Skip to content

Commit

Permalink
ActionMenu: customizable icon button color
Browse files Browse the repository at this point in the history
  • Loading branch information
hojberg committed Dec 18, 2024
1 parent 351182d commit 9a0ee5f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/UI/ActionMenu.elm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type ActionItems msg

type ActionMenuTrigger msg
= ButtonTrigger { icon : Maybe (Icon msg), label : String, color : Button.Color }
| IconButtonTrigger (Icon msg)
| IconButtonTrigger { icon : Icon msg, color : Button.Color }
| CustomTrigger { toHtml : Bool -> Html msg }


Expand Down Expand Up @@ -107,7 +107,7 @@ fromIconButton : msg -> Icon msg -> ActionItems msg -> ActionMenu msg
fromIconButton toggleMsg icon actionItems =
{ toggleMsg = toggleMsg
, state = Closed
, trigger = IconButtonTrigger icon
, trigger = IconButtonTrigger { icon = icon, color = Button.Default }
, actionItems = actionItems
, nudge = NoNudge
, maxWidth = Nothing
Expand Down Expand Up @@ -186,10 +186,10 @@ withButtonIcon icon actionMenu_ =
in
{ actionMenu_ | trigger = bt }

IconButtonTrigger _ ->
IconButtonTrigger i ->
let
ibt =
IconButtonTrigger icon
IconButtonTrigger { i | icon = icon }
in
{ actionMenu_ | trigger = ibt }

Expand All @@ -207,6 +207,13 @@ withButtonColor color actionMenu_ =
in
{ actionMenu_ | trigger = bt }

IconButtonTrigger i ->
let
ibt =
IconButtonTrigger { i | color = color }
in
{ actionMenu_ | trigger = ibt }

_ ->
actionMenu_

Expand Down Expand Up @@ -368,11 +375,12 @@ view { toggleMsg, nudge, state, trigger, actionItems, maxWidth } =
else
Button.view b_

IconButtonTrigger icon ->
IconButtonTrigger { icon, color } ->
let
b_ =
Button.icon toggleMsg icon
|> Button.withIconAfterLabel (caret state)
|> Button.withColor color
|> Button.small
in
if isOpen then
Expand Down

0 comments on commit 9a0ee5f

Please sign in to comment.