-----------------------------------------------------------------------------
-- |
-- Module      :  Miso.Style.Types
-- Copyright   :  (C) 2016-2025 David M. Johnson (@dmjio)
-- License     :  BSD3-style (see the file LICENSE)
-- Maintainer  :  David M. Johnson <code@dmj.io>
-- Stability   :  experimental
-- Portability :  non-portable
----------------------------------------------------------------------------
module Miso.Style.Types
  ( -- *** Types
    Style
  , Styles (..)
  , StyleSheet (..)
  ) where
-----------------------------------------------------------------------------
import Miso.String (MisoString)
-----------------------------------------------------------------------------
-- | Type for a CSS StyleSheet. Internally it maps From CSS selectors to 'Styles'.
--
-- @
-- testSheet :: StyleSheet
-- testSheet =
--    sheet_
--    [ selector_ ".name"
--        [ backgroundColor red
--        , alignContent "top"
--        ]
--    , selector_ "#container"
--        [ backgroundColor blue
--        , alignContent "center"
--        ]
--    , keyframes_ "slide-in"
--      [ "from" =:
--        [ transform "translateX(0%)"
--        ]
--      , "to" =:
--        [ transform "translateX(100%)"
--        , backgroundColor red
--        , backgroundSize "10px"
--        , backgroundRepeat "true"
--        ]
--      , pct 10 =:
--        [ "foo" =: "bar"
--        ]
--      ]
--    , media_ "screen and (min-width: 480px)"
--      [ "header" =:
--        [ height "auto"
--        ]
--      , "ul" =:
--        [ display "block"
--        ]
--      ]
--    ]
-- @
--
newtype StyleSheet = StyleSheet { StyleSheet -> [Styles]
getStyleSheet :: [Styles] }
  deriving (StyleSheet -> StyleSheet -> Bool
(StyleSheet -> StyleSheet -> Bool)
-> (StyleSheet -> StyleSheet -> Bool) -> Eq StyleSheet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StyleSheet -> StyleSheet -> Bool
== :: StyleSheet -> StyleSheet -> Bool
$c/= :: StyleSheet -> StyleSheet -> Bool
/= :: StyleSheet -> StyleSheet -> Bool
Eq, Int -> StyleSheet -> ShowS
[StyleSheet] -> ShowS
StyleSheet -> String
(Int -> StyleSheet -> ShowS)
-> (StyleSheet -> String)
-> ([StyleSheet] -> ShowS)
-> Show StyleSheet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StyleSheet -> ShowS
showsPrec :: Int -> StyleSheet -> ShowS
$cshow :: StyleSheet -> String
show :: StyleSheet -> String
$cshowList :: [StyleSheet] -> ShowS
showList :: [StyleSheet] -> ShowS
Show)
-----------------------------------------------------------------------------
-- | Type for a CSS 'Style'
--
type Style = (MisoString, MisoString)
-----------------------------------------------------------------------------
-- | Type for a @Map@ of CSS 'Style'. Used with @StyleSheet@.
-- It maps CSS properties to their values.
data Styles
  = Styles (MisoString, [Style])
  | KeyFrame MisoString [(MisoString, [Style])]
  | Media MisoString [(MisoString, [Style])]
  deriving (Styles -> Styles -> Bool
(Styles -> Styles -> Bool)
-> (Styles -> Styles -> Bool) -> Eq Styles
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Styles -> Styles -> Bool
== :: Styles -> Styles -> Bool
$c/= :: Styles -> Styles -> Bool
/= :: Styles -> Styles -> Bool
Eq, Int -> Styles -> ShowS
[Styles] -> ShowS
Styles -> String
(Int -> Styles -> ShowS)
-> (Styles -> String) -> ([Styles] -> ShowS) -> Show Styles
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Styles -> ShowS
showsPrec :: Int -> Styles -> ShowS
$cshow :: Styles -> String
show :: Styles -> String
$cshowList :: [Styles] -> ShowS
showList :: [Styles] -> ShowS
Show)
-----------------------------------------------------------------------------