0 | module Text.CSS.Length
 1 |
 2 | %default total
 3 |
 4 | public export
 5 | data Length : Type where
 6 |   Pt       : Bits16 -> Length
 7 |   Px       : Bits16 -> Length
 8 |   Em       : Double -> Length
 9 |   Rem      : Double -> Length
10 |
11 | export
12 | Interpolation Length where
13 |   interpolate (Pt x)  = show x ++ "pt"
14 |   interpolate (Px x)  = show x ++ "px"
15 |   interpolate (Em x)  = show x ++ "em"
16 |   interpolate (Rem x) = show x ++ "rem"
17 |
18 | export %inline
19 | pt : Cast Length a => Bits16 -> a
20 | pt = cast . Pt
21 |
22 | export %inline
23 | px : Cast Length a => Bits16 -> a
24 | px = cast . Px
25 |
26 | export %inline
27 | em : Cast Length a => Double -> a
28 | em = cast . Em
29 |
30 | export %inline
31 | rem : Cast Length a => Double -> a
32 | rem = cast . Rem
33 |
34 | export %inline
35 | (.pt) : Cast Length a => Bits16 -> a
36 | (.pt) = pt
37 |
38 | export %inline
39 | (.px) : Cast Length a => Bits16 -> a
40 | (.px) = px
41 |
42 | export %inline
43 | (.em) : Cast Length a => Double -> a
44 | (.em) = em
45 |
46 | export %inline
47 | (.rem) : Cast Length a => Double -> a
48 | (.rem) = rem
49 |