Split into category packages; module github.com/ZacharyZhang-NY/MujicaUI
This commit is contained in:
1822 files changed
+24568
-21314
No files matched your search
@@ -7,11 +7,14 @@ import (
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
mujica "mujicaui"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/core"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/feedback"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/input"
|
||||
"github.com/ZacharyZhang-NY/MujicaUI/navigation"
|
||||
)
|
||||
|
||||
// motionLoaderDemo shows a loader while loading.
|
||||
func motionLoaderDemo(id string, loader func(c *ui.Context, o mujica.LoaderOptions) *ui.Element) func(c *ui.Context, log func(string)) {
|
||||
func motionLoaderDemo(id string, loader func(c *ui.Context, o feedback.LoaderOptions) *ui.Element) func(c *ui.Context, log func(string)) {
|
||||
return func(c *ui.Context, log func(string)) {
|
||||
type state struct {
|
||||
loading, label bool
|
||||
@@ -28,8 +31,8 @@ func motionLoaderDemo(id string, loader func(c *ui.Context, o mujica.LoaderOptio
|
||||
ui.Text(c, "Done.")
|
||||
return
|
||||
}
|
||||
loader(c, mujica.LoaderOptions{Size: float32(s.size), Label: "Thinking", ShowLabel: s.label})
|
||||
loader(c, mujica.LoaderOptions{Size: float32(s.size), Label: "Indexing", Color: mujica.Tokens(c).Info})
|
||||
loader(c, feedback.LoaderOptions{Size: float32(s.size), Label: "Thinking", ShowLabel: s.label})
|
||||
loader(c, feedback.LoaderOptions{Size: float32(s.size), Label: "Indexing", Color: core.Tokens(c).Info})
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -41,11 +44,11 @@ func motionShimmerDemo(c *ui.Context, log func(string)) {
|
||||
navigationDemo(c, func() {
|
||||
navigationCheck(c, &s.loading, "Loading", log)
|
||||
}, func() {
|
||||
mujica.Shimmer(c, s.loading, mujica.ShimmerOptions{Height: 56, Label: "Loading report"}, func() {
|
||||
feedback.Shimmer(c, s.loading, feedback.ShimmerOptions{Height: 56, Label: "Loading report"}, func() {
|
||||
ui.Text(c, "Quarterly report: 12 chapters, 340 pages.")
|
||||
})
|
||||
mujica.Shimmer(c, s.loading, mujica.ShimmerOptions{Width: 240, Height: 20}, func() {
|
||||
ui.Text(c, "Updated today").TextColor(mujica.Tokens(c).TextMuted)
|
||||
feedback.Shimmer(c, s.loading, feedback.ShimmerOptions{Width: 240, Height: 20}, func() {
|
||||
ui.Text(c, "Updated today").TextColor(core.Tokens(c).TextMuted)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -56,17 +59,17 @@ func motionCountUpDemo(c *ui.Context, log func(string)) {
|
||||
navigationDemo(c, func() {
|
||||
navigationSlider(c, &s.duration, "Duration (ms)", 120, 1200, log)
|
||||
navigationSlider(c, &s.decimals, "Decimals", 0, 4, log)
|
||||
if mujica.Button(c, "Add 500", mujica.ButtonOptions{Variant: mujica.Secondary}).Clicked() {
|
||||
if input.Button(c, "Add 500", input.ButtonOptions{Variant: input.Secondary}).Clicked() {
|
||||
s.value += 500
|
||||
log(fmt.Sprintf("Value %.0f", s.value))
|
||||
}
|
||||
if mujica.Button(c, "Random", mujica.ButtonOptions{Variant: mujica.Secondary}).Clicked() {
|
||||
if input.Button(c, "Random", input.ButtonOptions{Variant: input.Secondary}).Clicked() {
|
||||
s.value = float64(rand.Intn(100000))
|
||||
log(fmt.Sprintf("Value %.0f", s.value))
|
||||
}
|
||||
}, func() {
|
||||
mujica.CountUp(c, s.value, mujica.CountUpOptions{Duration: time.Duration(s.duration) * time.Millisecond, Decimals: int(s.decimals)}).FontSize(mujica.FontSize(c, 32))
|
||||
mujica.CountUp(c, s.value/1000, mujica.CountUpOptions{Decimals: 2, Duration: time.Second})
|
||||
feedback.CountUp(c, s.value, feedback.CountUpOptions{Duration: time.Duration(s.duration) * time.Millisecond, Decimals: int(s.decimals)}).FontSize(core.FontSize(c, 32))
|
||||
feedback.CountUp(c, s.value/1000, feedback.CountUpOptions{Decimals: 2, Duration: time.Second})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,18 +82,18 @@ func motionTypewriterDemo(c *ui.Context, log func(string)) {
|
||||
s := ui.Local(c.Root(), "294", func() state { return state{text: "The court assembles at dusk.", speed: 30} })
|
||||
navigationDemo(c, func() {
|
||||
navigationSlider(c, &s.speed, "Speed", 5, 120, log)
|
||||
if mujica.Button(c, "Append", mujica.ButtonOptions{Variant: mujica.Secondary}).Clicked() {
|
||||
if input.Button(c, "Append", input.ButtonOptions{Variant: input.Secondary}).Clicked() {
|
||||
s.text += " The music begins."
|
||||
log("Appended")
|
||||
}
|
||||
if mujica.Button(c, "Restart", mujica.ButtonOptions{Variant: mujica.Secondary}).Clicked() {
|
||||
if input.Button(c, "Restart", input.ButtonOptions{Variant: input.Secondary}).Clicked() {
|
||||
s.text = "A new letter arrives from the duchess."
|
||||
s.round++
|
||||
log("Restarted")
|
||||
}
|
||||
}, func() {
|
||||
ui.Column(c).Key(s.round).Children(func() {
|
||||
if mujica.Typewriter(c, s.text, mujica.TypewriterOptions{Speed: s.speed, Skippable: true}).Changed() {
|
||||
if feedback.Typewriter(c, s.text, feedback.TypewriterOptions{Speed: s.speed, Skippable: true}).Changed() {
|
||||
log("Finished")
|
||||
}
|
||||
})
|
||||
@@ -103,8 +106,8 @@ func motionShimmerTextDemo(c *ui.Context, log func(string)) {
|
||||
navigationDemo(c, func() {
|
||||
navigationCheck(c, &s.active, "Thinking", log)
|
||||
}, func() {
|
||||
mujica.ShimmerText(c, "Thinking about the program…", mujica.ShimmerTextOptions{Active: s.active})
|
||||
mujica.ShimmerText(c, "思考中…", mujica.ShimmerTextOptions{Active: s.active})
|
||||
feedback.ShimmerText(c, "Thinking about the program…", feedback.ShimmerTextOptions{Active: s.active})
|
||||
feedback.ShimmerText(c, "思考中…", feedback.ShimmerTextOptions{Active: s.active})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -119,14 +122,14 @@ func motionStaggerDemo(c *ui.Context, log func(string)) {
|
||||
navigationDemo(c, func() {
|
||||
navigationSlider(c, &s.interval, "Interval (ms)", 20, 300, log)
|
||||
navigationCheck(c, &s.horizontal, "Horizontal", log)
|
||||
if mujica.Button(c, "Replay", mujica.ButtonOptions{Variant: mujica.Secondary}).Clicked() {
|
||||
if input.Button(c, "Replay", input.ButtonOptions{Variant: input.Secondary}).Clicked() {
|
||||
s.round++
|
||||
log(fmt.Sprintf("Replay %d", s.round))
|
||||
}
|
||||
}, func() {
|
||||
ui.Column(c).Key(s.round).Children(func() {
|
||||
mujica.Stagger(c, len(guests), mujica.StaggerOptions{Interval: time.Duration(s.interval) * time.Millisecond, Horizontal: s.horizontal}, func(i int) {
|
||||
ui.Text(c, guests[i]+" arrives").Padding(6, 10).Background(mujica.Tokens(c).Surface).Radius(4).Margin(0, 0, 4, 0)
|
||||
feedback.Stagger(c, len(guests), feedback.StaggerOptions{Interval: time.Duration(s.interval) * time.Millisecond, Horizontal: s.horizontal}, func(i int) {
|
||||
ui.Text(c, guests[i]+" arrives").Padding(6, 10).Background(core.Tokens(c).Surface).Radius(4).Margin(0, 0, 4, 0)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -140,13 +143,13 @@ func motionReorderDemo(c *ui.Context, log func(string)) {
|
||||
s := ui.Local(c.Root(), "297", func() state { return state{order: []string{"Overture", "Masquerade", "Interlude", "Finale"}, gap: 4} })
|
||||
navigationDemo(c, func() {
|
||||
navigationSlider(c, &s.gap, "Gap", 0, 24, log)
|
||||
if mujica.Button(c, "Shuffle", mujica.ButtonOptions{Variant: mujica.Secondary}).Clicked() {
|
||||
if input.Button(c, "Shuffle", input.ButtonOptions{Variant: input.Secondary}).Clicked() {
|
||||
next := append([]string(nil), s.order...)
|
||||
rand.Shuffle(len(next), func(i, j int) { next[i], next[j] = next[j], next[i] })
|
||||
s.order = next
|
||||
log(fmt.Sprintf("Order %v", s.order))
|
||||
}
|
||||
if mujica.Button(c, "Reverse", mujica.ButtonOptions{Variant: mujica.Secondary}).Clicked() {
|
||||
if input.Button(c, "Reverse", input.ButtonOptions{Variant: input.Secondary}).Clicked() {
|
||||
next := make([]string, len(s.order))
|
||||
for i, v := range s.order {
|
||||
next[len(next)-1-i] = v
|
||||
@@ -156,8 +159,8 @@ func motionReorderDemo(c *ui.Context, log func(string)) {
|
||||
}
|
||||
}, func() {
|
||||
ui.Column(c).Width(280).Children(func() {
|
||||
mujica.ReorderTransition(c, s.order, mujica.ReorderTransitionOptions{Gap: float32(s.gap)}, func(name string) {
|
||||
ui.Text(c, name).Padding(8, 12).Background(mujica.Tokens(c).Surface).Radius(4)
|
||||
feedback.ReorderTransition(c, s.order, feedback.ReorderTransitionOptions{Gap: float32(s.gap)}, func(name string) {
|
||||
ui.Text(c, name).Padding(8, 12).Background(core.Tokens(c).Surface).Radius(4)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -171,8 +174,8 @@ func motionLayoutDemo(c *ui.Context, log func(string)) {
|
||||
navigationCheck(c, &s.clip, "Clip", log)
|
||||
}, func() {
|
||||
ui.Column(c).AlignItems(ui.Start).Children(func() {
|
||||
mujica.LayoutTransition(c, mujica.LayoutTransitionOptions{Clip: s.clip}, func() {
|
||||
ui.Column(c).Padding(12).Gap(6).Background(mujica.Tokens(c).Surface).Radius(4).Children(func() {
|
||||
feedback.LayoutTransition(c, feedback.LayoutTransitionOptions{Clip: s.clip}, func() {
|
||||
ui.Column(c).Padding(12).Gap(6).Background(core.Tokens(c).Surface).Radius(4).Children(func() {
|
||||
ui.Text(c, "Program").FontWeight(600)
|
||||
if s.open {
|
||||
for _, p := range []string{"Overture", "Masquerade", "Interlude", "Finale"} {
|
||||
@@ -193,15 +196,15 @@ func motionPresenceDemo(c *ui.Context, log func(string)) {
|
||||
s := ui.Local(c.Root(), "299", func() state { return state{show: true} })
|
||||
navigationDemo(c, func() {
|
||||
navigationCheck(c, &s.show, "Show", log)
|
||||
if mujica.SegmentedControl(c, &s.kind, []mujica.Segment{{Label: "Fade"}, {Label: "Slide"}, {Label: "Collapse"}}, mujica.SegmentedControlOptions{Label: "Kind"}).Changed() {
|
||||
if navigation.SegmentedControl(c, &s.kind, []navigation.Segment{{Label: "Fade"}, {Label: "Slide"}, {Label: "Collapse"}}, navigation.SegmentedControlOptions{Label: "Kind"}).Changed() {
|
||||
log(fmt.Sprintf("Kind %d", s.kind))
|
||||
}
|
||||
}, func() {
|
||||
ui.Column(c).Width(320).Children(func() {
|
||||
mujica.Presence(c, s.show, mujica.PresenceOptions{Kind: mujica.PresenceKind(s.kind)}, func() {
|
||||
ui.Text(c, "Your changes were saved.").Padding(10, 12).Background(mujica.Tokens(c).Surface).Radius(4)
|
||||
feedback.Presence(c, s.show, feedback.PresenceOptions{Kind: feedback.PresenceKind(s.kind)}, func() {
|
||||
ui.Text(c, "Your changes were saved.").Padding(10, 12).Background(core.Tokens(c).Surface).Radius(4)
|
||||
})
|
||||
ui.Text(c, "Content below moves with it.").TextColor(mujica.Tokens(c).TextMuted).Padding(8, 0)
|
||||
ui.Text(c, "Content below moves with it.").TextColor(core.Tokens(c).TextMuted).Padding(8, 0)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -210,11 +213,11 @@ func motionBlinkDemo(c *ui.Context, log func(string)) {
|
||||
type state struct{ price float64 }
|
||||
s := ui.Local(c.Root(), "300", func() state { return state{price: 101.5} })
|
||||
navigationDemo(c, func() {
|
||||
if mujica.Button(c, "Tick", mujica.ButtonOptions{Variant: mujica.Secondary}).Clicked() {
|
||||
if input.Button(c, "Tick", input.ButtonOptions{Variant: input.Secondary}).Clicked() {
|
||||
s.price += float64(rand.Intn(200)-100) / 50
|
||||
log(fmt.Sprintf("Price %.2f", s.price))
|
||||
}
|
||||
}, func() {
|
||||
mujica.BlinkHighlight(c, s.price, mujica.BlinkHighlightOptions{})
|
||||
feedback.BlinkHighlight(c, s.price, feedback.BlinkHighlightOptions{})
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user