From 9a0ee5fc55f2e5de5b949955d09080c05a229493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8jberg?= Date: Wed, 18 Dec 2024 13:31:56 -0500 Subject: [PATCH] ActionMenu: customizable icon button color --- src/UI/ActionMenu.elm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/UI/ActionMenu.elm b/src/UI/ActionMenu.elm index 62f912c..d910be1 100644 --- a/src/UI/ActionMenu.elm +++ b/src/UI/ActionMenu.elm @@ -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 } @@ -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 @@ -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 } @@ -207,6 +207,13 @@ withButtonColor color actionMenu_ = in { actionMenu_ | trigger = bt } + IconButtonTrigger i -> + let + ibt = + IconButtonTrigger { i | color = color } + in + { actionMenu_ | trigger = ibt } + _ -> actionMenu_ @@ -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