/
Font.purs
65 lines (45 loc) · 1.88 KB
/
Font.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
module CSS.Font where
import Prelude
import CSS.Color (Color)
import CSS.Common (class Inherit, class Initial, class Normal, class Unset)
import CSS.Property (class Val, Value, value, quote)
import CSS.Size (Size)
import CSS.String (fromString)
import CSS.Stylesheet (CSS, key)
import Data.NonEmpty (NonEmpty, oneOf)
color :: Color -> CSS
color = key $ fromString "color"
newtype GenericFontFamily = GenericFontFamily Value
derive instance eqGenericFontFamily :: Eq GenericFontFamily
derive instance ordGenericFontFamily :: Ord GenericFontFamily
instance valGenericFontFamily :: Val GenericFontFamily where
value (GenericFontFamily v) = v
sansSerif :: GenericFontFamily
sansSerif = GenericFontFamily $ fromString "sans-serif"
fontFamily :: Array String -> NonEmpty Array GenericFontFamily -> CSS
fontFamily a b = key (fromString "font-family") <<< value $ (value <<< quote <$> a) <> oneOf (value <$> b)
fontSize :: forall a. Size a -> CSS
fontSize = key $ fromString "font-size"
newtype FontWeight = FontWeight Value
derive instance eqFontWeight :: Eq FontWeight
derive instance ordFontWeight :: Ord FontWeight
instance valFontWeight :: Val FontWeight where
value (FontWeight v) = v
instance normalFontWeight :: Normal FontWeight where
normal = FontWeight (fromString "normal")
instance initialFontWeight :: Initial FontWeight where
initial = FontWeight (fromString "initial")
instance inheritFontWeight :: Inherit FontWeight where
inherit = FontWeight (fromString "inherit")
instance unsetFontWeight :: Unset FontWeight where
unset = FontWeight (fromString "unset")
bold :: FontWeight
bold = FontWeight $ fromString "bold"
bolder :: FontWeight
bolder = FontWeight $ fromString "bolder"
lighter :: FontWeight
lighter = FontWeight $ fromString "lighter"
weight :: Number -> FontWeight
weight i = FontWeight $ value i
fontWeight :: FontWeight -> CSS
fontWeight = key $ fromString "font-weight"