{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}

module Web.View.Types where

import Data.Kind (Type)
import Data.Map (Map)
import Data.String (IsString (..))
import Data.Text (Text, pack, unpack)
import Data.Text qualified as T
import GHC.Generics (Generic)
import Numeric (showFFloat)
import Text.Casing (kebab)


data Content
  = Node Element
  | Text Text
  | -- | Raw embedded HTML or SVG. See 'Web.View.Element.raw'
    Raw Text
  deriving (Int -> Content -> ShowS
[Content] -> ShowS
Content -> String
(Int -> Content -> ShowS)
-> (Content -> String) -> ([Content] -> ShowS) -> Show Content
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Content -> ShowS
showsPrec :: Int -> Content -> ShowS
$cshow :: Content -> String
show :: Content -> String
$cshowList :: [Content] -> ShowS
showList :: [Content] -> ShowS
Show, Content -> Content -> Bool
(Content -> Content -> Bool)
-> (Content -> Content -> Bool) -> Eq Content
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Content -> Content -> Bool
== :: Content -> Content -> Bool
$c/= :: Content -> Content -> Bool
/= :: Content -> Content -> Bool
Eq)


-- | A single HTML tag. Note that the class attribute is stored separately from the rest of the attributes to make adding styles easier
data Element = Element
  { Element -> Bool
inline :: Bool
  , Element -> Text
name :: Name
  , Element -> Attributes ()
attributes :: Attributes ()
  , Element -> [Content]
children :: [Content]
  }
  deriving (Int -> Element -> ShowS
[Element] -> ShowS
Element -> String
(Int -> Element -> ShowS)
-> (Element -> String) -> ([Element] -> ShowS) -> Show Element
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Element -> ShowS
showsPrec :: Int -> Element -> ShowS
$cshow :: Element -> String
show :: Element -> String
$cshowList :: [Element] -> ShowS
showList :: [Element] -> ShowS
Show, Element -> Element -> Bool
(Element -> Element -> Bool)
-> (Element -> Element -> Bool) -> Eq Element
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Element -> Element -> Bool
== :: Element -> Element -> Bool
$c/= :: Element -> Element -> Bool
/= :: Element -> Element -> Bool
Eq)


-- | Construct an Element
element :: Name -> Attributes c -> [Content] -> Element
element :: forall {k} (c :: k). Text -> Attributes c -> [Content] -> Element
element Text
n Attributes c
atts =
  Bool -> Text -> Attributes () -> [Content] -> Element
Element Bool
False Text
n (Attributes c -> Attributes ()
forall {k} (c :: k). Attributes c -> Attributes ()
stripContext Attributes c
atts)
 where
  stripContext :: Attributes c -> Attributes ()
  stripContext :: forall {k} (c :: k). Attributes c -> Attributes ()
stripContext (Attributes [Class]
cls Map Text Text
other) = [Class] -> Map Text Text -> Attributes ()
forall {k} (c :: k). [Class] -> Map Text Text -> Attributes c
Attributes [Class]
cls Map Text Text
other


-- | The Attributes for an 'Element'. Classes are merged and managed separately from the other attributes.
data Attributes c = Attributes
  { forall {k} (c :: k). Attributes c -> [Class]
classes :: [Class]
  , forall {k} (c :: k). Attributes c -> Map Text Text
other :: Map Name AttValue
  }
  deriving (Int -> Attributes c -> ShowS
[Attributes c] -> ShowS
Attributes c -> String
(Int -> Attributes c -> ShowS)
-> (Attributes c -> String)
-> ([Attributes c] -> ShowS)
-> Show (Attributes c)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (c :: k). Int -> Attributes c -> ShowS
forall k (c :: k). [Attributes c] -> ShowS
forall k (c :: k). Attributes c -> String
$cshowsPrec :: forall k (c :: k). Int -> Attributes c -> ShowS
showsPrec :: Int -> Attributes c -> ShowS
$cshow :: forall k (c :: k). Attributes c -> String
show :: Attributes c -> String
$cshowList :: forall k (c :: k). [Attributes c] -> ShowS
showList :: [Attributes c] -> ShowS
Show, Attributes c -> Attributes c -> Bool
(Attributes c -> Attributes c -> Bool)
-> (Attributes c -> Attributes c -> Bool) -> Eq (Attributes c)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k (c :: k). Attributes c -> Attributes c -> Bool
$c== :: forall k (c :: k). Attributes c -> Attributes c -> Bool
== :: Attributes c -> Attributes c -> Bool
$c/= :: forall k (c :: k). Attributes c -> Attributes c -> Bool
/= :: Attributes c -> Attributes c -> Bool
Eq)


instance Semigroup (Attributes c) where
  Attributes c
a1 <> :: Attributes c -> Attributes c -> Attributes c
<> Attributes c
a2 = [Class] -> Map Text Text -> Attributes c
forall {k} (c :: k). [Class] -> Map Text Text -> Attributes c
Attributes (Attributes c
a1.classes [Class] -> [Class] -> [Class]
forall a. Semigroup a => a -> a -> a
<> Attributes c
a2.classes) (Attributes c
a1.other Map Text Text -> Map Text Text -> Map Text Text
forall a. Semigroup a => a -> a -> a
<> Attributes c
a2.other)
instance Monoid (Attributes c) where
  mempty :: Attributes c
mempty = [Class] -> Map Text Text -> Attributes c
forall {k} (c :: k). [Class] -> Map Text Text -> Attributes c
Attributes [] Map Text Text
forall a. Monoid a => a
mempty
type Attribute = (Name, AttValue)
type Name = Text
type AttValue = Text


-- * Attribute Modifiers


{- | Element functions expect a modifier function as their first argument. These can add attributes and classes. Combine multiple `Mod`s with (`.`)

> userEmail :: User -> View c ()
> userEmail user = input (fontSize 16 . active) (text user.email)
>   where
>     active = isActive user then bold else id

If you don't want to specify any attributes, you can use `id`

> plainView :: View c ()
> plainView = el id "No styles"
-}
type Mod (context :: Type) = Attributes context -> Attributes context


-- * Atomic CSS


-- TODO: document atomic CSS here?

-- | All the atomic classes used in a 'Web.View.View'
type CSS = [Class]


-- | Atomic classes include a selector and the corresponding styles
data Class = Class
  { Class -> Selector
selector :: Selector
  , Class -> Styles
properties :: Styles
  }
  deriving (Int -> Class -> ShowS
[Class] -> ShowS
Class -> String
(Int -> Class -> ShowS)
-> (Class -> String) -> ([Class] -> ShowS) -> Show Class
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Class -> ShowS
showsPrec :: Int -> Class -> ShowS
$cshow :: Class -> String
show :: Class -> String
$cshowList :: [Class] -> ShowS
showList :: [Class] -> ShowS
Show, Class -> Class -> Bool
(Class -> Class -> Bool) -> (Class -> Class -> Bool) -> Eq Class
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Class -> Class -> Bool
== :: Class -> Class -> Bool
$c/= :: Class -> Class -> Bool
/= :: Class -> Class -> Bool
Eq)


-- | The styles to apply for a given atomic 'Class'
type Styles = Map Name StyleValue


-- | A parent selector limits the selector to only apply when a descendent of the parent in question
type Ancestor = Text


-- | A child selector limits
data ChildCombinator
  = AllChildren
  | ChildWithName Text
  deriving (Int -> ChildCombinator -> ShowS
[ChildCombinator] -> ShowS
ChildCombinator -> String
(Int -> ChildCombinator -> ShowS)
-> (ChildCombinator -> String)
-> ([ChildCombinator] -> ShowS)
-> Show ChildCombinator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChildCombinator -> ShowS
showsPrec :: Int -> ChildCombinator -> ShowS
$cshow :: ChildCombinator -> String
show :: ChildCombinator -> String
$cshowList :: [ChildCombinator] -> ShowS
showList :: [ChildCombinator] -> ShowS
Show, ChildCombinator -> ChildCombinator -> Bool
(ChildCombinator -> ChildCombinator -> Bool)
-> (ChildCombinator -> ChildCombinator -> Bool)
-> Eq ChildCombinator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChildCombinator -> ChildCombinator -> Bool
== :: ChildCombinator -> ChildCombinator -> Bool
$c/= :: ChildCombinator -> ChildCombinator -> Bool
/= :: ChildCombinator -> ChildCombinator -> Bool
Eq, Eq ChildCombinator
Eq ChildCombinator =>
(ChildCombinator -> ChildCombinator -> Ordering)
-> (ChildCombinator -> ChildCombinator -> Bool)
-> (ChildCombinator -> ChildCombinator -> Bool)
-> (ChildCombinator -> ChildCombinator -> Bool)
-> (ChildCombinator -> ChildCombinator -> Bool)
-> (ChildCombinator -> ChildCombinator -> ChildCombinator)
-> (ChildCombinator -> ChildCombinator -> ChildCombinator)
-> Ord ChildCombinator
ChildCombinator -> ChildCombinator -> Bool
ChildCombinator -> ChildCombinator -> Ordering
ChildCombinator -> ChildCombinator -> ChildCombinator
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 :: ChildCombinator -> ChildCombinator -> Ordering
compare :: ChildCombinator -> ChildCombinator -> Ordering
$c< :: ChildCombinator -> ChildCombinator -> Bool
< :: ChildCombinator -> ChildCombinator -> Bool
$c<= :: ChildCombinator -> ChildCombinator -> Bool
<= :: ChildCombinator -> ChildCombinator -> Bool
$c> :: ChildCombinator -> ChildCombinator -> Bool
> :: ChildCombinator -> ChildCombinator -> Bool
$c>= :: ChildCombinator -> ChildCombinator -> Bool
>= :: ChildCombinator -> ChildCombinator -> Bool
$cmax :: ChildCombinator -> ChildCombinator -> ChildCombinator
max :: ChildCombinator -> ChildCombinator -> ChildCombinator
$cmin :: ChildCombinator -> ChildCombinator -> ChildCombinator
min :: ChildCombinator -> ChildCombinator -> ChildCombinator
Ord)


instance IsString ChildCombinator where
  fromString :: String -> ChildCombinator
fromString String
s = Text -> ChildCombinator
ChildWithName (String -> Text
forall a. IsString a => String -> a
fromString String
s)


-- | The selector to use for the given atomic 'Class'
data Selector = Selector
  { Selector -> Maybe Media
media :: Maybe Media
  , Selector -> Maybe Text
ancestor :: Maybe Ancestor
  , Selector -> Maybe ChildCombinator
child :: Maybe ChildCombinator
  , Selector -> Maybe Pseudo
pseudo :: Maybe Pseudo
  , Selector -> ClassName
className :: ClassName
  }
  deriving (Selector -> Selector -> Bool
(Selector -> Selector -> Bool)
-> (Selector -> Selector -> Bool) -> Eq Selector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Selector -> Selector -> Bool
== :: Selector -> Selector -> Bool
$c/= :: Selector -> Selector -> Bool
/= :: Selector -> Selector -> Bool
Eq, Eq Selector
Eq Selector =>
(Selector -> Selector -> Ordering)
-> (Selector -> Selector -> Bool)
-> (Selector -> Selector -> Bool)
-> (Selector -> Selector -> Bool)
-> (Selector -> Selector -> Bool)
-> (Selector -> Selector -> Selector)
-> (Selector -> Selector -> Selector)
-> Ord Selector
Selector -> Selector -> Bool
Selector -> Selector -> Ordering
Selector -> Selector -> Selector
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 :: Selector -> Selector -> Ordering
compare :: Selector -> Selector -> Ordering
$c< :: Selector -> Selector -> Bool
< :: Selector -> Selector -> Bool
$c<= :: Selector -> Selector -> Bool
<= :: Selector -> Selector -> Bool
$c> :: Selector -> Selector -> Bool
> :: Selector -> Selector -> Bool
$c>= :: Selector -> Selector -> Bool
>= :: Selector -> Selector -> Bool
$cmax :: Selector -> Selector -> Selector
max :: Selector -> Selector -> Selector
$cmin :: Selector -> Selector -> Selector
min :: Selector -> Selector -> Selector
Ord, Int -> Selector -> ShowS
[Selector] -> ShowS
Selector -> String
(Int -> Selector -> ShowS)
-> (Selector -> String) -> ([Selector] -> ShowS) -> Show Selector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Selector -> ShowS
showsPrec :: Int -> Selector -> ShowS
$cshow :: Selector -> String
show :: Selector -> String
$cshowList :: [Selector] -> ShowS
showList :: [Selector] -> ShowS
Show)


instance IsString Selector where
  fromString :: String -> Selector
fromString String
s = ClassName -> Selector
selector (String -> ClassName
forall a. IsString a => String -> a
fromString String
s)


-- | Create a 'Selector' given only a 'ClassName'
selector :: ClassName -> Selector
selector :: ClassName -> Selector
selector ClassName
c =
  Selector
    { $sel:pseudo:Selector :: Maybe Pseudo
pseudo = Maybe Pseudo
forall a. Maybe a
Nothing
    , $sel:ancestor:Selector :: Maybe Text
ancestor = Maybe Text
forall a. Maybe a
Nothing
    , $sel:child:Selector :: Maybe ChildCombinator
child = Maybe ChildCombinator
forall a. Maybe a
Nothing
    , $sel:media:Selector :: Maybe Media
media = Maybe Media
forall a. Maybe a
Nothing
    , $sel:className:Selector :: ClassName
className = ClassName
c
    }


-- | A class name
newtype ClassName = ClassName
  { ClassName -> Text
text :: Text
  }
  deriving newtype (ClassName -> ClassName -> Bool
(ClassName -> ClassName -> Bool)
-> (ClassName -> ClassName -> Bool) -> Eq ClassName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClassName -> ClassName -> Bool
== :: ClassName -> ClassName -> Bool
$c/= :: ClassName -> ClassName -> Bool
/= :: ClassName -> ClassName -> Bool
Eq, Eq ClassName
Eq ClassName =>
(ClassName -> ClassName -> Ordering)
-> (ClassName -> ClassName -> Bool)
-> (ClassName -> ClassName -> Bool)
-> (ClassName -> ClassName -> Bool)
-> (ClassName -> ClassName -> Bool)
-> (ClassName -> ClassName -> ClassName)
-> (ClassName -> ClassName -> ClassName)
-> Ord ClassName
ClassName -> ClassName -> Bool
ClassName -> ClassName -> Ordering
ClassName -> ClassName -> ClassName
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 :: ClassName -> ClassName -> Ordering
compare :: ClassName -> ClassName -> Ordering
$c< :: ClassName -> ClassName -> Bool
< :: ClassName -> ClassName -> Bool
$c<= :: ClassName -> ClassName -> Bool
<= :: ClassName -> ClassName -> Bool
$c> :: ClassName -> ClassName -> Bool
> :: ClassName -> ClassName -> Bool
$c>= :: ClassName -> ClassName -> Bool
>= :: ClassName -> ClassName -> Bool
$cmax :: ClassName -> ClassName -> ClassName
max :: ClassName -> ClassName -> ClassName
$cmin :: ClassName -> ClassName -> ClassName
min :: ClassName -> ClassName -> ClassName
Ord, Int -> ClassName -> ShowS
[ClassName] -> ShowS
ClassName -> String
(Int -> ClassName -> ShowS)
-> (ClassName -> String)
-> ([ClassName] -> ShowS)
-> Show ClassName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClassName -> ShowS
showsPrec :: Int -> ClassName -> ShowS
$cshow :: ClassName -> String
show :: ClassName -> String
$cshowList :: [ClassName] -> ShowS
showList :: [ClassName] -> ShowS
Show, Semigroup ClassName
ClassName
Semigroup ClassName =>
ClassName
-> (ClassName -> ClassName -> ClassName)
-> ([ClassName] -> ClassName)
-> Monoid ClassName
[ClassName] -> ClassName
ClassName -> ClassName -> ClassName
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: ClassName
mempty :: ClassName
$cmappend :: ClassName -> ClassName -> ClassName
mappend :: ClassName -> ClassName -> ClassName
$cmconcat :: [ClassName] -> ClassName
mconcat :: [ClassName] -> ClassName
Monoid, NonEmpty ClassName -> ClassName
ClassName -> ClassName -> ClassName
(ClassName -> ClassName -> ClassName)
-> (NonEmpty ClassName -> ClassName)
-> (forall b. Integral b => b -> ClassName -> ClassName)
-> Semigroup ClassName
forall b. Integral b => b -> ClassName -> ClassName
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: ClassName -> ClassName -> ClassName
<> :: ClassName -> ClassName -> ClassName
$csconcat :: NonEmpty ClassName -> ClassName
sconcat :: NonEmpty ClassName -> ClassName
$cstimes :: forall b. Integral b => b -> ClassName -> ClassName
stimes :: forall b. Integral b => b -> ClassName -> ClassName
Semigroup)


instance IsString ClassName where
  fromString :: String -> ClassName
fromString String
s = Text -> ClassName
ClassName (Text -> ClassName) -> Text -> ClassName
forall a b. (a -> b) -> a -> b
$ String -> Text
pack String
s


-- | Create a class name, escaping special characters
className :: Text -> ClassName
className :: Text -> ClassName
className = Text -> ClassName
ClassName (Text -> ClassName) -> (Text -> Text) -> Text -> ClassName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
T.toLower (Text -> Text) -> (Text -> Text) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Char) -> Text -> Text
T.map Char -> Char
noDot
 where
  noDot :: Char -> Char
noDot Char
'.' = Char
'-'
  noDot Char
c = Char
c


-- | Convert a type into a className segment to generate unique compound style names based on the value
class ToClassName a where
  toClassName :: a -> ClassName
  default toClassName :: (Show a) => a -> ClassName
  toClassName = Text -> ClassName
className (Text -> ClassName) -> (a -> Text) -> a -> ClassName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Text) -> (a -> String) -> a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> String
forall a. Show a => a -> String
show


instance ToClassName Int
instance ToClassName Text where
  toClassName :: Text -> ClassName
toClassName = Text -> ClassName
className
instance ToClassName Float where
  toClassName :: Float -> ClassName
toClassName Float
f = Text -> ClassName
className (Text -> ClassName) -> Text -> ClassName
forall a b. (a -> b) -> a -> b
$ String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Maybe Int -> Float -> ShowS
forall a. RealFloat a => Maybe Int -> a -> ShowS
showFFloat (Int -> Maybe Int
forall a. a -> Maybe a
Just Int
3) Float
f String
""


{- | Psuedos allow for specifying styles that only apply in certain conditions. See `Web.View.Style.hover` etc

> el (color Primary . hover (color White)) "hello"
-}
data Pseudo
  = Hover
  | Active
  | Even
  | Odd
  deriving (Int -> Pseudo -> ShowS
[Pseudo] -> ShowS
Pseudo -> String
(Int -> Pseudo -> ShowS)
-> (Pseudo -> String) -> ([Pseudo] -> ShowS) -> Show Pseudo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Pseudo -> ShowS
showsPrec :: Int -> Pseudo -> ShowS
$cshow :: Pseudo -> String
show :: Pseudo -> String
$cshowList :: [Pseudo] -> ShowS
showList :: [Pseudo] -> ShowS
Show, Pseudo -> Pseudo -> Bool
(Pseudo -> Pseudo -> Bool)
-> (Pseudo -> Pseudo -> Bool) -> Eq Pseudo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Pseudo -> Pseudo -> Bool
== :: Pseudo -> Pseudo -> Bool
$c/= :: Pseudo -> Pseudo -> Bool
/= :: Pseudo -> Pseudo -> Bool
Eq, Eq Pseudo
Eq Pseudo =>
(Pseudo -> Pseudo -> Ordering)
-> (Pseudo -> Pseudo -> Bool)
-> (Pseudo -> Pseudo -> Bool)
-> (Pseudo -> Pseudo -> Bool)
-> (Pseudo -> Pseudo -> Bool)
-> (Pseudo -> Pseudo -> Pseudo)
-> (Pseudo -> Pseudo -> Pseudo)
-> Ord Pseudo
Pseudo -> Pseudo -> Bool
Pseudo -> Pseudo -> Ordering
Pseudo -> Pseudo -> Pseudo
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 :: Pseudo -> Pseudo -> Ordering
compare :: Pseudo -> Pseudo -> Ordering
$c< :: Pseudo -> Pseudo -> Bool
< :: Pseudo -> Pseudo -> Bool
$c<= :: Pseudo -> Pseudo -> Bool
<= :: Pseudo -> Pseudo -> Bool
$c> :: Pseudo -> Pseudo -> Bool
> :: Pseudo -> Pseudo -> Bool
$c>= :: Pseudo -> Pseudo -> Bool
>= :: Pseudo -> Pseudo -> Bool
$cmax :: Pseudo -> Pseudo -> Pseudo
max :: Pseudo -> Pseudo -> Pseudo
$cmin :: Pseudo -> Pseudo -> Pseudo
min :: Pseudo -> Pseudo -> Pseudo
Ord)


-- | The value of a css style property
newtype StyleValue = StyleValue String
  deriving newtype (String -> StyleValue
(String -> StyleValue) -> IsString StyleValue
forall a. (String -> a) -> IsString a
$cfromString :: String -> StyleValue
fromString :: String -> StyleValue
IsString, Int -> StyleValue -> ShowS
[StyleValue] -> ShowS
StyleValue -> String
(Int -> StyleValue -> ShowS)
-> (StyleValue -> String)
-> ([StyleValue] -> ShowS)
-> Show StyleValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StyleValue -> ShowS
showsPrec :: Int -> StyleValue -> ShowS
$cshow :: StyleValue -> String
show :: StyleValue -> String
$cshowList :: [StyleValue] -> ShowS
showList :: [StyleValue] -> ShowS
Show, StyleValue -> StyleValue -> Bool
(StyleValue -> StyleValue -> Bool)
-> (StyleValue -> StyleValue -> Bool) -> Eq StyleValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StyleValue -> StyleValue -> Bool
== :: StyleValue -> StyleValue -> Bool
$c/= :: StyleValue -> StyleValue -> Bool
/= :: StyleValue -> StyleValue -> Bool
Eq)


-- | Use a type as a css style property value
class ToStyleValue a where
  toStyleValue :: a -> StyleValue
  default toStyleValue :: (Show a) => a -> StyleValue
  toStyleValue = String -> StyleValue
StyleValue (String -> StyleValue) -> (a -> String) -> a -> StyleValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
kebab ShowS -> (a -> String) -> a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> String
forall a. Show a => a -> String
show


instance ToStyleValue String where
  toStyleValue :: String -> StyleValue
toStyleValue = String -> StyleValue
StyleValue


instance ToStyleValue Text where
  toStyleValue :: Text -> StyleValue
toStyleValue = String -> StyleValue
StyleValue (String -> StyleValue) -> (Text -> String) -> Text -> StyleValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
unpack


instance ToStyleValue Int


instance ToStyleValue Float where
  -- this does not convert to a percent, just a ratio
  toStyleValue :: Float -> StyleValue
toStyleValue Float
n = String -> StyleValue
StyleValue (String -> StyleValue) -> String -> StyleValue
forall a b. (a -> b) -> a -> b
$ Maybe Int -> Float -> ShowS
forall a. RealFloat a => Maybe Int -> a -> ShowS
showFFloat (Int -> Maybe Int
forall a. a -> Maybe a
Just Int
2) Float
n String
""


data Length
  = PxRem PxRem
  | Pct Float
  deriving (Int -> Length -> ShowS
[Length] -> ShowS
Length -> String
(Int -> Length -> ShowS)
-> (Length -> String) -> ([Length] -> ShowS) -> Show Length
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Length -> ShowS
showsPrec :: Int -> Length -> ShowS
$cshow :: Length -> String
show :: Length -> String
$cshowList :: [Length] -> ShowS
showList :: [Length] -> ShowS
Show)


instance ToClassName Length where
  toClassName :: Length -> ClassName
toClassName (PxRem PxRem
p) = PxRem -> ClassName
forall a. ToClassName a => a -> ClassName
toClassName PxRem
p
  toClassName (Pct Float
p) = Float -> ClassName
forall a. ToClassName a => a -> ClassName
toClassName Float
p


-- | Px, converted to Rem. Allows for the user to change the document font size and have the app scale accordingly. But allows the programmer to code in pixels to match a design
newtype PxRem = PxRem' Int
  deriving newtype (Int -> PxRem -> ShowS
[PxRem] -> ShowS
PxRem -> String
(Int -> PxRem -> ShowS)
-> (PxRem -> String) -> ([PxRem] -> ShowS) -> Show PxRem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PxRem -> ShowS
showsPrec :: Int -> PxRem -> ShowS
$cshow :: PxRem -> String
show :: PxRem -> String
$cshowList :: [PxRem] -> ShowS
showList :: [PxRem] -> ShowS
Show, PxRem -> ClassName
(PxRem -> ClassName) -> ToClassName PxRem
forall a. (a -> ClassName) -> ToClassName a
$ctoClassName :: PxRem -> ClassName
toClassName :: PxRem -> ClassName
ToClassName, Integer -> PxRem
PxRem -> PxRem
PxRem -> PxRem -> PxRem
(PxRem -> PxRem -> PxRem)
-> (PxRem -> PxRem -> PxRem)
-> (PxRem -> PxRem -> PxRem)
-> (PxRem -> PxRem)
-> (PxRem -> PxRem)
-> (PxRem -> PxRem)
-> (Integer -> PxRem)
-> Num PxRem
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: PxRem -> PxRem -> PxRem
+ :: PxRem -> PxRem -> PxRem
$c- :: PxRem -> PxRem -> PxRem
- :: PxRem -> PxRem -> PxRem
$c* :: PxRem -> PxRem -> PxRem
* :: PxRem -> PxRem -> PxRem
$cnegate :: PxRem -> PxRem
negate :: PxRem -> PxRem
$cabs :: PxRem -> PxRem
abs :: PxRem -> PxRem
$csignum :: PxRem -> PxRem
signum :: PxRem -> PxRem
$cfromInteger :: Integer -> PxRem
fromInteger :: Integer -> PxRem
Num, PxRem -> PxRem -> Bool
(PxRem -> PxRem -> Bool) -> (PxRem -> PxRem -> Bool) -> Eq PxRem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PxRem -> PxRem -> Bool
== :: PxRem -> PxRem -> Bool
$c/= :: PxRem -> PxRem -> Bool
/= :: PxRem -> PxRem -> Bool
Eq, Enum PxRem
Real PxRem
(Real PxRem, Enum PxRem) =>
(PxRem -> PxRem -> PxRem)
-> (PxRem -> PxRem -> PxRem)
-> (PxRem -> PxRem -> PxRem)
-> (PxRem -> PxRem -> PxRem)
-> (PxRem -> PxRem -> (PxRem, PxRem))
-> (PxRem -> PxRem -> (PxRem, PxRem))
-> (PxRem -> Integer)
-> Integral PxRem
PxRem -> Integer
PxRem -> PxRem -> (PxRem, PxRem)
PxRem -> PxRem -> PxRem
forall a.
(Real a, Enum a) =>
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
$cquot :: PxRem -> PxRem -> PxRem
quot :: PxRem -> PxRem -> PxRem
$crem :: PxRem -> PxRem -> PxRem
rem :: PxRem -> PxRem -> PxRem
$cdiv :: PxRem -> PxRem -> PxRem
div :: PxRem -> PxRem -> PxRem
$cmod :: PxRem -> PxRem -> PxRem
mod :: PxRem -> PxRem -> PxRem
$cquotRem :: PxRem -> PxRem -> (PxRem, PxRem)
quotRem :: PxRem -> PxRem -> (PxRem, PxRem)
$cdivMod :: PxRem -> PxRem -> (PxRem, PxRem)
divMod :: PxRem -> PxRem -> (PxRem, PxRem)
$ctoInteger :: PxRem -> Integer
toInteger :: PxRem -> Integer
Integral, Num PxRem
Ord PxRem
(Num PxRem, Ord PxRem) => (PxRem -> Rational) -> Real PxRem
PxRem -> Rational
forall a. (Num a, Ord a) => (a -> Rational) -> Real a
$ctoRational :: PxRem -> Rational
toRational :: PxRem -> Rational
Real, Eq PxRem
Eq PxRem =>
(PxRem -> PxRem -> Ordering)
-> (PxRem -> PxRem -> Bool)
-> (PxRem -> PxRem -> Bool)
-> (PxRem -> PxRem -> Bool)
-> (PxRem -> PxRem -> Bool)
-> (PxRem -> PxRem -> PxRem)
-> (PxRem -> PxRem -> PxRem)
-> Ord PxRem
PxRem -> PxRem -> Bool
PxRem -> PxRem -> Ordering
PxRem -> PxRem -> PxRem
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 :: PxRem -> PxRem -> Ordering
compare :: PxRem -> PxRem -> Ordering
$c< :: PxRem -> PxRem -> Bool
< :: PxRem -> PxRem -> Bool
$c<= :: PxRem -> PxRem -> Bool
<= :: PxRem -> PxRem -> Bool
$c> :: PxRem -> PxRem -> Bool
> :: PxRem -> PxRem -> Bool
$c>= :: PxRem -> PxRem -> Bool
>= :: PxRem -> PxRem -> Bool
$cmax :: PxRem -> PxRem -> PxRem
max :: PxRem -> PxRem -> PxRem
$cmin :: PxRem -> PxRem -> PxRem
min :: PxRem -> PxRem -> PxRem
Ord, Int -> PxRem
PxRem -> Int
PxRem -> [PxRem]
PxRem -> PxRem
PxRem -> PxRem -> [PxRem]
PxRem -> PxRem -> PxRem -> [PxRem]
(PxRem -> PxRem)
-> (PxRem -> PxRem)
-> (Int -> PxRem)
-> (PxRem -> Int)
-> (PxRem -> [PxRem])
-> (PxRem -> PxRem -> [PxRem])
-> (PxRem -> PxRem -> [PxRem])
-> (PxRem -> PxRem -> PxRem -> [PxRem])
-> Enum PxRem
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 :: PxRem -> PxRem
succ :: PxRem -> PxRem
$cpred :: PxRem -> PxRem
pred :: PxRem -> PxRem
$ctoEnum :: Int -> PxRem
toEnum :: Int -> PxRem
$cfromEnum :: PxRem -> Int
fromEnum :: PxRem -> Int
$cenumFrom :: PxRem -> [PxRem]
enumFrom :: PxRem -> [PxRem]
$cenumFromThen :: PxRem -> PxRem -> [PxRem]
enumFromThen :: PxRem -> PxRem -> [PxRem]
$cenumFromTo :: PxRem -> PxRem -> [PxRem]
enumFromTo :: PxRem -> PxRem -> [PxRem]
$cenumFromThenTo :: PxRem -> PxRem -> PxRem -> [PxRem]
enumFromThenTo :: PxRem -> PxRem -> PxRem -> [PxRem]
Enum)


instance Num Length where
  -- only support numeric literals
  Length
a + :: Length -> Length -> Length
+ Length
_ = Length
a
  Length
a * :: Length -> Length -> Length
* Length
_ = Length
a
  abs :: Length -> Length
abs (PxRem PxRem
a) = PxRem -> Length
PxRem (PxRem -> PxRem
forall a. Num a => a -> a
abs PxRem
a)
  abs (Pct Float
a) = Float -> Length
Pct (Float -> Float
forall a. Num a => a -> a
abs Float
a)
  signum :: Length -> Length
signum (PxRem PxRem
a) = PxRem -> Length
PxRem (PxRem -> PxRem
forall a. Num a => a -> a
signum PxRem
a)
  signum (Pct Float
a) = Float -> Length
Pct (Float -> Float
forall a. Num a => a -> a
signum Float
a)
  negate :: Length -> Length
negate (PxRem PxRem
a) = PxRem -> Length
PxRem (PxRem -> PxRem
forall a. Num a => a -> a
negate PxRem
a)
  negate (Pct Float
a) = Float -> Length
Pct (Float -> Float
forall a. Num a => a -> a
negate Float
a)
  fromInteger :: Integer -> Length
fromInteger Integer
n = PxRem -> Length
PxRem (Integer -> PxRem
forall a. Num a => Integer -> a
fromInteger Integer
n)


instance ToStyleValue PxRem where
  toStyleValue :: PxRem -> StyleValue
toStyleValue (PxRem' Int
0) = StyleValue
"0px"
  toStyleValue (PxRem' Int
1) = StyleValue
"1px"
  toStyleValue (PxRem' Int
n) = String -> StyleValue
StyleValue (String -> StyleValue) -> String -> StyleValue
forall a b. (a -> b) -> a -> b
$ Float -> String
forall a. Show a => a -> String
show ((Int -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n :: Float) Float -> Float -> Float
forall a. Fractional a => a -> a -> a
/ Float
16.0) String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"rem"


instance ToStyleValue Length where
  toStyleValue :: Length -> StyleValue
toStyleValue (PxRem PxRem
p) = PxRem -> StyleValue
forall a. ToStyleValue a => a -> StyleValue
toStyleValue PxRem
p
  toStyleValue (Pct Float
n) = String -> StyleValue
StyleValue (String -> StyleValue) -> String -> StyleValue
forall a b. (a -> b) -> a -> b
$ Maybe Int -> Float -> ShowS
forall a. RealFloat a => Maybe Int -> a -> ShowS
showFFloat (Int -> Maybe Int
forall a. a -> Maybe a
Just Int
1) (Float
n Float -> Float -> Float
forall a. Num a => a -> a -> a
* Float
100) String
"" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"%"


-- | Milliseconds, used for transitions
newtype Ms = Ms Int
  deriving (Int -> Ms -> ShowS
[Ms] -> ShowS
Ms -> String
(Int -> Ms -> ShowS)
-> (Ms -> String) -> ([Ms] -> ShowS) -> Show Ms
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Ms -> ShowS
showsPrec :: Int -> Ms -> ShowS
$cshow :: Ms -> String
show :: Ms -> String
$cshowList :: [Ms] -> ShowS
showList :: [Ms] -> ShowS
Show)
  deriving newtype (Integer -> Ms
Ms -> Ms
Ms -> Ms -> Ms
(Ms -> Ms -> Ms)
-> (Ms -> Ms -> Ms)
-> (Ms -> Ms -> Ms)
-> (Ms -> Ms)
-> (Ms -> Ms)
-> (Ms -> Ms)
-> (Integer -> Ms)
-> Num Ms
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: Ms -> Ms -> Ms
+ :: Ms -> Ms -> Ms
$c- :: Ms -> Ms -> Ms
- :: Ms -> Ms -> Ms
$c* :: Ms -> Ms -> Ms
* :: Ms -> Ms -> Ms
$cnegate :: Ms -> Ms
negate :: Ms -> Ms
$cabs :: Ms -> Ms
abs :: Ms -> Ms
$csignum :: Ms -> Ms
signum :: Ms -> Ms
$cfromInteger :: Integer -> Ms
fromInteger :: Integer -> Ms
Num, Ms -> ClassName
(Ms -> ClassName) -> ToClassName Ms
forall a. (a -> ClassName) -> ToClassName a
$ctoClassName :: Ms -> ClassName
toClassName :: Ms -> ClassName
ToClassName)


instance ToStyleValue Ms where
  toStyleValue :: Ms -> StyleValue
toStyleValue (Ms Int
n) = String -> StyleValue
StyleValue (String -> StyleValue) -> String -> StyleValue
forall a b. (a -> b) -> a -> b
$ Int -> String
forall a. Show a => a -> String
show Int
n String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"ms"


-- | Media allows for responsive designs that change based on characteristics of the window. See [Layout Example](https://github.com/seanhess/web-view/blob/master/example/Example/Layout.hs)
data Media
  = MinWidth Int
  | MaxWidth Int
  deriving (Media -> Media -> Bool
(Media -> Media -> Bool) -> (Media -> Media -> Bool) -> Eq Media
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Media -> Media -> Bool
== :: Media -> Media -> Bool
$c/= :: Media -> Media -> Bool
/= :: Media -> Media -> Bool
Eq, Eq Media
Eq Media =>
(Media -> Media -> Ordering)
-> (Media -> Media -> Bool)
-> (Media -> Media -> Bool)
-> (Media -> Media -> Bool)
-> (Media -> Media -> Bool)
-> (Media -> Media -> Media)
-> (Media -> Media -> Media)
-> Ord Media
Media -> Media -> Bool
Media -> Media -> Ordering
Media -> Media -> Media
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 :: Media -> Media -> Ordering
compare :: Media -> Media -> Ordering
$c< :: Media -> Media -> Bool
< :: Media -> Media -> Bool
$c<= :: Media -> Media -> Bool
<= :: Media -> Media -> Bool
$c> :: Media -> Media -> Bool
> :: Media -> Media -> Bool
$c>= :: Media -> Media -> Bool
>= :: Media -> Media -> Bool
$cmax :: Media -> Media -> Media
max :: Media -> Media -> Media
$cmin :: Media -> Media -> Media
min :: Media -> Media -> Media
Ord, Int -> Media -> ShowS
[Media] -> ShowS
Media -> String
(Int -> Media -> ShowS)
-> (Media -> String) -> ([Media] -> ShowS) -> Show Media
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Media -> ShowS
showsPrec :: Int -> Media -> ShowS
$cshow :: Media -> String
show :: Media -> String
$cshowList :: [Media] -> ShowS
showList :: [Media] -> ShowS
Show)


{- | Options for styles that support specifying various sides. This has a "fake" Num instance to support literals

> border 5
> border (X 2)
> border (TRBL 0 5 0 0)
-}
data Sides a
  = All a
  | TRBL a a a a
  | X a
  | Y a
  | XY a a


-- Num instance is just to support literals
instance (Num a) => Num (Sides a) where
  Sides a
a + :: Sides a -> Sides a -> Sides a
+ Sides a
_ = Sides a
a
  Sides a
a * :: Sides a -> Sides a -> Sides a
* Sides a
_ = Sides a
a
  abs :: Sides a -> Sides a
abs Sides a
a = Sides a
a
  negate :: Sides a -> Sides a
negate Sides a
a = Sides a
a
  signum :: Sides a -> Sides a
signum Sides a
a = Sides a
a
  fromInteger :: Integer -> Sides a
fromInteger Integer
n = a -> Sides a
forall a. a -> Sides a
All (Integer -> a
forall a. Num a => Integer -> a
fromInteger Integer
n)


-- | Element's attributes do not include class, which is separated. FlatAttributes generate the class attribute and include it
newtype FlatAttributes = FlatAttributes {FlatAttributes -> Map Text Text
attributes :: Map Name AttValue}
  deriving ((forall x. FlatAttributes -> Rep FlatAttributes x)
-> (forall x. Rep FlatAttributes x -> FlatAttributes)
-> Generic FlatAttributes
forall x. Rep FlatAttributes x -> FlatAttributes
forall x. FlatAttributes -> Rep FlatAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FlatAttributes -> Rep FlatAttributes x
from :: forall x. FlatAttributes -> Rep FlatAttributes x
$cto :: forall x. Rep FlatAttributes x -> FlatAttributes
to :: forall x. Rep FlatAttributes x -> FlatAttributes
Generic)


-- ** Colors


{- | ToColor allows you to create a type containing your application's colors:

> data AppColor
>   = White
>   | Primary
>   | Dark
>
> instance ToColor AppColor where
>   colorValue White = "#FFF"
>   colorValue Dark = "#333"
>   colorValue Primary = "#00F"
>
> hello :: View c ()
> hello = el (bg Primary . color White) "Hello"
-}
class ToColor a where
  colorValue :: a -> HexColor
  colorName :: a -> Text
  default colorName :: (Show a) => a -> Text
  colorName = Text -> Text
T.toLower (Text -> Text) -> (a -> Text) -> a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
pack (String -> Text) -> (a -> String) -> a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> String
forall a. Show a => a -> String
show


-- | Hexidecimal Color. Can be specified with or without the leading '#'. Recommended to use an AppColor type instead of manually using hex colors. See 'Web.View.Types.ToColor'
newtype HexColor = HexColor Text
  deriving (Int -> HexColor -> ShowS
[HexColor] -> ShowS
HexColor -> String
(Int -> HexColor -> ShowS)
-> (HexColor -> String) -> ([HexColor] -> ShowS) -> Show HexColor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HexColor -> ShowS
showsPrec :: Int -> HexColor -> ShowS
$cshow :: HexColor -> String
show :: HexColor -> String
$cshowList :: [HexColor] -> ShowS
showList :: [HexColor] -> ShowS
Show)


instance ToColor HexColor where
  colorValue :: HexColor -> HexColor
colorValue HexColor
c = HexColor
c
  colorName :: HexColor -> Text
colorName (HexColor Text
a) = (Char -> Bool) -> Text -> Text
T.dropWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'#') Text
a


instance ToStyleValue HexColor where
  toStyleValue :: HexColor -> StyleValue
toStyleValue (HexColor Text
s) = String -> StyleValue
StyleValue (String -> StyleValue) -> String -> StyleValue
forall a b. (a -> b) -> a -> b
$ String
"#" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
unpack ((Char -> Bool) -> Text -> Text
T.dropWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'#') Text
s)


instance IsString HexColor where
  fromString :: String -> HexColor
fromString = Text -> HexColor
HexColor (Text -> HexColor) -> (String -> Text) -> String -> HexColor
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> Text -> Text
T.dropWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'#') (Text -> Text) -> (String -> Text) -> String -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack


instance ToClassName HexColor where
  toClassName :: HexColor -> ClassName
toClassName = Text -> ClassName
className (Text -> ClassName) -> (HexColor -> Text) -> HexColor -> ClassName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HexColor -> Text
forall a. ToColor a => a -> Text
colorName


data Align
  = Center
  deriving (Int -> Align -> ShowS
[Align] -> ShowS
Align -> String
(Int -> Align -> ShowS)
-> (Align -> String) -> ([Align] -> ShowS) -> Show Align
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Align -> ShowS
showsPrec :: Int -> Align -> ShowS
$cshow :: Align -> String
show :: Align -> String
$cshowList :: [Align] -> ShowS
showList :: [Align] -> ShowS
Show, Align -> ClassName
(Align -> ClassName) -> ToClassName Align
forall a. (a -> ClassName) -> ToClassName a
$ctoClassName :: Align -> ClassName
toClassName :: Align -> ClassName
ToClassName, Align -> StyleValue
(Align -> StyleValue) -> ToStyleValue Align
forall a. (a -> StyleValue) -> ToStyleValue a
$ctoStyleValue :: Align -> StyleValue
toStyleValue :: Align -> StyleValue
ToStyleValue)