Split into category packages; module github.com/ZacharyZhang-NY/MujicaUI

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 16:18:48 -04:00
1 parent 5a7e921c7e
commit 22b53e9e9e
1822 files changed
+24568 -21314

No files matched your search

+2 -2
View File
@@ -8,8 +8,8 @@
```go
var collapsed bool
mujica.AppShell(c, &collapsed, mujica.AppShellOptions{
TitleBar: func() { mujica.TitleBar(c, "Court Records", mujica.TitleBarOptions{}) },
layout.AppShell(c, &collapsed, layout.AppShellOptions{
TitleBar: func() { layout.TitleBar(c, "Court Records", layout.TitleBarOptions{}) },
Sidebar: func() { ui.Text(c, "Chronicles") },
Content: func() { ui.Text(c, "The Grand Hall") },
})
+2 -2
View File
@@ -7,8 +7,8 @@
## 最小示例
```go
mujica.TitleBar(c, "Court Records", mujica.TitleBarOptions{
Trailing: func() { mujica.Button(c, "Share", mujica.ButtonOptions{Variant: mujica.Ghost}) },
layout.TitleBar(c, "Court Records", layout.TitleBarOptions{
Trailing: func() { input.Button(c, "Share", input.ButtonOptions{Variant: input.Ghost}) },
})
```
+3 -3
View File
@@ -7,9 +7,9 @@
## 最小示例
```go
bar := mujica.StatusBar(c, mujica.StatusBarOptions{
Left: []mujica.StatusItem{{ID: "sync", Text: "Syncing", ShowProgress: true, Progress: 0.4}},
Right: []mujica.StatusItem{{ID: "bell", Label: "Notifications", Icon: icons.Must("bell"), Action: true}},
bar := layout.StatusBar(c, layout.StatusBarOptions{
Left: []layout.StatusItem{{ID: "sync", Text: "Syncing", ShowProgress: true, Progress: 0.4}},
Right: []layout.StatusItem{{ID: "bell", Label: "Notifications", Icon: icons.Must("bell"), Action: true}},
})
if bar.Clicked == "bell" {
opened++
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
mujica.Container(c, mujica.ContainerOptions{MaxWidth: 320, Center: true}, func() {
layout.Container(c, layout.ContainerOptions{MaxWidth: 320, Center: true}, func() {
ui.Text(c, "A centered column of prose.")
})
```
+4 -4
View File
@@ -7,12 +7,12 @@
## 最小示例
```go
mujica.Stack(c, mujica.StackOptions{Horizontal: true, Gap: mujica.SpaceM}, func() {
mujica.Button(c, "Save", mujica.ButtonOptions{})
layout.Stack(c, layout.StackOptions{Horizontal: true, Gap: layout.SpaceM}, func() {
input.Button(c, "Save", input.ButtonOptions{})
if showDraft {
mujica.Button(c, "Draft", mujica.ButtonOptions{Variant: mujica.Secondary})
input.Button(c, "Draft", input.ButtonOptions{Variant: input.Secondary})
}
mujica.Button(c, "Cancel", mujica.ButtonOptions{Variant: mujica.Ghost})
input.Button(c, "Cancel", input.ButtonOptions{Variant: input.Ghost})
})
```
+2 -2
View File
@@ -7,8 +7,8 @@
## 最小示例
```go
mujica.Grid(c, mujica.GridOptions{Columns: []ui.Track{ui.Fixed(96), ui.Fr(1)}}, func() {
mujica.GridCell(c, mujica.GridCellOptions{ColumnSpan: -1}, func() { ui.Text(c, "Header") })
layout.Grid(c, layout.GridOptions{Columns: []ui.Track{ui.Fixed(96), ui.Fr(1)}}, func() {
layout.GridCell(c, layout.GridCellOptions{ColumnSpan: -1}, func() { ui.Text(c, "Header") })
ui.Text(c, "Name")
ui.Text(c, "Ada")
})
+1 -1
View File
@@ -8,7 +8,7 @@
```go
var offset ui.ScrollState
mujica.ScrollArea(c, &offset, mujica.ScrollAreaOptions{Label: "Log"}, func() {
layout.ScrollArea(c, &offset, layout.ScrollAreaOptions{Label: "Log"}, func() {
for range 50 {
ui.Text(c, "A line of the log")
}
+2 -2
View File
@@ -7,8 +7,8 @@
## 最小示例
```go
split := mujica.SplitPaneState{Size: 160}
mujica.SplitPane(c, &split, mujica.SplitPaneOptions{MinFirst: 120, Collapsible: mujica.SplitPaneFirst},
split := layout.SplitPaneState{Size: 160}
layout.SplitPane(c, &split, layout.SplitPaneOptions{MinFirst: 120, Collapsible: layout.SplitPaneFirst},
func() { ui.Text(c, "Files") },
func() { ui.Text(c, "Editor") },
).Element.Fill()
+1 -1
View File
@@ -8,7 +8,7 @@
```go
ui.Box(c).Size(320, 240).Children(func() {
mujica.AspectRatio(c, mujica.AspectRatioOptions{Ratio: 16.0 / 9}, func() {
layout.AspectRatio(c, layout.AspectRatioOptions{Ratio: 16.0 / 9}, func() {
ui.Text(c, "16 : 9")
})
})
+2 -2
View File
@@ -8,8 +8,8 @@
```go
ui.Column(c).Padding(16).Gap(12).Children(func() {
mujica.Divider(c, mujica.DividerOptions{Ornament: true})
mujica.Divider(c, mujica.DividerOptions{Label: "Chapter II"})
layout.Divider(c, layout.DividerOptions{Ornament: true})
layout.Divider(c, layout.DividerOptions{Label: "Chapter II"})
})
```
+4 -4
View File
@@ -10,10 +10,10 @@
name := "Coronation.md"
saveErr := ""
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Text(c, "Order ID: 4821-AX", mujica.TextOptions{Selectable: true})
mujica.Text(c, "A long note that stops after two lines.", mujica.TextOptions{MaxLines: 2})
if mujica.EditableText(c, &name, mujica.EditableTextOptions{Error: saveErr}).Changed() {
core.Use(c, core.Settings{})
display.Text(c, "Order ID: 4821-AX", display.TextOptions{Selectable: true})
display.Text(c, "A long note that stops after two lines.", display.TextOptions{MaxLines: 2})
if display.EditableText(c, &name, display.EditableTextOptions{Error: saveErr}).Changed() {
saveErr = "" // save name here; set saveErr on failure
}
}
+3 -3
View File
@@ -8,9 +8,9 @@
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Heading(c, "The Grand Hall", mujica.HeadingOptions{Subtitle: "Winter ceremonies", Divider: true})
mujica.Heading(c, "Guest Ledger", mujica.HeadingOptions{Level: 2})
core.Use(c, core.Settings{})
display.Heading(c, "The Grand Hall", display.HeadingOptions{Subtitle: "Winter ceremonies", Divider: true})
display.Heading(c, "Guest Ledger", display.HeadingOptions{Level: 2})
}
```
+3 -3
View File
@@ -8,10 +8,10 @@
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
core.Use(c, core.Settings{})
ui.Row(c).Gap(8).Children(func() {
mujica.Icon(c, "star", mujica.IconOptions{})
mujica.Icon(c, "circle-check", mujica.IconOptions{Size: 20, Tone: mujica.IconSuccess, Label: "Done"})
display.Icon(c, "star", display.IconOptions{})
display.Icon(c, "circle-check", display.IconOptions{Size: 20, Tone: display.IconSuccess, Label: "Done"})
})
}
```
+2 -2
View File
@@ -10,8 +10,8 @@
var photo *ui.Bitmap // decode once with ui.DecodeBitmap, outside the view
loading, loadErr := false, errors.New("timeout")
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
img := mujica.Image(c, photo, mujica.ImageOptions{
core.Use(c, core.Settings{})
img := display.Image(c, photo, display.ImageOptions{
Width: 160, Height: 120, Crop: true, Alt: "Hall of mirrors",
Loading: loading, Err: loadErr,
})
+3 -3
View File
@@ -8,10 +8,10 @@
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
core.Use(c, core.Settings{})
ui.Row(c).Gap(8).Children(func() {
mujica.Avatar(c, "Sakiko Togawa", mujica.AvatarOptions{Size: 40})
mujica.Avatar(c, "", mujica.AvatarOptions{})
display.Avatar(c, "Sakiko Togawa", display.AvatarOptions{Size: 40})
display.Avatar(c, "", display.AvatarOptions{})
})
}
```
+3 -3
View File
@@ -7,13 +7,13 @@
## 最小示例
```go
people := []mujica.AvatarItem{
people := []display.AvatarItem{
{Name: "Sakiko Togawa"}, {Name: "Uika Misumi"}, {Name: "Mutsumi Wakaba"},
{Name: "Umiri Yahata"}, {Name: "Nyamu Yutenji"},
}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.AvatarGroup(c, people, mujica.AvatarGroupOptions{Max: 3})
core.Use(c, core.Settings{})
display.AvatarGroup(c, people, display.AvatarGroupOptions{Max: 3})
}
```
+4 -4
View File
@@ -9,10 +9,10 @@
```go
unread := 120
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Badge(c, mujica.BadgeOptions{Text: "New", Tone: mujica.BadgeNeutral}, nil)
mujica.Badge(c, mujica.BadgeOptions{Count: unread, Label: "Unread", Position: mujica.BadgeTopRight}, func() {
mujica.Avatar(c, "Sakiko Togawa", mujica.AvatarOptions{})
core.Use(c, core.Settings{})
display.Badge(c, display.BadgeOptions{Text: "New", Tone: display.BadgeNeutral}, nil)
display.Badge(c, display.BadgeOptions{Count: unread, Label: "Unread", Position: display.BadgeTopRight}, func() {
display.Avatar(c, "Sakiko Togawa", display.AvatarOptions{})
})
}
```
+3 -3
View File
@@ -9,12 +9,12 @@
```go
tags := []string{"Baroque", "Gothic"}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
core.Use(c, core.Settings{})
ui.Row(c).Gap(8).Children(func() {
for i, t := range tags {
var v mujica.TagView
var v display.TagView
ui.Box(c).Key(t).Children(func() {
v = mujica.Tag(c, t, mujica.TagOptions{Icon: "star", Clickable: true, Closable: true})
v = display.Tag(c, t, display.TagOptions{Icon: "star", Clickable: true, Closable: true})
})
if v.Closed {
tags = append(tags[:i:i], tags[i+1:]...)
+3 -3
View File
@@ -9,9 +9,9 @@
```go
details := false
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Link(c, "Read the charter", mujica.LinkOptions{URL: "https://example.com/charter"})
if mujica.Link(c, "Show details", mujica.LinkOptions{}).Clicked() {
core.Use(c, core.Settings{})
display.Link(c, "Read the charter", display.LinkOptions{URL: "https://example.com/charter"})
if display.Link(c, "Show details", display.LinkOptions{}).Clicked() {
details = !details
}
}
+3 -3
View File
@@ -8,10 +8,10 @@
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
core.Use(c, core.Settings{})
ui.Row(c).Gap(6).Children(func() {
mujica.Text(c, "Command palette", mujica.TextOptions{})
mujica.Kbd(c, "Mod", "Shift", "P")
display.Text(c, "Command palette", display.TextOptions{})
display.Kbd(c, "Mod", "Shift", "P")
})
}
```
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
if mujica.Button(c, "Save", mujica.ButtonOptions{Icon: icons.Must("check")}).Clicked() {
if input.Button(c, "Save", input.ButtonOptions{Icon: icons.Must("check")}).Clicked() {
fmt.Println("saved")
}
```
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
if mujica.IconButton(c, icons.Must("settings"), "Settings", mujica.IconButtonOptions{Variant: mujica.Ghost}).Clicked() {
if input.IconButton(c, icons.Must("settings"), "Settings", input.IconButtonOptions{Variant: input.Ghost}).Clicked() {
fmt.Println("open settings")
}
```
+2 -2
View File
@@ -7,8 +7,8 @@
## 最小示例
```go
items := []mujica.ButtonGroupItem{{Label: "Day"}, {Label: "Week"}, {Label: "Month"}}
if i := mujica.ButtonGroup(c, items, mujica.ButtonGroupOptions{Label: "Range"}).ClickedItem(); i >= 0 {
items := []input.ButtonGroupItem{{Label: "Day"}, {Label: "Week"}, {Label: "Month"}}
if i := input.ButtonGroup(c, items, input.ButtonGroupOptions{Label: "Range"}).ClickedItem(); i >= 0 {
fmt.Println("chose", items[i].Label)
}
```
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
r := mujica.TextInput(c, &name, mujica.TextInputOptions{Label: "Name", Placeholder: "Your name", Clearable: true})
r := input.TextInput(c, &name, input.TextInputOptions{Label: "Name", Placeholder: "Your name", Clearable: true})
if r.Submitted() {
fmt.Println("hello", name)
}
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
r := mujica.TextArea(c, &notes, mujica.TextAreaOptions{Label: "Notes", MaxHeight: 160, MaxLength: 200})
r := input.TextArea(c, &notes, input.TextAreaOptions{Label: "Notes", MaxHeight: 160, MaxLength: 200})
if r.Submitted() {
fmt.Println("send", notes)
}
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
if mujica.NumberInput(c, &copies, mujica.NumberInputOptions{Min: 1, Max: 99, Label: "Copies"}).Changed() {
if input.NumberInput(c, &copies, input.NumberInputOptions{Min: 1, Max: 99, Label: "Copies"}).Changed() {
fmt.Println("copies", copies)
}
```
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
if mujica.PasswordInput(c, &password, mujica.PasswordInputOptions{Label: "Password"}).Submitted() {
if input.PasswordInput(c, &password, input.PasswordInputOptions{Label: "Password"}).Submitted() {
fmt.Println("signing in")
}
```
+1 -1
View File
@@ -11,7 +11,7 @@ matches := 0
if query != "" {
matches = strings.Count(text, query)
}
r := mujica.SearchInput(c, &query, mujica.SearchInputOptions{Find: true, Matches: matches, Current: &current})
r := input.SearchInput(c, &query, input.SearchInputOptions{Find: true, Matches: matches, Current: &current})
if r.Moved() {
fmt.Println("show match", current)
}
+2 -2
View File
@@ -7,10 +7,10 @@
## 最小示例
```go
mujica.CheckboxGroup(c, "Notifications", []mujica.CheckboxItem{
input.CheckboxGroup(c, "Notifications", []input.CheckboxItem{
{Label: "Mail", Value: &mail},
{Label: "Calendar", Value: &calendar},
}, mujica.CheckboxGroupOptions{})
}, input.CheckboxGroupOptions{})
```
签名:
+2 -2
View File
@@ -7,8 +7,8 @@
## 最小示例
```go
items := []mujica.RadioItem[string]{{Value: "s", Label: "Small"}, {Value: "m", Label: "Medium"}, {Value: "l", Label: "Large"}}
if mujica.RadioGroup(c, &size, items, mujica.RadioGroupOptions{Label: "Size"}).Changed() {
items := []input.RadioItem[string]{{Value: "s", Label: "Small"}, {Value: "m", Label: "Medium"}, {Value: "l", Label: "Large"}}
if input.RadioGroup(c, &size, items, input.RadioGroupOptions{Label: "Size"}).Changed() {
fmt.Println("size", size)
}
```
+2 -2
View File
@@ -9,8 +9,8 @@
```go
wifi := true
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
if mujica.Switch(c, &wifi, "Wi-Fi", mujica.SwitchOptions{}).Changed() {
core.Use(c, core.Settings{})
if input.Switch(c, &wifi, "Wi-Fi", input.SwitchOptions{}).Changed() {
log.Println("Wi-Fi:", wifi)
}
}
+2 -2
View File
@@ -9,8 +9,8 @@
```go
bold := false
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Toggle(c, &bold, "", mujica.ToggleOptions{Icon: icons.Must("bold"), Label: "Bold"})
core.Use(c, core.Settings{})
input.Toggle(c, &bold, "", input.ToggleOptions{Icon: icons.Must("bold"), Label: "Bold"})
}
ui.Render(view, 400, 300, 1)
```
+3 -3
View File
@@ -8,14 +8,14 @@
```go
align := []string{"left"}
items := []mujica.ToggleItem[string]{
items := []input.ToggleItem[string]{
{Value: "left", Label: "Left"},
{Value: "center", Label: "Center"},
{Value: "right", Label: "Right"},
}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.ToggleGroup(c, &align, items, mujica.ToggleGroupOptions{Label: "Align"})
core.Use(c, core.Settings{})
input.ToggleGroup(c, &align, items, input.ToggleGroupOptions{Label: "Align"})
}
ui.Render(view, 400, 300, 1)
```
+2 -2
View File
@@ -9,8 +9,8 @@
```go
volume := 40.0
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Slider(c, &volume, mujica.SliderOptions{Step: 5, ShowValue: true, Label: "Volume"})
core.Use(c, core.Settings{})
input.Slider(c, &volume, input.SliderOptions{Step: 5, ShowValue: true, Label: "Volume"})
}
ui.Render(view, 400, 300, 1)
```
+2 -2
View File
@@ -9,8 +9,8 @@
```go
low, high := 20.0, 80.0
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.RangeSlider(c, &low, &high, mujica.RangeSliderOptions{Step: 10, Label: "Price"})
core.Use(c, core.Settings{})
input.RangeSlider(c, &low, &high, input.RangeSliderOptions{Step: 10, Label: "Price"})
}
ui.Render(view, 400, 300, 1)
```
+3 -3
View File
@@ -8,14 +8,14 @@
```go
plan := ""
options := []mujica.SelectOption[string]{
options := []input.SelectOption[string]{
{Value: "free", Label: "Free"},
{Value: "pro", Label: "Pro"},
{Value: "team", Label: "Team", Disabled: true},
}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Select(c, &plan, options, mujica.SelectOptions{Clearable: true, Label: "Plan"})
core.Use(c, core.Settings{})
input.Select(c, &plan, options, input.SelectOptions{Clearable: true, Label: "Plan"})
}
ui.Render(view, 400, 300, 1)
```
+3 -3
View File
@@ -8,14 +8,14 @@
```go
tags := []int{1}
options := []mujica.SelectOption[int]{
options := []input.SelectOption[int]{
{Value: 1, Label: "Rose"},
{Value: 2, Label: "Lily"},
{Value: 3, Label: "Iris"},
}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.MultiSelect(c, &tags, options, mujica.MultiSelectOptions{Max: 2, Label: "Flowers"})
core.Use(c, core.Settings{})
input.MultiSelect(c, &tags, options, input.MultiSelectOptions{Max: 2, Label: "Flowers"})
}
ui.Render(view, 400, 300, 1)
```
+2 -2
View File
@@ -10,8 +10,8 @@
font := ""
fonts := []string{"Garamond", "Georgia", "Didot"}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
r := mujica.Combobox(c, &font, fonts, mujica.ComboboxOptions{AllowCustom: true, Label: "Font"})
core.Use(c, core.Settings{})
r := input.Combobox(c, &font, fonts, input.ComboboxOptions{AllowCustom: true, Label: "Font"})
if r.QueryChanged() {
log.Println("search:", r.Query())
}
+5 -5
View File
@@ -8,15 +8,15 @@
```go
var path []string
level := func(p []string) mujica.CascaderLevel {
level := func(p []string) input.CascaderLevel {
if len(p) == 0 {
return mujica.CascaderLevel{Nodes: []mujica.CascaderNode{{Value: "fr", Label: "France"}}}
return input.CascaderLevel{Nodes: []input.CascaderNode{{Value: "fr", Label: "France"}}}
}
return mujica.CascaderLevel{Nodes: []mujica.CascaderNode{{Value: "paris", Label: "Paris", Leaf: true}}}
return input.CascaderLevel{Nodes: []input.CascaderNode{{Value: "paris", Label: "Paris", Leaf: true}}}
}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Cascader(c, &path, mujica.CascaderOptions{Level: level, Label: "City"})
core.Use(c, core.Settings{})
input.Cascader(c, &path, input.CascaderOptions{Level: level, Label: "City"})
}
ui.Render(view, 400, 300, 1)
```
+4 -4
View File
@@ -8,15 +8,15 @@
```go
var roles []string
nodes := []mujica.TreeSelectNode{
{ID: "court", Label: "Court", Children: []mujica.TreeSelectNode{
nodes := []input.TreeSelectNode{
{ID: "court", Label: "Court", Children: []input.TreeSelectNode{
{ID: "king", Label: "King"},
{ID: "queen", Label: "Queen"},
}},
}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.TreeSelect(c, &roles, nodes, mujica.TreeSelectOptions{Multiple: true, Label: "Roles"})
core.Use(c, core.Settings{})
input.TreeSelect(c, &roles, nodes, input.TreeSelectOptions{Multiple: true, Label: "Roles"})
}
ui.Render(view, 400, 300, 1)
```
+5 -5
View File
@@ -9,13 +9,13 @@
## 最小示例
```go
var state mujica.FormState
var state input.FormState
name := ""
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
res := mujica.Form(c, &state, mujica.FormOptions{}, func(f *mujica.FormScope) {
mujica.FormItem(c, f, "name", &name, mujica.FormItemOptions[string]{Label: "Name", Required: true}, func() *ui.Element {
return mujica.InputGroup(c, &name, mujica.InputGroupOptions{Invalid: state.Error("name") != ""}).Input
core.Use(c, core.Settings{})
res := input.Form(c, &state, input.FormOptions{}, func(f *input.FormScope) {
input.FormItem(c, f, "name", &name, input.FormItemOptions[string]{Label: "Name", Required: true}, func() *ui.Element {
return input.InputGroup(c, &name, input.InputGroupOptions{Invalid: state.Error("name") != ""}).Input
})
})
if res.Submitted() {
+3 -3
View File
@@ -11,9 +11,9 @@
```go
email := ""
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.FormField(c, "Email", mujica.FormFieldOptions{Required: true, Description: "For receipts."}, func() *ui.Element {
return mujica.InputGroup(c, &email, mujica.InputGroupOptions{}).Input
core.Use(c, core.Settings{})
input.FormField(c, "Email", input.FormFieldOptions{Required: true, Description: "For receipts."}, func() *ui.Element {
return input.InputGroup(c, &email, input.InputGroupOptions{}).Input
})
}
ui.Render(view, 400, 300, 1)
+3 -3
View File
@@ -11,10 +11,10 @@
```go
site := ""
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
g := mujica.InputGroup(c, &site, mujica.InputGroupOptions{
core.Use(c, core.Settings{})
g := input.InputGroup(c, &site, input.InputGroupOptions{
Prefix: "https://", Label: "Site",
Buttons: []mujica.InputGroupButton{{Label: "Open"}},
Buttons: []input.InputGroupButton{{Label: "Open"}},
})
if g.Clicked == 0 {
c.OpenURL("https://" + site)
+2 -2
View File
@@ -11,8 +11,8 @@
```go
code := ""
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
if mujica.PinInput(c, &code, mujica.PinInputOptions{Length: 6}).Completed() {
core.Use(c, core.Settings{})
if input.PinInput(c, &code, input.PinInputOptions{Length: 6}).Completed() {
fmt.Println("verify", code)
}
}
+2 -2
View File
@@ -11,8 +11,8 @@
```go
tags := []string{"gothic"}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.TagsInput(c, &tags, mujica.TagsInputOptions{Max: 5, Placeholder: "Add a tag", Label: "Tags"})
core.Use(c, core.Settings{})
input.TagsInput(c, &tags, input.TagsInputOptions{Max: 5, Placeholder: "Add a tag", Label: "Tags"})
}
ui.Render(view, 400, 300, 1)
```
+2 -2
View File
@@ -11,8 +11,8 @@
```go
stars := 3.5
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Rating(c, &stars, mujica.RatingOptions{Step: 0.5, ShowValue: true})
core.Use(c, core.Settings{})
input.Rating(c, &stars, input.RatingOptions{Step: 0.5, ShowValue: true})
}
ui.Render(view, 400, 300, 1)
```
+2 -2
View File
@@ -11,8 +11,8 @@
```go
tint := ui.Hex("#7D2034")
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.ColorPicker(c, &tint, mujica.ColorPickerOptions{Label: "Tint"})
core.Use(c, core.Settings{})
input.ColorPicker(c, &tint, input.ColorPickerOptions{Label: "Tint"})
}
ui.Render(view, 400, 300, 1)
```
+2 -2
View File
@@ -11,8 +11,8 @@
```go
var paths []string
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.FilePicker(c, &paths, mujica.FilePickerOptions{
core.Use(c, core.Settings{})
input.FilePicker(c, &paths, input.FilePickerOptions{
Multiple: true,
Filters: []mygo.FileFilter{{Name: "Scores", Extensions: []string{"pdf", "mid"}}},
})
+3 -3
View File
@@ -9,10 +9,10 @@
## 最小示例
```go
var files []mujica.DroppedFile
var files []input.DroppedFile
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.FileDropZone(c, &files, mujica.FileDropZoneOptions{
core.Use(c, core.Settings{})
input.FileDropZone(c, &files, input.FileDropZoneOptions{
Extensions: []string{"png", "jpg"}, MaxFiles: 3, MaxSize: 5 << 20,
})
}
+3 -3
View File
@@ -10,10 +10,10 @@
```go
chosen := []string{"uika"}
items := []mujica.TransferItem{{ID: "uika", Label: "Uika"}, {ID: "mutsumi", Label: "Mutsumi"}, {ID: "nyamu", Label: "Nyamu", Disabled: true}}
items := []input.TransferItem{{ID: "uika", Label: "Uika"}, {ID: "mutsumi", Label: "Mutsumi"}, {ID: "nyamu", Label: "Nyamu", Disabled: true}}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Transfer(c, &chosen, items, mujica.TransferOptions{})
core.Use(c, core.Settings{})
input.Transfer(c, &chosen, items, input.TransferOptions{})
}
ui.Render(view, 400, 300, 1)
```
+3 -3
View File
@@ -7,10 +7,10 @@
## 最小示例
```go
day := mujica.Date{Year: 2026, Month: time.October, Day: 5}
day := core.Date{Year: 2026, Month: time.October, Day: 5}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
if mujica.Calendar(c, &day, mujica.CalendarOptions{WeekStart: mujica.WeekStartMonday}).Changed() {
core.Use(c, core.Settings{})
if datetime.Calendar(c, &day, datetime.CalendarOptions{WeekStart: datetime.WeekStartMonday}).Changed() {
fmt.Println("chosen", day)
}
}
+5 -5
View File
@@ -7,12 +7,12 @@
## 最小示例
```go
due := mujica.Date{Year: 2026, Month: time.October, Day: 5}
due := core.Date{Year: 2026, Month: time.October, Day: 5}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
opts := mujica.DatePickerOptions{Label: "Due date", Clearable: true,
Min: mujica.Date{Year: 2026, Month: time.January, Day: 1}}
if mujica.DatePicker(c, &due, opts).Changed() {
core.Use(c, core.Settings{})
opts := datetime.DatePickerOptions{Label: "Due date", Clearable: true,
Min: core.Date{Year: 2026, Month: time.January, Day: 1}}
if datetime.DatePicker(c, &due, opts).Changed() {
fmt.Println("due", due)
}
}
+3 -3
View File
@@ -7,10 +7,10 @@
## 最小示例
```go
var stay mujica.DateRange
var stay datetime.DateRange
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
r := mujica.DateRangePicker(c, &stay, mujica.DateRangePickerOptions{Label: "Stay"})
core.Use(c, core.Settings{})
r := datetime.DateRangePicker(c, &stay, datetime.DateRangePickerOptions{Label: "Stay"})
if r.Changed() {
fmt.Println("stay", stay.Start, stay.End, stay.Days())
}
+4 -4
View File
@@ -7,11 +7,11 @@
## 最小示例
```go
alarm := mujica.TimeOfDay{Hour: 7, Minute: 30}
alarm := datetime.TimeOfDay{Hour: 7, Minute: 30}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
opts := mujica.TimePickerOptions{Label: "Alarm", Hour12: true, MinuteStep: 5}
if mujica.TimePicker(c, &alarm, opts).Changed() {
core.Use(c, core.Settings{})
opts := datetime.TimePickerOptions{Label: "Alarm", Hour12: true, MinuteStep: 5}
if datetime.TimePicker(c, &alarm, opts).Changed() {
fmt.Println("alarm", alarm)
}
}
+4 -4
View File
@@ -7,11 +7,11 @@
## 最小示例
```go
shift := mujica.TimeRange{Start: mujica.TimeOfDay{Hour: 22}, End: mujica.TimeOfDay{Hour: 6}}
shift := datetime.TimeRange{Start: datetime.TimeOfDay{Hour: 22}, End: datetime.TimeOfDay{Hour: 6}}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
opts := mujica.TimeRangePickerOptions{Label: "Night shift", AllowOvernight: true}
if mujica.TimeRangePicker(c, &shift, opts).Changed() {
core.Use(c, core.Settings{})
opts := datetime.TimeRangePickerOptions{Label: "Night shift", AllowOvernight: true}
if datetime.TimeRangePicker(c, &shift, opts).Changed() {
fmt.Println("shift", shift.Start, shift.End, shift.Overnight())
}
}
+3 -3
View File
@@ -13,9 +13,9 @@ if err != nil {
}
var meeting time.Time
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
opts := mujica.DateTimePickerOptions{Label: "Meeting", Location: tokyo, MinuteStep: 15}
if mujica.DateTimePicker(c, &meeting, opts).Changed() {
core.Use(c, core.Settings{})
opts := datetime.DateTimePickerOptions{Label: "Meeting", Location: tokyo, MinuteStep: 15}
if datetime.DateTimePicker(c, &meeting, opts).Changed() {
fmt.Println("meeting", meeting)
}
}
+4 -4
View File
@@ -7,11 +7,11 @@
## 最小示例
```go
var month mujica.YearMonth
var month datetime.YearMonth
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
opts := mujica.MonthPickerOptions{Label: "Billing month", Clearable: true}
if mujica.MonthPicker(c, &month, opts).Changed() {
core.Use(c, core.Settings{})
opts := datetime.MonthPickerOptions{Label: "Billing month", Clearable: true}
if datetime.MonthPicker(c, &month, opts).Changed() {
fmt.Println("month", month)
}
}
+3 -3
View File
@@ -9,9 +9,9 @@
```go
year := 2026
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
opts := mujica.YearPickerOptions{Label: "Vintage", Min: 1990, Max: 2030}
if mujica.YearPicker(c, &year, opts).Changed() {
core.Use(c, core.Settings{})
opts := datetime.YearPickerOptions{Label: "Vintage", Min: 1990, Max: 2030}
if datetime.YearPicker(c, &year, opts).Changed() {
fmt.Println("year", year)
}
}
+2 -2
View File
@@ -7,11 +7,11 @@
## 最小示例
```go
if mujica.Tabs(c, &tab, []mujica.Tab{
if navigation.Tabs(c, &tab, []navigation.Tab{
{Label: "General", Panel: func() { ui.Text(c, "General settings") }},
{Label: "Fonts", Icon: icons.Must("italic"), Panel: func() { ui.Text(c, "Fonts") }},
{Label: "Archive", Disabled: true},
}, mujica.TabsOptions{Label: "Settings"}).Changed() {
}, navigation.TabsOptions{Label: "Settings"}).Changed() {
fmt.Println("tab", tab)
}
```
+2 -2
View File
@@ -7,10 +7,10 @@
## 最小示例
```go
if mujica.SegmentedControl(c, &view, []mujica.Segment{
if navigation.SegmentedControl(c, &view, []navigation.Segment{
{Label: "List", Icon: icons.Must("list"), HideLabel: true},
{Label: "Grid", Icon: icons.Must("layout-grid"), HideLabel: true},
}, mujica.SegmentedControlOptions{Label: "View"}).Changed() {
}, navigation.SegmentedControlOptions{Label: "View"}).Changed() {
fmt.Println("view", view)
}
```
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
if i, ok := mujica.Breadcrumb(c, path, mujica.BreadcrumbOptions{}).Chosen(); ok {
if i, ok := navigation.Breadcrumb(c, path, navigation.BreadcrumbOptions{}).Chosen(); ok {
path = path[:i+1]
}
```
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
if mujica.Pagination(c, &page, &size, mujica.PaginationOptions{Total: 420, PageSizes: []int{10, 20, 50}, Jump: true}).Changed() {
if navigation.Pagination(c, &page, &size, navigation.PaginationOptions{Total: 420, PageSizes: []int{10, 20, 50}, Jump: true}).Changed() {
fmt.Println("load page", page, "of size", size)
}
```
+2 -2
View File
@@ -7,11 +7,11 @@
## 最小示例
```go
mujica.Steps(c, &current, []mujica.Step{
navigation.Steps(c, &current, []navigation.Step{
{Title: "Account", Clickable: true},
{Title: "Profile", Description: "Name and seal"},
{Title: "Confirm"},
}, mujica.StepsOptions{Label: "Sign-up"})
}, navigation.StepsOptions{Label: "Sign-up"})
```
签名:`func Steps(c *ui.Context, current *int, steps []Step, opts StepsOptions) ChoiceResult`
+4 -4
View File
@@ -7,12 +7,12 @@
## 最小示例
```go
mujica.Sidebar(c, &selected, []mujica.SidebarSection{
{Title: "Mail", Items: []mujica.SidebarItem{
navigation.Sidebar(c, &selected, []navigation.SidebarSection{
{Title: "Mail", Items: []navigation.SidebarItem{
{ID: "inbox", Label: "Inbox", Icon: icons.Must("inbox"), Count: 3},
{Label: "Folders", Items: []mujica.SidebarItem{{ID: "work", Label: "Work", Icon: icons.Must("folder")}}},
{Label: "Folders", Items: []navigation.SidebarItem{{ID: "work", Label: "Work", Icon: icons.Must("folder")}}},
}},
}, mujica.SidebarOptions{})
}, navigation.SidebarOptions{})
```
签名:`func Sidebar(c *ui.Context, selected *string, sections []SidebarSection, opts SidebarOptions) ChoiceResult`
+4 -4
View File
@@ -7,12 +7,12 @@
## 最小示例
```go
mujica.NavigationMenu(c, router, []mujica.NavigationLink{
navigation.NavigationMenu(c, router, []navigation.NavigationLink{
{Label: "Home", Path: "/"},
{Label: "Library", Items: []mujica.NavigationLink{
{Label: "Library", Items: []navigation.NavigationLink{
{Label: "Poems", Path: "/library/poems", Description: "Verse of the court"},
}},
}, mujica.NavigationMenuOptions{History: true})
}, navigation.NavigationMenuOptions{History: true})
router.View(c, func(r *ui.Route) { ui.Text(c, r.Path()) })
```
@@ -58,6 +58,6 @@ router.View(c, func(r *ui.Route) { ui.Text(c, r.Path()) })
## 限制
- MyGo 历史按钮的提示文字固定为英文 “Back” / “Forward”(`ui/router.go:713`);本组件覆盖了无障碍名称,但提示仍为英文。
- 历史按钮的外观来自 MyGo 主题按钮样式(经 `mujica.Use` 映射为 MujicaUI 颜色)。
- 历史按钮的外观来自 MyGo 主题按钮样式(经 `core.Use` 映射为 MujicaUI 颜色)。
- 弹层打开时在 160 ms 内淡入,减少动画时直接显示。关闭时立即消失:弹层关闭后 MyGo 不再构建其元素,公开接口无法为已移除的浮层做淡出。
- 下拉面板最高为锚点上方或下方可用空间,超出时在面板内滚动;方向键移动焦点时自动滚入视野。
+7 -7
View File
@@ -7,15 +7,15 @@
## 最小示例
```go
res := mujica.Menubar(c, []mujica.MenubarMenu{
{Label: "File", Items: []mujica.MenubarItem{
{ID: "new", Label: "New", Shortcut: mujica.MenubarShortcut{Mods: ui.Cmd, Key: ui.KeyN}},
{Label: "Export", Items: []mujica.MenubarItem{{ID: "pdf", Label: "PDF"}}},
res := navigation.Menubar(c, []navigation.MenubarMenu{
{Label: "File", Items: []navigation.MenubarItem{
{ID: "new", Label: "New", Shortcut: navigation.MenubarShortcut{Mods: ui.Cmd, Key: ui.KeyN}},
{Label: "Export", Items: []navigation.MenubarItem{{ID: "pdf", Label: "PDF"}}},
}},
{Label: "View", Items: []mujica.MenubarItem{
{ID: "wrap", Label: "Word wrap", Kind: mujica.MenubarCheck, Checked: wrap},
{Label: "View", Items: []navigation.MenubarItem{
{ID: "wrap", Label: "Word wrap", Kind: navigation.MenubarCheck, Checked: wrap},
}},
}, mujica.MenubarOptions{})
}, navigation.MenubarOptions{})
if id, ok := res.Chosen(); ok && id == "wrap" {
wrap = !wrap
}
+6 -6
View File
@@ -7,13 +7,13 @@
## 最小示例
```go
mujica.Toolbar(c, mujica.ToolbarOptions{Label: "Format"}, func() {
mujica.ToolbarGroup(c, func() {
mujica.ToolbarButton(c, "Bold", mujica.ToolbarButtonOptions{Icon: icons.Must("bold")})
mujica.ToolbarButton(c, "Italic", mujica.ToolbarButtonOptions{Icon: icons.Must("italic")})
navigation.Toolbar(c, navigation.ToolbarOptions{Label: "Format"}, func() {
navigation.ToolbarGroup(c, func() {
navigation.ToolbarButton(c, "Bold", navigation.ToolbarButtonOptions{Icon: icons.Must("bold")})
navigation.ToolbarButton(c, "Italic", navigation.ToolbarButtonOptions{Icon: icons.Must("italic")})
})
mujica.ToolbarSeparator(c)
if mujica.ToolbarButton(c, "Copy", mujica.ToolbarButtonOptions{Icon: icons.Must("copy"), ShowLabel: true}).Clicked() {
navigation.ToolbarSeparator(c)
if navigation.ToolbarButton(c, "Copy", navigation.ToolbarButtonOptions{Icon: icons.Must("copy"), ShowLabel: true}).Clicked() {
fmt.Println("copy")
}
})
+2 -2
View File
@@ -7,10 +7,10 @@
## 最小示例
```go
res := mujica.CommandPalette(c, &open, []mujica.Command{
res := navigation.CommandPalette(c, &open, []navigation.Command{
{ID: "new", Label: "New document", Group: "File"},
{ID: "theme", Label: "Toggle dark mode", Group: "View", Keywords: []string{"night"}},
}, mujica.CommandPaletteOptions{})
}, navigation.CommandPaletteOptions{})
if id, ok := res.Chosen(); ok {
fmt.Println("run", id)
}
+3 -3
View File
@@ -8,9 +8,9 @@
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Card(c, mujica.CardOptions{Title: "Archive", Decorated: true, Footer: func() {
mujica.Button(c, "Open", mujica.ButtonOptions{})
core.Use(c, core.Settings{})
data.Card(c, data.CardOptions{Title: "Archive", Decorated: true, Footer: func() {
input.Button(c, "Open", input.ButtonOptions{})
}}, func() {
ui.Text(c, "Letters of the court, sealed in wax.")
}).Width(280)
+3 -3
View File
@@ -8,10 +8,10 @@
```go
names := []string{"Matins", "Lauds", "Prime", "Terce"}
var state mujica.ListState[string]
var state data.ListState[string]
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
v := mujica.List(c, &state, len(names), mujica.ListOptions[string]{
core.Use(c, core.Settings{})
v := data.List(c, &state, len(names), data.ListOptions[string]{
Key: func(i int) string { return names[i] },
Label: func(i int) string { return names[i] },
}, func(i int) { ui.Text(c, names[i]) })
+5 -5
View File
@@ -13,10 +13,10 @@ type relic struct {
Age int
}
rows := []relic{{1, "Censer", 300}, {2, "Altar", 120}, {3, "Bell", 80}}
var state mujica.DataTableState[int]
opts := mujica.DataTableOptions[relic, int]{
var state data.DataTableState[int]
opts := data.DataTableOptions[relic, int]{
Key: func(r relic) int { return r.ID },
Columns: []mujica.DataColumn[relic]{
Columns: []data.DataColumn[relic]{
{ID: "name", Title: "Name", Sortable: true,
Text: func(r relic) string { return r.Name },
Compare: func(a, b relic) int { return cmp.Compare(a.Name, b.Name) }},
@@ -26,8 +26,8 @@ opts := mujica.DataTableOptions[relic, int]{
},
}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.DataTable(c, &state, rows, opts).Element.Size(360, 240)
core.Use(c, core.Settings{})
data.DataTable(c, &state, rows, opts).Element.Size(360, 240)
}
ui.Render(view, 400, 300, 1)
```
+3 -3
View File
@@ -8,10 +8,10 @@
```go
kids := map[string][]string{"Nave": {"Pulpit", "Pews"}}
var state mujica.TreeState[string]
var state data.TreeState[string]
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Tree(c, &state, mujica.TreeOptions[string]{
core.Use(c, core.Settings{})
data.Tree(c, &state, data.TreeOptions[string]{
Roots: []string{"Nave", "Sacristy"},
Children: func(n string) []string { return kids[n] },
Label: func(n string) string { return n },
+4 -4
View File
@@ -9,14 +9,14 @@
```go
kids := map[string][]string{"Vestry": {"Stole", "Alb"}}
size := map[string]int{"Vestry": 9, "Stole": 2, "Alb": 5, "Organ": 7}
var state mujica.TreeTableState[string]
var state data.TreeTableState[string]
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.TreeTable(c, &state, mujica.TreeTableOptions[string]{
core.Use(c, core.Settings{})
data.TreeTable(c, &state, data.TreeTableOptions[string]{
Roots: []string{"Vestry", "Organ"},
Children: func(n string) []string { return kids[n] },
Label: func(n string) string { return n },
Columns: []mujica.TreeColumn[string]{
Columns: []data.TreeColumn[string]{
{ID: "name", Title: "Name", Cell: func(n string) { ui.Text(c, n) },
Compare: cmp.Compare[string]},
{ID: "size", Title: "Size", Width: 80, Align: ui.End,
+3 -3
View File
@@ -9,11 +9,11 @@
```go
open := []string{"choir"}
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Accordion(c, &open, []mujica.AccordionItem{
core.Use(c, core.Settings{})
data.Accordion(c, &open, []data.AccordionItem{
{ID: "choir", Title: "Choir", Content: func() { ui.Text(c, "Twelve voices.") }},
{ID: "nave", Title: "Nave", Content: func() { ui.Text(c, "Black oak pews.") }},
}, mujica.AccordionOptions{})
}, data.AccordionOptions{})
}
ui.Render(view, 400, 300, 1)
```
+2 -2
View File
@@ -9,8 +9,8 @@
```go
open := false
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Collapsible(c, &open, mujica.CollapsibleOptions{Title: "Details"}, func() {
core.Use(c, core.Settings{})
data.Collapsible(c, &open, data.CollapsibleOptions{Title: "Details"}, func() {
ui.Text(c, "Candles are lit at the seventh bell.")
})
}
+4 -4
View File
@@ -8,10 +8,10 @@
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Timeline(c, []mujica.TimelineItem{
{Time: "06:00", Title: "Matins sung", Status: mujica.TimelineDone},
{Time: "09:00", Title: "Relics moved", Content: "From the crypt to the altar.", Status: mujica.TimelineActive},
core.Use(c, core.Settings{})
data.Timeline(c, []data.TimelineItem{
{Time: "06:00", Title: "Matins sung", Status: data.TimelineDone},
{Time: "09:00", Title: "Relics moved", Content: "From the crypt to the altar.", Status: data.TimelineActive},
{Time: "18:00", Title: "Vespers"},
})
}
+3 -3
View File
@@ -8,12 +8,12 @@
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.DescriptionList(c, []mujica.DescriptionItem{
core.Use(c, core.Settings{})
data.DescriptionList(c, []data.DescriptionItem{
{Label: "Archivist", Value: "Sister Agnès", Copyable: true},
{Label: "Shelf", Value: "North vault, row 7"},
{Label: "Seal", Value: "Wine-red wax", Span: -1},
}, mujica.DescriptionListOptions{})
}, data.DescriptionListOptions{})
}
ui.Render(view, 400, 300, 1)
```
+2 -2
View File
@@ -9,8 +9,8 @@
```go
change := 12.5
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Statistic(c, 12840, mujica.StatisticOptions{
core.Use(c, core.Settings{})
data.Statistic(c, 12840, data.StatisticOptions{
Title: "Pilgrims", Unit: "souls", Precision: 0,
Change: &change, ChangeUnit: "%", ChangeNote: "vs last feast",
})
+2 -2
View File
@@ -10,8 +10,8 @@
picture := ui.MustParseSVG([]byte(`<svg xmlns="http://www.w3.org/2000/svg" width="240" height="160"><rect width="240" height="160" fill="#AD9164"/><path d="M120 20 L200 80 L120 140 L40 80 Z" fill="#7D2034"/></svg>`))
open, index := true, 0
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.ImageViewer(c, &open, &index, []mujica.ViewerImage{{Source: picture, Alt: "Rose window"}})
core.Use(c, core.Settings{})
data.ImageViewer(c, &open, &index, []data.ViewerImage{{Source: picture, Alt: "Rose window"}})
}
ui.Render(view, 400, 300, 1)
```
+2 -2
View File
@@ -9,8 +9,8 @@
```go
index := 0
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Carousel(c, &index, 3, mujica.CarouselOptions{Label: "Windows", Autoplay: true}, func(i int) {
core.Use(c, core.Settings{})
data.Carousel(c, &index, 3, data.CarouselOptions{Label: "Windows", Autoplay: true}, func(i int) {
ui.Text(c, fmt.Sprintf("Rose window %d", i+1)).Padding(24)
}).Element.Size(360, 220)
}
+5 -5
View File
@@ -10,19 +10,19 @@
open := true
name := "Ophelia"
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
if mujica.Button(c, "Rename…", mujica.ButtonOptions{}).Clicked() {
core.Use(c, core.Settings{})
if input.Button(c, "Rename…", input.ButtonOptions{}).Clicked() {
open = true
}
mujica.Dialog(c, &open, mujica.DialogOptions{
overlay.Dialog(c, &open, overlay.DialogOptions{
Title: "Rename the chamber",
Description: "The new name shows in every hall.",
Decorated: true,
Actions: func() {
if mujica.Button(c, "Cancel", mujica.ButtonOptions{Variant: mujica.Secondary}).Clicked() {
if input.Button(c, "Cancel", input.ButtonOptions{Variant: input.Secondary}).Clicked() {
open = false
}
if mujica.Button(c, "Rename", mujica.ButtonOptions{}).Clicked() {
if input.Button(c, "Rename", input.ButtonOptions{}).Clicked() {
open = false
}
},
+3 -3
View File
@@ -9,11 +9,11 @@
```go
open := true
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
if mujica.Button(c, "Delete archive", mujica.ButtonOptions{Variant: mujica.Danger}).Clicked() {
core.Use(c, core.Settings{})
if input.Button(c, "Delete archive", input.ButtonOptions{Variant: input.Danger}).Clicked() {
open = true
}
r := mujica.AlertDialog(c, &open, mujica.AlertDialogOptions{
r := overlay.AlertDialog(c, &open, overlay.AlertDialogOptions{
Title: "Delete the archive?",
Description: "Twelve letters will be destroyed.",
ConfirmText: "archive",
+3 -3
View File
@@ -9,11 +9,11 @@
```go
open := true
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
if mujica.Button(c, "Filters", mujica.ButtonOptions{}).Clicked() {
core.Use(c, core.Settings{})
if input.Button(c, "Filters", input.ButtonOptions{}).Clicked() {
open = true
}
mujica.Drawer(c, &open, mujica.DrawerOptions{Title: "Filters", Side: mujica.DrawerRight, Size: 320}, func() {
overlay.Drawer(c, &open, overlay.DrawerOptions{Title: "Filters", Side: overlay.DrawerRight, Size: 320}, func() {
ui.Text(c, "Guests are placed by rank.")
})
}
+3 -3
View File
@@ -9,12 +9,12 @@
```go
open := true
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
b := mujica.Button(c, "Guests", mujica.ButtonOptions{Variant: mujica.Secondary})
core.Use(c, core.Settings{})
b := input.Button(c, "Guests", input.ButtonOptions{Variant: input.Secondary})
if b.Clicked() {
open = !open
}
mujica.Popover(c, b, &open, mujica.PopoverOptions{Title: "Guest list"}, func() {
overlay.Popover(c, b, &open, overlay.PopoverOptions{Title: "Guest list"}, func() {
ui.Text(c, "Twelve guests confirmed.")
})
}
+3 -3
View File
@@ -8,9 +8,9 @@
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
b := mujica.Button(c, "Seal", mujica.ButtonOptions{})
mujica.Tooltip(c, b, "Seal the letter with wax", mujica.TooltipOptions{})
core.Use(c, core.Settings{})
b := input.Button(c, "Seal", input.ButtonOptions{})
overlay.Tooltip(c, b, "Seal the letter with wax", overlay.TooltipOptions{})
}
ui.Render(view, 400, 300, 1)
```
+3 -3
View File
@@ -8,9 +8,9 @@
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
b := mujica.Button(c, "Lady Sakiko", mujica.ButtonOptions{Variant: mujica.Ghost})
mujica.HoverCard(c, b, mujica.HoverCardOptions{}, func() {
core.Use(c, core.Settings{})
b := input.Button(c, "Lady Sakiko", input.ButtonOptions{Variant: input.Ghost})
overlay.HoverCard(c, b, overlay.HoverCardOptions{}, func() {
ui.Text(c, "Keyboardist of the court.")
})
}
+7 -7
View File
@@ -9,19 +9,19 @@
```go
pinned := false
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.DropdownMenu(c, "Actions", mujica.DropdownMenuOptions{}, func(m *mujica.PopupMenu) {
core.Use(c, core.Settings{})
overlay.DropdownMenu(c, "Actions", overlay.DropdownMenuOptions{}, func(m *overlay.PopupMenu) {
m.Group("Letter", func() {
if m.Item("Rename", mujica.PopupMenuItemOptions{}) {
if m.Item("Rename", overlay.PopupMenuItemOptions{}) {
fmt.Println("rename")
}
m.Check("Pinned", &pinned, mujica.PopupMenuItemOptions{KeepOpen: true})
m.Check("Pinned", &pinned, overlay.PopupMenuItemOptions{KeepOpen: true})
})
m.Submenu("Move to", mujica.PopupMenuItemOptions{}, func(m *mujica.PopupMenu) {
m.Item("Archive", mujica.PopupMenuItemOptions{})
m.Submenu("Move to", overlay.PopupMenuItemOptions{}, func(m *overlay.PopupMenu) {
m.Item("Archive", overlay.PopupMenuItemOptions{})
})
m.Separator()
m.Item("Burn", mujica.PopupMenuItemOptions{Disabled: true})
m.Item("Burn", overlay.PopupMenuItemOptions{Disabled: true})
})
}
ui.Render(view, 400, 300, 1)
+4 -4
View File
@@ -8,15 +8,15 @@
```go
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
core.Use(c, core.Settings{})
row := ui.Row(c).Padding(12).Children(func() {
ui.Text(c, "Letter to the Countess")
})
mujica.ContextMenu(c, row, mujica.ContextMenuOptions{}, func(m *mujica.PopupMenu) {
if m.Item("Reply", mujica.PopupMenuItemOptions{}) {
overlay.ContextMenu(c, row, overlay.ContextMenuOptions{}, func(m *overlay.PopupMenu) {
if m.Item("Reply", overlay.PopupMenuItemOptions{}) {
fmt.Println("reply")
}
m.Item("Delete", mujica.PopupMenuItemOptions{})
m.Item("Delete", overlay.PopupMenuItemOptions{})
})
}
ui.Render(view, 400, 300, 1)
+3 -3
View File
@@ -9,12 +9,12 @@
```go
open := false
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
b := mujica.Button(c, "Archive", mujica.ButtonOptions{Variant: mujica.Secondary})
core.Use(c, core.Settings{})
b := input.Button(c, "Archive", input.ButtonOptions{Variant: input.Secondary})
if b.Clicked() {
open = true
}
if mujica.Popconfirm(c, b, &open, mujica.PopconfirmOptions{Title: "Archive this letter?"}).Confirmed {
if overlay.Popconfirm(c, b, &open, overlay.PopconfirmOptions{Title: "Archive this letter?"}).Confirmed {
fmt.Println("archived")
}
}
+2 -2
View File
@@ -9,8 +9,8 @@
```go
open := true
view := func(c *ui.Context) {
mujica.Use(c, mujica.Settings{})
mujica.Overlay(c, &open, mujica.OverlayOptions{Place: mujica.OverlayBottomRight, Label: "Now playing"}, func() {
core.Use(c, core.Settings{})
overlay.Overlay(c, &open, overlay.OverlayOptions{Place: overlay.OverlayBottomRight, Label: "Now playing"}, func() {
ui.Text(c, "Symbol I: △")
})
}
+2 -2
View File
@@ -8,8 +8,8 @@
```go
open := true
r := mujica.Alert(c, &open, "The archive could not be read.", mujica.AlertOptions{
Severity: mujica.SeverityError,
r := feedback.Alert(c, &open, "The archive could not be read.", feedback.AlertOptions{
Severity: core.SeverityError,
Title: "Import failed",
Action: "Retry",
})
+3 -3
View File
@@ -7,11 +7,11 @@
## 最小示例
```go
if mujica.Button(c, "Delete note", mujica.ButtonOptions{Variant: mujica.Danger}).Clicked() {
mujica.ShowToast(c, mujica.ToastMessage{ID: "note-1", Message: "Note deleted", Action: "Undo"})
if input.Button(c, "Delete note", input.ButtonOptions{Variant: input.Danger}).Clicked() {
feedback.ShowToast(c, feedback.ToastMessage{ID: "note-1", Message: "Note deleted", Action: "Undo"})
}
// Last in the view:
if r := mujica.Toaster(c); r.Action == "note-1" {
if r := feedback.Toaster(c); r.Action == "note-1" {
// restore the note
}
```
+3 -3
View File
@@ -7,9 +7,9 @@
## 最小示例
```go
mujica.Progress(c, 0.62, mujica.ProgressOptions{Label: "Uploading", ShowValue: true})
mujica.Progress(c, 0, mujica.ProgressOptions{Shape: mujica.ProgressRing, Indeterminate: true, Label: "Connecting"})
mujica.Meter(c, 93, mujica.MeterOptions{
feedback.Progress(c, 0.62, feedback.ProgressOptions{Label: "Uploading", ShowValue: true})
feedback.Progress(c, 0, feedback.ProgressOptions{Shape: feedback.ProgressRing, Indeterminate: true, Label: "Connecting"})
feedback.Meter(c, 93, feedback.MeterOptions{
Max: 100, Label: "Disk", ShowValue: true,
Levels: &ui.MeterLevels{Warning: 70, Critical: 90},
})
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
mujica.Spinner(c, mujica.SpinnerOptions{Size: 20, Label: "Syncing", ShowLabel: true})
core.Spinner(c, core.SpinnerOptions{Size: 20, Label: "Syncing", ShowLabel: true})
```
签名:`func Spinner(c *ui.Context, opts SpinnerOptions) *ui.Element`
+2 -2
View File
@@ -8,9 +8,9 @@
```go
ui.Row(c).Padding(16).Gap(12).Children(func() {
mujica.Skeleton(c, mujica.SkeletonOptions{Shape: mujica.SkeletonCircle})
feedback.Skeleton(c, feedback.SkeletonOptions{Shape: feedback.SkeletonCircle})
ui.Column(c).Grow(1).Children(func() {
mujica.Skeleton(c, mujica.SkeletonOptions{Lines: 2})
feedback.Skeleton(c, feedback.SkeletonOptions{Lines: 2})
})
})
```
+2 -2
View File
@@ -7,8 +7,8 @@
## 最小示例
```go
r := mujica.EmptyState(c, mujica.EmptyStateOptions{
Kind: mujica.EmptyNoResults,
r := feedback.EmptyState(c, feedback.EmptyStateOptions{
Kind: feedback.EmptyNoResults,
Query: query,
Action: "Clear search",
})
+2 -2
View File
@@ -7,8 +7,8 @@
## 最小示例
```go
r := mujica.Result(c, mujica.ResultOptions{
Kind: mujica.ResultForbidden,
r := feedback.Result(c, feedback.ResultOptions{
Kind: feedback.ResultForbidden,
Description: "You need the Editor role to change billing.",
Actions: []string{"Request access", "Go back"},
})
+2 -2
View File
@@ -7,8 +7,8 @@
## 最小示例
```go
mujica.StatusIndicator(c, mujica.StatusSuccess, mujica.StatusIndicatorOptions{Label: "API online"})
mujica.StatusIndicator(c, mujica.StatusOffline, mujica.StatusIndicatorOptions{})
feedback.StatusIndicator(c, feedback.StatusSuccess, feedback.StatusIndicatorOptions{Label: "API online"})
feedback.StatusIndicator(c, feedback.StatusOffline, feedback.StatusIndicatorOptions{})
```
签名:`func StatusIndicator(c *ui.Context, status Status, opts StatusIndicatorOptions) *ui.Element`
+1 -1
View File
@@ -7,7 +7,7 @@
## 最小示例
```go
r := mujica.NotificationCenter(c, &items, mujica.NotificationCenterOptions{})
r := feedback.NotificationCenter(c, &items, feedback.NotificationCenterOptions{})
if r.Action == "a" {
// open the build log
}
+2 -2
View File
@@ -7,9 +7,9 @@
## 最小示例
```go
r := mujica.LoadingOverlay(c, loading, mujica.LoadingOverlayOptions{Cancel: "Cancel"}, func() {
r := feedback.LoadingOverlay(c, loading, feedback.LoadingOverlayOptions{Cancel: "Cancel"}, func() {
ui.Text(c, "Quarterly report")
mujica.Button(c, "Export", mujica.ButtonOptions{})
input.Button(c, "Export", input.ButtonOptions{})
})
if r.Canceled {
loading = false
Loaded 100 of 1822 files, more files were not shown because too many files have changed in this diff. Show more