Skip to content

Commit e8a1da9

Browse files
authored
Merge pull request #48 from alexmingoia/topic/vertical-align-rule
Add vertical-align rule
2 parents 9d7f83b + 48944f7 commit e8a1da9

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

src/CSS/Common.purs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class Hidden a where hidden :: a
2828
class Initial a where initial :: a
2929
class Unset a where unset :: a
3030

31+
class Top a where top :: a
32+
class Middle a where middle :: a
33+
class Bottom a where bottom :: a
34+
3135
-- | The other type class is used to escape from the type safety introduced by
3236
-- embedding CSS properties into the typed world of purescript-css.
3337
-- `Other` allows you to cast any `Value` to a specific value type.
@@ -47,6 +51,10 @@ instance otherValue :: Other Value where other = id
4751
instance initialValue :: Initial Value where initial = fromString "initial"
4852
instance unsetValue :: Unset Value where unset = fromString "unset"
4953

54+
instance topValue :: Top Value where top = fromString "top"
55+
instance middleValue :: Middle Value where middle = fromString "middle"
56+
instance bottomValue :: Bottom Value where bottom = fromString "bottom"
57+
5058
-------------------------------------------------------------------------------
5159

5260
-- | Common list browser prefixes to make experimental properties work in

src/CSS/VerticalAlign.purs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
module CSS.VerticalAlign where
2+
3+
import CSS.Common (class Baseline, class Inherit, class Initial, class Unset, class Top, class Middle, class Bottom)
4+
import CSS.Property (class Val)
5+
import CSS.String (fromString)
6+
import CSS.Stylesheet (CSS, key)
7+
import Data.Function (($))
8+
9+
data VerticalAlign
10+
= Baseline
11+
| Sub
12+
| Super
13+
| TextTop
14+
| TextBottom
15+
| Middle
16+
| Top
17+
| Bottom
18+
| Inherit
19+
| Initial
20+
| Unset
21+
22+
instance valVerticalAlign :: Val (VerticalAlign) where
23+
value (Baseline) = fromString "baseline"
24+
value (Sub) = fromString "sub"
25+
value (Super) = fromString "super"
26+
value (TextTop) = fromString "text-top"
27+
value (TextBottom) = fromString "text-bottom"
28+
value (Middle) = fromString "middle"
29+
value (Top) = fromString "top"
30+
value (Bottom) = fromString "bottom"
31+
value (Inherit) = fromString "inherit"
32+
value (Initial) = fromString "initial"
33+
value (Unset) = fromString "unset"
34+
35+
instance inheritVerticalAlign :: Inherit (VerticalAlign) where
36+
inherit = Inherit
37+
38+
instance initialVerticalAlign :: Initial (VerticalAlign) where
39+
initial = Initial
40+
41+
instance unsetVerticalAlign :: Unset (VerticalAlign) where
42+
unset = Unset
43+
44+
instance baselineVerticalAlign :: Baseline (VerticalAlign) where
45+
baseline = Baseline
46+
47+
instance middleVerticalAlign :: Middle (VerticalAlign) where
48+
middle = Middle
49+
50+
instance topVerticalAlign :: Top (VerticalAlign) where
51+
top = Top
52+
53+
instance bottomVerticalAlign :: Bottom (VerticalAlign) where
54+
bottom = Bottom
55+
56+
sub :: VerticalAlign
57+
sub = Sub
58+
59+
super :: VerticalAlign
60+
super = Super
61+
62+
textTop :: VerticalAlign
63+
textTop = TextTop
64+
65+
textBottom :: VerticalAlign
66+
textBottom = TextBottom
67+
68+
verticalAlign :: VerticalAlign -> CSS
69+
verticalAlign = key $ fromString "vertical-align"

0 commit comments

Comments
 (0)