@@ -16,7 +16,7 @@ module Lumi.Components2.Button
1616 , varButtonHueDisabled , varButtonGrey1 , varButtonGrey2
1717 , varButtonBlack , varButtonWhite
1818
19- , submit , reset , onPress , onPress'
19+ , submit , reset , state , onPress , onPress'
2020 , autoFocus , tabIndex , ariaLabel
2121 ) where
2222
@@ -31,7 +31,6 @@ import Effect.Class (liftEffect)
3131import Effect.Unsafe (unsafePerformEffect )
3232import Foreign.Object (fromHomogeneous )
3333import Lumi.Components (LumiComponent , PropsModifier , lumiComponent , propsModifier , unsafeMaybeToNullableAttr )
34- import Lumi.Components.Button (invisibleSpace )
3534import Lumi.Components.Color (ColorMap , shade )
3635import Lumi.Components.Size (Size (..))
3736import Lumi.Components2.Box as Box
@@ -523,15 +522,29 @@ varButtonWhite = var "--button-white"
523522-- | rather than providing an `onPress` action to the button
524523-- | itself.
525524submit :: forall c . ButtonState -> ButtonModifier c
526- submit state = propsModifier _ { type = Submit , state = state }
525+ submit s = propsModifier _ { type = Submit , state = s }
527526
528527-- | A form reset button. This helper takes the button state
529528-- | as an argument because a form's buttons are generally
530529-- | tied to the validity and `onSubmit` behavior of the form,
531530-- | rather than providing an `onPress` action to the button
532531-- | itself.
533532reset :: forall c . ButtonState -> ButtonModifier c
534- reset state = propsModifier _ { type = Reset , state = state }
533+ reset s = propsModifier _ { type = Reset , state = s }
534+
535+ -- | Set the button state. Generally you'll want to use `submit` or
536+ -- | `reset` instead, but this can still be useful for `onPress`
537+ -- | buttons which need to be disabled while some page state is
538+ -- | invalid or share in a collective page loading state.
539+ -- |
540+ -- | Note: When a page is in a loading state, any buttons which
541+ -- | were _not_ interacted with should be set to `Disabled`, not
542+ -- | `Loading`. A row of buttons containing the same spinner
543+ -- | looks strange. You also do not need to track which button
544+ -- | was interacted with, usually, because the `onPress` loading
545+ -- | state will override this one within the button pressed.
546+ state :: forall c . ButtonState -> ButtonModifier c
547+ state s = propsModifier _ { state = s }
535548
536549-- | A button with customized `onPress` behavior. The button will
537550-- | automatically display a loading state while the action is in-progress.
@@ -558,3 +571,8 @@ tabIndex i = propsModifier _ { tabIndex = Just i }
558571-- | label to "Close".
559572ariaLabel :: forall c . String -> ButtonModifier c
560573ariaLabel l = propsModifier _ { ariaLabel = Just l }
574+
575+ -- --------------------------
576+
577+ invisibleSpace :: String
578+ invisibleSpace = " \x2063 "
0 commit comments