{-# LANGUAGE OverloadedLists #-} {-# OPTIONS_GHC -Wno-missing-role-annotations #-} module Dashi.Components.Button where import Clay hiding ( Background , Color , action , fullWidth , label , size , span_ , var ) import Clay qualified hiding (Color, fullWidth) import Dashi.Components.Icon () import Dashi.Components.Spinner (Spinner (Spinner)) import Dashi.Components.Util import Dashi.Prelude hiding (none, transform, (#), (&)) import Dashi.Style.Border (BorderColour (BorderColour)) import Dashi.Style.Colour (LightDark (..), sameLightDark) import Dashi.Style.Pseudo (pressable) import Dashi.Style.Root (tokenDecl) import Dashi.Style.Text ( TextColour (TextColour) ) import Dashi.Style.Tokens import Dashi.Style.Uchu (Uchu (..), UchuAlpha (..)) import Dashi.Style.Uchu qualified as Uchu import Dashi.Style.Util import Data.List qualified as List import Data.Vector.Strict qualified as Vector import GHC.IsList (IsList (fromList)) import Miso.Html.Element (button_, label_) import Miso.Html.Event qualified as Html newtype Foreground = Foreground Appearance deriving newtype (Foreground Foreground -> Foreground -> Bounded Foreground forall a. a -> a -> Bounded a $cminBound :: Foreground minBound :: Foreground $cmaxBound :: Foreground maxBound :: Foreground Bounded, Int -> Foreground Foreground -> Int Foreground -> [Foreground] Foreground -> Foreground Foreground -> Foreground -> [Foreground] Foreground -> Foreground -> Foreground -> [Foreground] (Foreground -> Foreground) -> (Foreground -> Foreground) -> (Int -> Foreground) -> (Foreground -> Int) -> (Foreground -> [Foreground]) -> (Foreground -> Foreground -> [Foreground]) -> (Foreground -> Foreground -> [Foreground]) -> (Foreground -> Foreground -> Foreground -> [Foreground]) -> Enum Foreground forall a. (a -> a) -> (a -> a) -> (Int -> a) -> (a -> Int) -> (a -> [a]) -> (a -> a -> [a]) -> (a -> a -> [a]) -> (a -> a -> a -> [a]) -> Enum a $csucc :: Foreground -> Foreground succ :: Foreground -> Foreground $cpred :: Foreground -> Foreground pred :: Foreground -> Foreground $ctoEnum :: Int -> Foreground toEnum :: Int -> Foreground $cfromEnum :: Foreground -> Int fromEnum :: Foreground -> Int $cenumFrom :: Foreground -> [Foreground] enumFrom :: Foreground -> [Foreground] $cenumFromThen :: Foreground -> Foreground -> [Foreground] enumFromThen :: Foreground -> Foreground -> [Foreground] $cenumFromTo :: Foreground -> Foreground -> [Foreground] enumFromTo :: Foreground -> Foreground -> [Foreground] $cenumFromThenTo :: Foreground -> Foreground -> Foreground -> [Foreground] enumFromThenTo :: Foreground -> Foreground -> Foreground -> [Foreground] Enum, Foreground -> Foreground -> Bool (Foreground -> Foreground -> Bool) -> (Foreground -> Foreground -> Bool) -> Eq Foreground forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Foreground -> Foreground -> Bool == :: Foreground -> Foreground -> Bool $c/= :: Foreground -> Foreground -> Bool /= :: Foreground -> Foreground -> Bool Eq) instance Token Foreground where tokenName :: forall s. (IsString s, Semigroup s) => Foreground -> s tokenName (Foreground Appearance appearance) = [Char] -> s forall a. IsString a => [Char] -> a fromString ([Char] -> s) -> ([Maybe [Char]] -> [Char]) -> [Maybe [Char]] -> s forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . [Char] -> [[Char]] -> [Char] forall a. [a] -> [[a]] -> [a] List.intercalate [Char] "-" ([[Char]] -> [Char]) -> ([Maybe [Char]] -> [[Char]]) -> [Maybe [Char]] -> [Char] forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . [Maybe [Char]] -> [[Char]] forall a. [Maybe a] -> [a] catMaybes ([Maybe [Char]] -> s) -> [Maybe [Char]] -> s forall a b. (a -> b) -> a -> b $ [[Char] -> Maybe [Char] forall a. a -> Maybe a Just [Char] "button-foreground", Appearance -> Maybe [Char] forall t s. (Token t, Eq t, IsString s, Semigroup s) => t -> Maybe s nonDefaultTokenName Appearance appearance] instance ValueToken Foreground where type ValueType Foreground = LightDark (UchuAlpha Micro) tokenValue :: Foreground -> ValueType Foreground tokenValue (Foreground Appearance Default) = TextColour -> ValueType TextColour forall t. ValueToken t => t -> ValueType t tokenValue (TextColour -> ValueType TextColour) -> TextColour -> ValueType TextColour forall a b. (a -> b) -> a -> b $ Appearance -> TextColour TextColour Appearance Default tokenValue (Foreground Appearance Subtle) = TextColour -> ValueType TextColour forall t. ValueToken t => t -> ValueType t tokenValue (TextColour -> ValueType TextColour) -> TextColour -> ValueType TextColour forall a b. (a -> b) -> a -> b $ Appearance -> TextColour TextColour Appearance Subtle tokenValue (Foreground Appearance _) = (Uchu -> Micro -> UchuAlpha Micro) -> Micro -> Uchu -> UchuAlpha Micro forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Micro -> UchuAlpha Micro forall a. Uchu -> a -> UchuAlpha a UchuAlpha Micro 1 (Uchu -> UchuAlpha Micro) -> LightDark Uchu -> LightDark (UchuAlpha Micro) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Yang data Background = Background Appearance InputState deriving stock (Background -> Background -> Bool (Background -> Background -> Bool) -> (Background -> Background -> Bool) -> Eq Background forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Background -> Background -> Bool == :: Background -> Background -> Bool $c/= :: Background -> Background -> Bool /= :: Background -> Background -> Bool Eq) allBackgrounds :: Vector Background allBackgrounds :: Vector Background allBackgrounds = Appearance -> InputState -> Background Background (Appearance -> InputState -> Background) -> Vector Appearance -> Vector (InputState -> Background) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [Item (Vector Appearance) Appearance forall a. Bounded a => a minBound .. Item (Vector Appearance) Appearance forall a. Bounded a => a maxBound] Vector (InputState -> Background) -> Vector InputState -> Vector Background forall a b. Vector (a -> b) -> Vector a -> Vector b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> [Item (Vector InputState) InputState forall a. Bounded a => a minBound .. Item (Vector InputState) InputState forall a. Bounded a => a maxBound] instance Enum Background where toEnum :: Int -> Background toEnum = Vector Background -> Int -> Background forall a. Vector a -> Int -> a (Vector.!) Vector Background allBackgrounds fromEnum :: Background -> Int fromEnum = Maybe Int -> Int forall a. HasCallStack => Maybe a -> a fromJust (Maybe Int -> Int) -> (Background -> Maybe Int) -> Background -> Int forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . ((Background -> Bool) -> Vector Background -> Maybe Int) -> Vector Background -> (Background -> Bool) -> Maybe Int forall a b c. (a -> b -> c) -> b -> a -> c flip (Background -> Bool) -> Vector Background -> Maybe Int forall a. (a -> Bool) -> Vector a -> Maybe Int Vector.findIndex Vector Background allBackgrounds ((Background -> Bool) -> Maybe Int) -> (Background -> Background -> Bool) -> Background -> Maybe Int forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . Background -> Background -> Bool forall a. Eq a => a -> a -> Bool (==) instance Bounded Background where minBound :: Background minBound = Int -> Background forall a. Enum a => Int -> a toEnum Int 0 maxBound :: Background maxBound = Int -> Background forall a. Enum a => Int -> a toEnum (Int -> Background) -> (Int -> Int) -> Int -> Background forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . Int -> Int forall a. Enum a => a -> a pred (Int -> Background) -> Int -> Background forall a b. (a -> b) -> a -> b $ Vector Background -> Int forall a. Vector a -> Int Vector.length Vector Background allBackgrounds instance Token Background where tokenName :: forall s. (IsString s, Semigroup s) => Background -> s tokenName (Background Appearance appearance InputState state) = [Char] -> s forall a. IsString a => [Char] -> a fromString ([Char] -> s) -> ([Maybe [Char]] -> [Char]) -> [Maybe [Char]] -> s forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . [Char] -> [[Char]] -> [Char] forall a. [a] -> [[a]] -> [a] List.intercalate [Char] "-" ([[Char]] -> [Char]) -> ([Maybe [Char]] -> [[Char]]) -> [Maybe [Char]] -> [Char] forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . [Maybe [Char]] -> [[Char]] forall a. [Maybe a] -> [a] catMaybes ([Maybe [Char]] -> s) -> [Maybe [Char]] -> s forall a b. (a -> b) -> a -> b $ [ [Char] -> Maybe [Char] forall a. a -> Maybe a Just [Char] "button-background" , Appearance -> Maybe [Char] forall t s. (Token t, Eq t, IsString s, Semigroup s) => t -> Maybe s nonDefaultTokenName Appearance appearance , InputState -> Maybe [Char] forall t s. (Token t, Eq t, IsString s, Semigroup s) => t -> Maybe s nonDefaultTokenName InputState state ] instance ValueToken Background where type ValueType Background = LightDark (UchuAlpha Milli) tokenValue :: Background -> ValueType Background tokenValue (Background Appearance Default InputState state) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli alpha (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> Uchu -> LightDark Uchu forall c. c -> c -> LightDark c LightDark Uchu Yin2 Uchu Yin8 where alpha :: Milli alpha = Milli 0.25 Milli -> Milli -> Milli forall a. Num a => a -> a -> a * (Int -> Milli forall a b. (Integral a, Num b) => a -> b fromIntegral (Int -> Milli) -> (InputState -> Int) -> InputState -> Milli forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . Int -> Int forall a. Enum a => a -> a succ (Int -> Int) -> (InputState -> Int) -> InputState -> Int forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . InputState -> Int forall a. Enum a => a -> Int fromEnum) InputState state tokenValue (Background Appearance Subtle InputState DefaultState) = Milli -> UchuAlpha Milli -> UchuAlpha Milli forall a. a -> UchuAlpha a -> UchuAlpha a Uchu.setAlpha Milli 0 (UchuAlpha Milli -> UchuAlpha Milli) -> LightDark (UchuAlpha Milli) -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Background -> ValueType Background forall t. ValueToken t => t -> ValueType t tokenValue (Appearance -> InputState -> Background Background Appearance Default InputState DefaultState) tokenValue (Background Appearance Subtle InputState state) = Background -> ValueType Background forall t. ValueToken t => t -> ValueType t tokenValue (Background -> ValueType Background) -> Background -> ValueType Background forall a b. (a -> b) -> a -> b $ Appearance -> InputState -> Background Background Appearance Default InputState state tokenValue (Background Appearance Primary InputState DefaultState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Blue4 tokenValue (Background Appearance Primary InputState HoveredState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Blue5 tokenValue (Background Appearance Primary InputState ActiveState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Blue6 tokenValue (Background Appearance Success InputState DefaultState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Green5 tokenValue (Background Appearance Success InputState HoveredState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Green6 tokenValue (Background Appearance Success InputState ActiveState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Green7 tokenValue (Background Appearance Warning InputState DefaultState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Orange5 tokenValue (Background Appearance Warning InputState HoveredState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Orange6 tokenValue (Background Appearance Warning InputState ActiveState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Orange7 tokenValue (Background Appearance Danger InputState DefaultState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Red4 tokenValue (Background Appearance Danger InputState HoveredState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Red5 tokenValue (Background Appearance Danger InputState ActiveState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Red6 tokenValue (Background Appearance Discovery InputState DefaultState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Purple4 tokenValue (Background Appearance Discovery InputState HoveredState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Purple5 tokenValue (Background Appearance Discovery InputState ActiveState) = (Uchu -> Milli -> UchuAlpha Milli) -> Milli -> Uchu -> UchuAlpha Milli forall a b c. (a -> b -> c) -> b -> a -> c flip Uchu -> Milli -> UchuAlpha Milli forall a. Uchu -> a -> UchuAlpha a UchuAlpha Milli 1 (Uchu -> UchuAlpha Milli) -> LightDark Uchu -> LightDark (UchuAlpha Milli) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Uchu -> LightDark Uchu forall c. c -> LightDark c sameLightDark Uchu Purple6 data ButtonSize = DefaultSize | IconButton | CompactButton | FullWidthButton deriving stock (ButtonSize -> ButtonSize -> Bool (ButtonSize -> ButtonSize -> Bool) -> (ButtonSize -> ButtonSize -> Bool) -> Eq ButtonSize forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: ButtonSize -> ButtonSize -> Bool == :: ButtonSize -> ButtonSize -> Bool $c/= :: ButtonSize -> ButtonSize -> Bool /= :: ButtonSize -> ButtonSize -> Bool Eq, ButtonSize ButtonSize -> ButtonSize -> Bounded ButtonSize forall a. a -> a -> Bounded a $cminBound :: ButtonSize minBound :: ButtonSize $cmaxBound :: ButtonSize maxBound :: ButtonSize Bounded, Int -> ButtonSize ButtonSize -> Int ButtonSize -> [ButtonSize] ButtonSize -> ButtonSize ButtonSize -> ButtonSize -> [ButtonSize] ButtonSize -> ButtonSize -> ButtonSize -> [ButtonSize] (ButtonSize -> ButtonSize) -> (ButtonSize -> ButtonSize) -> (Int -> ButtonSize) -> (ButtonSize -> Int) -> (ButtonSize -> [ButtonSize]) -> (ButtonSize -> ButtonSize -> [ButtonSize]) -> (ButtonSize -> ButtonSize -> [ButtonSize]) -> (ButtonSize -> ButtonSize -> ButtonSize -> [ButtonSize]) -> Enum ButtonSize forall a. (a -> a) -> (a -> a) -> (Int -> a) -> (a -> Int) -> (a -> [a]) -> (a -> a -> [a]) -> (a -> a -> [a]) -> (a -> a -> a -> [a]) -> Enum a $csucc :: ButtonSize -> ButtonSize succ :: ButtonSize -> ButtonSize $cpred :: ButtonSize -> ButtonSize pred :: ButtonSize -> ButtonSize $ctoEnum :: Int -> ButtonSize toEnum :: Int -> ButtonSize $cfromEnum :: ButtonSize -> Int fromEnum :: ButtonSize -> Int $cenumFrom :: ButtonSize -> [ButtonSize] enumFrom :: ButtonSize -> [ButtonSize] $cenumFromThen :: ButtonSize -> ButtonSize -> [ButtonSize] enumFromThen :: ButtonSize -> ButtonSize -> [ButtonSize] $cenumFromTo :: ButtonSize -> ButtonSize -> [ButtonSize] enumFromTo :: ButtonSize -> ButtonSize -> [ButtonSize] $cenumFromThenTo :: ButtonSize -> ButtonSize -> ButtonSize -> [ButtonSize] enumFromThenTo :: ButtonSize -> ButtonSize -> ButtonSize -> [ButtonSize] Enum) instance Token ButtonSize where tokenName :: forall s. (IsString s, Semigroup s) => ButtonSize -> s tokenName ButtonSize DefaultSize = s "default" tokenName ButtonSize IconButton = s "icon" tokenName ButtonSize CompactButton = s "compact" tokenName ButtonSize FullWidthButton = s "full-width" defaultToken :: Maybe ButtonSize defaultToken = ButtonSize -> Maybe ButtonSize forall a. a -> Maybe a Just ButtonSize DefaultSize data Button model action = Button { forall model action. Button model action -> ButtonSize size :: ButtonSize , forall model action. Button model action -> Appearance appearance :: Appearance , forall model action. Button model action -> [View model action] label :: [View model action] , forall model action. Button model action -> Maybe action onClick :: Maybe action } appearanceStyle :: Appearance -> Css appearanceStyle :: Appearance -> Css appearanceStyle Appearance appearance = do Bool -> Css -> Css forall (f :: * -> *). Applicative f => Bool -> f () -> f () when (Appearance appearance Appearance -> Appearance -> Bool forall a. Eq a => a -> a -> Bool == Appearance Subtle) (Css -> Css) -> Css -> Css forall a b. (a -> b) -> a -> b $ Key Text "box-shadow" Key Text -> Text -> Css -: Text "none" Foreground -> Css forall t. Token t => t -> Css color' (Foreground -> Css) -> Foreground -> Css forall a b. (a -> b) -> a -> b $ Appearance -> Foreground Foreground Appearance appearance Background -> Css forall t. Token t => t -> Css backgroundColor' (Background -> Css) -> Background -> Css forall a b. (a -> b) -> a -> b $ Appearance -> InputState -> Background Background Appearance appearance InputState DefaultState NonEmpty Refinement -> Refinement forall a. Semigroup a => NonEmpty a -> a sconcat [Bool -> Refinement ariaBusy Bool False, Refinement -> Refinement forall a. Not a => a -> Refinement Clay.not Refinement disabled] Refinement -> Css -> Css & do Refinement hover Refinement -> Css -> Css & Background -> Css forall t. Token t => t -> Css backgroundColor' (Appearance -> InputState -> Background Background Appearance appearance InputState HoveredState) Refinement active Refinement -> Css -> Css & Background -> Css forall t. Token t => t -> Css backgroundColor' (Appearance -> InputState -> Background Background Appearance appearance InputState ActiveState) sizeStyle :: ButtonSize -> Css sizeStyle :: ButtonSize -> Css sizeStyle ButtonSize DefaultSize = () -> Css forall a. a -> StyleM a forall (f :: * -> *) a. Applicative f => a -> f a pure () sizeStyle ButtonSize IconButton = do SizeToken -> Css paddingAll' SizeToken XSmall Selector forall a. IsString a => a Clay.label Selector -> Css -> Css ? Selector forall a. IsString a => a Clay.span Selector -> Refinement -> Selector # Refinement ".icon" Selector -> Css -> Css ? Transformation -> Css transform Transformation forall a. None a => a none sizeStyle ButtonSize CompactButton = do Size LengthUnit -> Size LengthUnit -> Css forall a. Size a -> Size a -> Css paddingYX (Number -> Size LengthUnit em Number 0.125) (Space -> ValueType Space forall t. (Token t, Val (ValueType t), Other (ValueType t)) => t -> ValueType t token (Space -> ValueType Space) -> Space -> ValueType Space forall a b. (a -> b) -> a -> b $ SizeToken -> Space Space SizeToken Medium) Selector forall a. IsString a => a Clay.span Selector -> Css -> Css ? Transformation -> Css transform (Size LengthUnit -> Transformation translateY Size LengthUnit forall a. Size a nil) sizeStyle ButtonSize FullWidthButton = do Css fullWidth Selector forall a. IsString a => a Clay.label Selector -> Css -> Css ? do Css fullWidth JustifyContentValue -> Css justifyContent JustifyContentValue forall a. SpaceEvenly a => a spaceEvenly instance Widget (Button model action) model action where widget' :: [Attribute action] -> Button model action -> View model action widget' [Attribute action] attrs Button{[View model action] Maybe action Appearance ButtonSize size :: forall model action. Button model action -> ButtonSize appearance :: forall model action. Button model action -> Appearance label :: forall model action. Button model action -> [View model action] onClick :: forall model action. Button model action -> Maybe action size :: ButtonSize appearance :: Appearance label :: [View model action] onClick :: Maybe action ..} = [Attribute action] -> [View model action] -> View model action forall action model. [Attribute action] -> [View model action] -> View model action button_ ( ButtonSize -> Attribute action forall t action. Token t => t -> Attribute action forall action. ButtonSize -> Attribute action tokenAttr ButtonSize size Attribute action -> [Attribute action] -> [Attribute action] forall a. a -> [a] -> [a] : Appearance -> Attribute action forall action. Appearance -> Attribute action forall t action. Token t => t -> Attribute action tokenAttr Appearance appearance Attribute action -> [Attribute action] -> [Attribute action] forall a. a -> [a] -> [a] : [Attribute action] attrs [Attribute action] -> [Attribute action] -> [Attribute action] forall a. Semigroup a => a -> a -> a <> [Attribute action forall action. Attribute action unselectable_ | Bool isBusy] [Attribute action] -> [Attribute action] -> [Attribute action] forall a. Semigroup a => a -> a -> a <> Maybe (Attribute action) -> [Attribute action] forall a. Maybe a -> [a] maybeToList (action -> Attribute action forall action. action -> Attribute action Html.onClickPrevent (action -> Attribute action) -> Maybe action -> Maybe (Attribute action) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Maybe action onClick) ) ([View model action] -> View model action) -> [View model action] -> View model action forall a b. (a -> b) -> a -> b $ [Attribute action] -> [View model action] -> View model action forall action model. [Attribute action] -> [View model action] -> View model action label_ [] [View model action] label View model action -> [View model action] -> [View model action] forall a. a -> [a] -> [a] : [Spinner -> View model action forall w model action. Widget w model action => w -> View model action widget Spinner Spinner | Bool isBusy] where isBusy :: Bool isBusy = [Attribute action] -> Bool forall action. [Attribute action] -> Bool hasAriaBusy [Attribute action] attrs style :: Css style = do Selector ":root" Selector -> Css -> Css ? do forall t. (ValueToken t, Val (ValueType t)) => Css tokenDecl @Foreground forall t. (ValueToken t, Val (ValueType t)) => Css tokenDecl @Background NonEmpty Selector -> Selector forall a. Semigroup a => NonEmpty a -> a sconcat [Item (NonEmpty Selector) Selector Clay.button, Selector input Selector -> Refinement -> Selector # (Text "type" Text -> Text -> Refinement @= Text "submit"), Item (NonEmpty Selector) Selector ".button"] Selector -> Css -> Css ? do Css pressable UserSelect -> Css userSelect UserSelect forall a. None a => a none Position -> Css position Position relative NonEmpty BoxShadow -> Css boxShadow (NonEmpty BoxShadow -> Css) -> ([BoxShadow] -> NonEmpty BoxShadow) -> [BoxShadow] -> Css forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . [Item (NonEmpty BoxShadow)] -> NonEmpty BoxShadow [BoxShadow] -> NonEmpty BoxShadow forall l. IsList l => [Item l] -> l fromList ([BoxShadow] -> Css) -> [BoxShadow] -> Css forall a b. (a -> b) -> a -> b $ [ BoxShadow -> Item [BoxShadow] BoxShadow -> BoxShadow bsInset (BoxShadow -> Item [BoxShadow]) -> (Size (ZonkAny 0) -> BoxShadow) -> Size (ZonkAny 0) -> Item [BoxShadow] forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . Color -> BoxShadow -> BoxShadow bsColor (BorderColour -> Color forall t. Token t => t -> Color colorToken BorderColour BorderColour) (BoxShadow -> BoxShadow) -> (Size (ZonkAny 0) -> BoxShadow) -> Size (ZonkAny 0) -> BoxShadow forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . Size (ZonkAny 0) -> Size (ZonkAny 0) -> Size (ZonkAny 0) -> BoxShadow forall a. Size a -> Size a -> Size a -> BoxShadow shadowWithBlur Size (ZonkAny 0) forall a. Size a nil Size (ZonkAny 0) forall a. Size a nil (Size (ZonkAny 0) -> Item [BoxShadow]) -> Size (ZonkAny 0) -> Item [BoxShadow] forall a b. (a -> b) -> a -> b $ Text -> [Size (ZonkAny 0)] -> Size (ZonkAny 0) forall v. (Val v, Other v) => Text -> [v] -> v var Text "border-width" [] ] TextColour -> Css forall t. Token t => t -> Css color' (TextColour -> Css) -> TextColour -> Css forall a b. (a -> b) -> a -> b $ Appearance -> TextColour TextColour Appearance Subtle SizeToken -> Css borderRadiusAll' SizeToken Small SizeToken -> SizeToken -> Css paddingYX' SizeToken XSmall SizeToken Medium FontWeight -> Css fontWeight (FontWeight -> Css) -> FontWeight -> Css forall a b. (a -> b) -> a -> b $ Integer -> FontWeight weight Integer 550 Background -> Css forall t. Token t => t -> Css backgroundColor' (Background -> Css) -> Background -> Css forall a b. (a -> b) -> a -> b $ Appearance -> InputState -> Background Background Appearance Default InputState DefaultState Text -> Time -> TimingFunction -> Time -> Css transition Text "background" (Double -> Time sec Double 0.15) TimingFunction easeOut Time 0 Selector forall a. IsString a => a Clay.label Selector -> Css -> Css ? do Display -> Css display Display inlineFlex AlignItemsValue -> Css alignItems AlignItemsValue forall a. Baseline a => a baseline JustifyContentValue -> Css justifyContent JustifyContentValue forall a. Center a => a center TextAlign -> Css textAlign TextAlign forall a. Center a => a center SizeToken -> Css gap' SizeToken XSmall Size (ZonkAny 1) -> Css forall a. Size a -> Css lineHeight (Size (ZonkAny 1) -> Css) -> Size (ZonkAny 1) -> Css forall a b. (a -> b) -> a -> b $ Number -> Size (ZonkAny 1) forall a. Number -> Size a unitless Number 1.6 PointerEvents -> Css Clay.pointerEvents PointerEvents forall a. None a => a none Selector forall a. IsString a => a Clay.span Selector -> Refinement -> Selector # Refinement ":not(.icon)" Selector -> Css -> Css ? Transformation -> Css transform (Size LengthUnit -> Transformation translateY (Size LengthUnit -> Transformation) -> (Number -> Size LengthUnit) -> Number -> Transformation forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . Number -> Size LengthUnit em (Number -> Transformation) -> Number -> Transformation forall a b. (a -> b) -> a -> b $ -Number 0.1) Selector forall a. IsString a => a Clay.span Selector -> Refinement -> Selector # Refinement ".icon" Selector -> Css -> Css ? Transformation -> Css transform (Size LengthUnit -> Transformation translateY (Size LengthUnit -> Transformation) -> (Number -> Size LengthUnit) -> Number -> Transformation forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . Number -> Size LengthUnit em (Number -> Transformation) -> Number -> Transformation forall a b. (a -> b) -> a -> b $ Number 0.05) Selector ".icon" Selector -> Css -> Css ? SizeToken -> Css fontSize' SizeToken Large Selector ".spinner" Selector -> Css -> Css ? do Number -> Css opacity Number 1 Position -> Css position Position absolute Size Percentage -> Css forall a. Size a -> Css left (Size Percentage -> Css) -> Size Percentage -> Css forall a b. (a -> b) -> a -> b $ Number -> Size Percentage pct Number 50 Key Text "transform" Key Text -> Text -> Css -: Text "translateX(-50%)" Size LengthUnit -> Css forall a. Size a -> Css top (Size LengthUnit -> Css) -> (Space -> Size LengthUnit) -> Space -> Css forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . Space -> Size LengthUnit Space -> ValueType Space forall t. (Token t, Val (ValueType t), Other (ValueType t)) => t -> ValueType t token (Space -> Css) -> Space -> Css forall a b. (a -> b) -> a -> b $ SizeToken -> Space Space SizeToken XSmall Display -> Css display Display inlineBlock Size LengthUnit -> Css forall a. Size a -> Css width (Size LengthUnit -> Css) -> Size LengthUnit -> Css forall a b. (a -> b) -> a -> b $ Number -> Size LengthUnit em Number 1.4 Size LengthUnit -> Css forall a. Size a -> Css height (Size LengthUnit -> Css) -> Size LengthUnit -> Css forall a b. (a -> b) -> a -> b $ Number -> Size LengthUnit em Number 1.4 Bool -> Refinement ariaBusy Bool True Refinement -> Css -> Css & Selector forall a. IsString a => a Clay.label Selector -> Css -> Css ? Number -> Css opacity Number 0 (ButtonSize -> Css) -> Css forall t. Token t => (t -> Css) -> Css byTokens ButtonSize -> Css sizeStyle (Appearance -> Css) -> Css forall t. Token t => (t -> Css) -> Css byTokens Appearance -> Css appearanceStyle