{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeSynonymInstances #-}
module Graphics.Blank.Types.CSS where
import Data.String
import Graphics.Blank.JavaScript
import Graphics.Blank.Parser
import Graphics.Blank.Types
import Prelude.Compat
import Text.ParserCombinators.ReadP (choice)
import Text.ParserCombinators.ReadPrec (lift)
import Text.Read (Read(..), readListPrecDefault)
import TextShow (TextShow(..), FromTextShow(..))
data Length = Em { Length -> Double
runLength :: Double }
| Ex { runLength :: Double }
| Ch { runLength :: Double }
| Rem { runLength :: Double }
| Vh { runLength :: Double }
| Vw { runLength :: Double }
| Vmin { runLength :: Double }
| Vmax { runLength :: Double }
| Px { runLength :: Double }
| Mm { runLength :: Double }
| Cm { runLength :: Double }
| In { runLength :: Double }
| Pt { runLength :: Double }
| Pc { runLength :: Double }
deriving (Length -> Length -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Length -> Length -> Bool
$c/= :: Length -> Length -> Bool
== :: Length -> Length -> Bool
$c== :: Length -> Length -> Bool
Eq, Eq Length
Length -> Length -> Bool
Length -> Length -> Ordering
Length -> Length -> Length
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
min :: Length -> Length -> Length
$cmin :: Length -> Length -> Length
max :: Length -> Length -> Length
$cmax :: Length -> Length -> Length
>= :: Length -> Length -> Bool
$c>= :: Length -> Length -> Bool
> :: Length -> Length -> Bool
$c> :: Length -> Length -> Bool
<= :: Length -> Length -> Bool
$c<= :: Length -> Length -> Bool
< :: Length -> Length -> Bool
$c< :: Length -> Length -> Bool
compare :: Length -> Length -> Ordering
$ccompare :: Length -> Length -> Ordering
Ord)
class LengthProperty a where
fromLength :: Length -> a
instance LengthProperty Length where
fromLength :: Length -> Length
fromLength = forall a. a -> a
id
em :: LengthProperty a => Double -> a
em :: forall a. LengthProperty a => Double -> a
em = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Em
ex :: LengthProperty a => Double -> a
ex :: forall a. LengthProperty a => Double -> a
ex = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Ex
ch :: LengthProperty a => Double -> a
ch :: forall a. LengthProperty a => Double -> a
ch = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Ch
rem_ :: LengthProperty a => Double -> a
rem_ :: forall a. LengthProperty a => Double -> a
rem_ = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Rem
vh :: LengthProperty a => Double -> a
vh :: forall a. LengthProperty a => Double -> a
vh = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Vh
vw :: LengthProperty a => Double -> a
vw :: forall a. LengthProperty a => Double -> a
vw = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Vw
vmin :: LengthProperty a => Double -> a
vmin :: forall a. LengthProperty a => Double -> a
vmin = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Vmin
vmax :: LengthProperty a => Double -> a
vmax :: forall a. LengthProperty a => Double -> a
vmax = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Vmax
px :: LengthProperty a => Double -> a
px :: forall a. LengthProperty a => Double -> a
px = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Px
mm :: LengthProperty a => Double -> a
mm :: forall a. LengthProperty a => Double -> a
mm = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Mm
cm :: LengthProperty a => Double -> a
cm :: forall a. LengthProperty a => Double -> a
cm = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Cm
in_ :: LengthProperty a => Double -> a
in_ :: forall a. LengthProperty a => Double -> a
in_ = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
In
pt :: LengthProperty a => Double -> a
pt :: forall a. LengthProperty a => Double -> a
pt = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Pt
pc :: LengthProperty a => Double -> a
pc :: forall a. LengthProperty a => Double -> a
pc = forall a. LengthProperty a => Length -> a
fromLength forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> Length
Pc
instance IsString Length where
fromString :: String -> Length
fromString = forall a. Read a => String -> a
read
instance Read Length where
readPrec :: ReadPrec Length
readPrec = do
Double
d <- forall a. Read a => ReadPrec a
readPrec
forall a. ReadP a -> ReadPrec a
lift forall a b. (a -> b) -> a -> b
$ forall a. [ReadP a] -> ReadP a
choice
[ Double -> Length
Em Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"em"
, Double -> Length
Ex Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"ex"
, Double -> Length
Ch Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"ch"
, Double -> Length
Rem Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"rem"
, Double -> Length
Vh Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"vh"
, Double -> Length
Vw Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"vw"
, Double -> Length
Vmin Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"vmin"
, Double -> Length
Vmax Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"vmax"
, Double -> Length
Px Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"px"
, Double -> Length
Mm Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"mm"
, Double -> Length
Cm Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"cm"
, Double -> Length
In Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"in"
, Double -> Length
Pt Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"pt"
, Double -> Length
Pc Double
d forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ String -> ReadP String
stringCI String
"pc"
]
readListPrec :: ReadPrec [Length]
readListPrec = forall a. Read a => ReadPrec [a]
readListPrecDefault
instance Show Length where
showsPrec :: Int -> Length -> ShowS
showsPrec Int
p = forall a. Show a => Int -> a -> ShowS
showsPrec Int
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> FromTextShow a
FromTextShow
instance TextShow Length where
showb :: Length -> Builder
showb Length
l = Double -> Builder
jsDouble (Length -> Double
runLength Length
l) forall a. Semigroup a => a -> a -> a
<> forall {a}. IsString a => Length -> a
showbUnits Length
l
where
showbUnits :: Length -> a
showbUnits (Em Double
_) = a
"em"
showbUnits (Ex Double
_) = a
"ex"
showbUnits (Ch Double
_) = a
"ch"
showbUnits (Rem Double
_) = a
"rem"
showbUnits (Vh Double
_) = a
"vh"
showbUnits (Vw Double
_) = a
"vw"
showbUnits (Vmin Double
_) = a
"vmin"
showbUnits (Vmax Double
_) = a
"vmax"
showbUnits (Px Double
_) = a
"px"
showbUnits (Mm Double
_) = a
"mm"
showbUnits (Cm Double
_) = a
"cm"
showbUnits (In Double
_) = a
"in"
showbUnits (Pt Double
_) = a
"pt"
showbUnits (Pc Double
_) = a
"pc"
class PercentageProperty a where
percent :: Percentage -> a
instance PercentageProperty Percentage where
percent :: Double -> Double
percent = forall a. a -> a
id