{-# OPTIONS_GHC -Wno-term-variable-capture #-} module Dashi.Components.Heading where import Clay hiding (FontSize, element, fontSize, size) import Clay qualified import Dashi.Components.Icon () import Dashi.Prelude hiding (element) import Dashi.Style.Tokens hiding (FontSize) import Miso.Html.Element (h1_, h2_, h3_, h4_, h5_) selector :: SizeToken -> Selector selector :: SizeToken -> Selector selector SizeToken XSmall = Selector h5 selector SizeToken Small = Selector h4 selector SizeToken Medium = Selector h3 selector SizeToken Large = Selector h2 selector SizeToken XLarge = Selector h1 element :: SizeToken -> [Attribute action] -> [View model action] -> View model action element :: forall action model. SizeToken -> [Attribute action] -> [View model action] -> View model action element SizeToken XSmall = [Attribute action] -> [View model action] -> View model action forall action model. [Attribute action] -> [View model action] -> View model action h5_ element SizeToken Small = [Attribute action] -> [View model action] -> View model action forall action model. [Attribute action] -> [View model action] -> View model action h4_ element SizeToken Medium = [Attribute action] -> [View model action] -> View model action forall action model. [Attribute action] -> [View model action] -> View model action h3_ element SizeToken Large = [Attribute action] -> [View model action] -> View model action forall action model. [Attribute action] -> [View model action] -> View model action h2_ element SizeToken XLarge = [Attribute action] -> [View model action] -> View model action forall action model. [Attribute action] -> [View model action] -> View model action h1_ newtype FontSize = FontSize SizeToken deriving newtype (FontSize -> FontSize -> Bool (FontSize -> FontSize -> Bool) -> (FontSize -> FontSize -> Bool) -> Eq FontSize forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: FontSize -> FontSize -> Bool == :: FontSize -> FontSize -> Bool $c/= :: FontSize -> FontSize -> Bool /= :: FontSize -> FontSize -> Bool Eq, Eq FontSize Eq FontSize => (FontSize -> FontSize -> Ordering) -> (FontSize -> FontSize -> Bool) -> (FontSize -> FontSize -> Bool) -> (FontSize -> FontSize -> Bool) -> (FontSize -> FontSize -> Bool) -> (FontSize -> FontSize -> FontSize) -> (FontSize -> FontSize -> FontSize) -> Ord FontSize FontSize -> FontSize -> Bool FontSize -> FontSize -> Ordering FontSize -> FontSize -> FontSize forall a. Eq a => (a -> a -> Ordering) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> a) -> (a -> a -> a) -> Ord a $ccompare :: FontSize -> FontSize -> Ordering compare :: FontSize -> FontSize -> Ordering $c< :: FontSize -> FontSize -> Bool < :: FontSize -> FontSize -> Bool $c<= :: FontSize -> FontSize -> Bool <= :: FontSize -> FontSize -> Bool $c> :: FontSize -> FontSize -> Bool > :: FontSize -> FontSize -> Bool $c>= :: FontSize -> FontSize -> Bool >= :: FontSize -> FontSize -> Bool $cmax :: FontSize -> FontSize -> FontSize max :: FontSize -> FontSize -> FontSize $cmin :: FontSize -> FontSize -> FontSize min :: FontSize -> FontSize -> FontSize Ord, FontSize FontSize -> FontSize -> Bounded FontSize forall a. a -> a -> Bounded a $cminBound :: FontSize minBound :: FontSize $cmaxBound :: FontSize maxBound :: FontSize Bounded, Int -> FontSize FontSize -> Int FontSize -> [FontSize] FontSize -> FontSize FontSize -> FontSize -> [FontSize] FontSize -> FontSize -> FontSize -> [FontSize] (FontSize -> FontSize) -> (FontSize -> FontSize) -> (Int -> FontSize) -> (FontSize -> Int) -> (FontSize -> [FontSize]) -> (FontSize -> FontSize -> [FontSize]) -> (FontSize -> FontSize -> [FontSize]) -> (FontSize -> FontSize -> FontSize -> [FontSize]) -> Enum FontSize 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 :: FontSize -> FontSize succ :: FontSize -> FontSize $cpred :: FontSize -> FontSize pred :: FontSize -> FontSize $ctoEnum :: Int -> FontSize toEnum :: Int -> FontSize $cfromEnum :: FontSize -> Int fromEnum :: FontSize -> Int $cenumFrom :: FontSize -> [FontSize] enumFrom :: FontSize -> [FontSize] $cenumFromThen :: FontSize -> FontSize -> [FontSize] enumFromThen :: FontSize -> FontSize -> [FontSize] $cenumFromTo :: FontSize -> FontSize -> [FontSize] enumFromTo :: FontSize -> FontSize -> [FontSize] $cenumFromThenTo :: FontSize -> FontSize -> FontSize -> [FontSize] enumFromThenTo :: FontSize -> FontSize -> FontSize -> [FontSize] Enum) instance Token FontSize where tokenName :: forall s. (IsString s, Semigroup s) => FontSize -> s tokenName (FontSize SizeToken fontSize) = String -> s forall a. IsString a => String -> a fromString (String -> s) -> String -> s forall a b. (a -> b) -> a -> b $ String "heading-" String -> String -> String forall a. Semigroup a => a -> a -> a <> SizeToken -> String forall s. (IsString s, Semigroup s) => SizeToken -> s forall t s. (Token t, IsString s, Semigroup s) => t -> s tokenName SizeToken fontSize String -> String -> String forall a. Semigroup a => a -> a -> a <> String "-font-size" instance ValueToken FontSize where type ValueType FontSize = Size Percentage tokenValue :: FontSize -> ValueType FontSize tokenValue (FontSize SizeToken fontSize) = Number -> Size Percentage pct (Number -> Size Percentage) -> Number -> Size Percentage forall a b. (a -> b) -> a -> b $ case SizeToken fontSize of SizeToken XSmall -> Number 85 SizeToken Small -> Number 100 SizeToken Medium -> Number 125 SizeToken Large -> Number 150 SizeToken XLarge -> Number 200 data Heading = Heading SizeToken MisoString instance Widget Heading model action where widget' :: [Attribute action] -> Heading -> View model action widget' [Attribute action] attrs (Heading SizeToken size MisoString t) = SizeToken -> [Attribute action] -> [View model action] -> View model action forall action model. SizeToken -> [Attribute action] -> [View model action] -> View model action element SizeToken size [Attribute action] attrs [MisoString -> View model action forall model action. MisoString -> View model action text MisoString t] style :: Css style = do NonEmpty Selector -> Selector forall a. Semigroup a => NonEmpty a -> a sconcat (SizeToken -> Selector selector (SizeToken -> Selector) -> NonEmpty SizeToken -> NonEmpty Selector forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> NonEmpty SizeToken forall l. (IsList l, Item l ~ SizeToken) => l forall t l. (Token t, IsList l, Item l ~ t) => l allTokens) Selector -> Css -> Css ? FontWeight -> Css fontWeight (Integer -> FontWeight weight Integer 600) forall (t :: * -> *) (f :: * -> *) a b. (Foldable t, Applicative f) => t a -> (a -> f b) -> f () for_ @[] [SizeToken] forall l. (IsList l, Item l ~ SizeToken) => l forall t l. (Token t, IsList l, Item l ~ t) => l allTokens \SizeToken size -> SizeToken -> Selector selector SizeToken size Selector -> Css -> Css ? Size Percentage -> Css forall a. Size a -> Css Clay.fontSize (FontSize -> ValueType FontSize forall t. ValueToken t => t -> ValueType t tokenValue (FontSize -> ValueType FontSize) -> FontSize -> ValueType FontSize forall a b. (a -> b) -> a -> b $ SizeToken -> FontSize FontSize SizeToken size)