Refactor: share iconAction for borderless 16 DIP icon buttons
datetimeIconButton moves to icon_button.go as iconAction(c, icon, label) and replaces the identical copies in Dialog close, PasswordInput toggle and AppShell collapse. Hover and press now set Text on every caller, including the date and time pickers, which kept TextMuted on hover. Image retry (bordered, danger ink), TagsInput remove (14 DIP icon, no press state) and Tag close (12 DIP icon, fade) are different buttons and stay as they are.
This commit is contained in:
9 files changed
+36
-67
No files matched your search
@@ -2,6 +2,9 @@ package mujica
|
||||
|
||||
import (
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"mujicaui/internal"
|
||||
"mujicaui/theme"
|
||||
)
|
||||
|
||||
// IconButtonOptions configure an IconButton.
|
||||
@@ -31,3 +34,18 @@ func IconButton(c *ui.Context, icon *ui.SVG, label string, opts IconButtonOption
|
||||
}
|
||||
return b.Tooltip(tip)
|
||||
}
|
||||
|
||||
// iconAction is a square, borderless button showing icon, named label.
|
||||
func iconAction(c *ui.Context, icon *ui.SVG, label string) *ui.Element {
|
||||
k := Tokens(c)
|
||||
b := ui.ButtonBase(c).Size(theme.MinHitSize, theme.MinHitSize).Radius(theme.ControlRadius).Label(label).TextColor(k.TextMuted)
|
||||
internal.Ring(b, k.Focus, theme.ControlRadius)
|
||||
switch {
|
||||
case b.Pressed():
|
||||
b.Background(k.Selection).TextColor(k.Text)
|
||||
case b.Hovered():
|
||||
b.Background(k.SurfaceHover).TextColor(k.Text)
|
||||
}
|
||||
b.Children(func() { ui.Icon(c, icon).Size(16, 16) })
|
||||
return b
|
||||
}
|
||||
Reference in new issue
Block a user