Skip to content

Commit 411cc2c

Browse files
authored
Merge pull request #49 from alexmingoia/topic/list-style-rule
Add list-style rule
2 parents 70eb12d + 50f2a23 commit 411cc2c

File tree

5 files changed

+211
-2
lines changed

5 files changed

+211
-2
lines changed

src/CSS/Common.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class Visible a where visible :: a
2727
class Hidden a where hidden :: a
2828
class Initial a where initial :: a
2929
class Unset a where unset :: a
30-
3130
class Top a where top :: a
3231
class Middle a where middle :: a
3332
class Bottom a where bottom :: a
33+
class URL a where url :: String -> a
3434

3535
-- | The other type class is used to escape from the type safety introduced by
3636
-- embedding CSS properties into the typed world of purescript-css.
@@ -50,10 +50,10 @@ instance hiddenValue :: Hidden Value where hidden = fromString "hidden"
5050
instance otherValue :: Other Value where other = id
5151
instance initialValue :: Initial Value where initial = fromString "initial"
5252
instance unsetValue :: Unset Value where unset = fromString "unset"
53-
5453
instance topValue :: Top Value where top = fromString "top"
5554
instance middleValue :: Middle Value where middle = fromString "middle"
5655
instance bottomValue :: Bottom Value where bottom = fromString "bottom"
56+
instance urlValue :: URL Value where url s = fromString ("url(\"" <> s <> "\")")
5757

5858
-------------------------------------------------------------------------------
5959

src/CSS/ListStyle.purs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module CSS.ListStyle where
2+
3+
import CSS.ListStyle.Image (ListStyleImage)
4+
import CSS.ListStyle.Position (ListStylePosition)
5+
import CSS.ListStyle.Type (ListStyleType)
6+
import CSS.Property (class Val, value)
7+
import CSS.String (fromString)
8+
import CSS.Stylesheet (CSS, key)
9+
import Data.Tuple.Nested (tuple3)
10+
11+
data ListStyle = ListStyle ListStyleType ListStylePosition ListStyleImage
12+
13+
instance valueListStyle :: Val ListStyle where
14+
value (ListStyle t p i) = value (tuple3 t p i)
15+
16+
listStyle :: ListStyleType -> ListStylePosition -> ListStyleImage -> CSS
17+
listStyle t p i = key (fromString "list-style") (ListStyle t p i)

src/CSS/ListStyle/Image.purs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module CSS.ListStyle.Image where
2+
3+
import CSS.Common (class Inherit, class Initial, class None, class Unset, class URL)
4+
import CSS.Property (class Val)
5+
import CSS.String (fromString)
6+
import CSS.Stylesheet (CSS, key)
7+
import Data.Eq (class Eq)
8+
import Data.Function (($))
9+
import Data.Generic (class Generic, gShow)
10+
import Data.Ord (class Ord)
11+
import Data.Semigroup ((<>))
12+
import Data.Show (class Show)
13+
14+
data ListStyleImage
15+
= ListStyleImage String
16+
| Initial
17+
| Inherit
18+
| Unset
19+
| None
20+
21+
derive instance eqListStyleImage :: Eq ListStyleImage
22+
derive instance ordListStyleImage :: Ord ListStyleImage
23+
derive instance genericListStyleImage :: Generic ListStyleImage
24+
25+
instance showListStyleImage :: Show ListStyleImage where
26+
show = gShow
27+
28+
instance valListStyleImage :: Val ListStyleImage where
29+
value (Initial) = fromString "initial"
30+
value (Inherit) = fromString "inherit"
31+
value (Unset) = fromString "unset"
32+
value (None) = fromString "none"
33+
value (ListStyleImage url) = fromString ("url('" <> url <> "')")
34+
35+
instance initialListStyleImage :: Initial ListStyleImage where
36+
initial = Initial
37+
38+
instance inheritListStyleImage :: Inherit ListStyleImage where
39+
inherit = Inherit
40+
41+
instance unsetListStyleImage :: Unset ListStyleImage where
42+
unset = Unset
43+
44+
instance noneListImageImage :: None ListStyleImage where
45+
none = None
46+
47+
instance urlListStyleImage :: URL ListStyleImage where
48+
url s = ListStyleImage s
49+
50+
listStyleImage :: ListStyleImage -> CSS
51+
listStyleImage = key $ fromString "list-style-image"

src/CSS/ListStyle/Position.purs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module CSS.ListStyle.Position where
2+
3+
import CSS.Common (class Inherit, class Initial, class Unset)
4+
import CSS.Property (class Val)
5+
import CSS.String (fromString)
6+
import CSS.Stylesheet (CSS, key)
7+
import Data.Eq (class Eq)
8+
import Data.Function (($))
9+
import Data.Generic (class Generic, gShow)
10+
import Data.Ord (class Ord)
11+
import Data.Show (class Show)
12+
13+
data ListStylePosition
14+
= Inside
15+
| Outside
16+
| Inherit
17+
| Initial
18+
| Unset
19+
20+
derive instance eqListStylePosition :: Eq ListStylePosition
21+
derive instance ordListStylePosition :: Ord ListStylePosition
22+
derive instance genericListStylePosition :: Generic ListStylePosition
23+
24+
instance showListStylePosition :: Show ListStylePosition where
25+
show = gShow
26+
27+
instance valListStylePosition :: Val ListStylePosition where
28+
value (Inside) = fromString "inside"
29+
value (Outside) = fromString "outside"
30+
value (Inherit) = fromString "inherit"
31+
value (Initial) = fromString "initial"
32+
value (Unset) = fromString "unset"
33+
34+
instance initialListStylePosition :: Initial ListStylePosition where
35+
initial = Initial
36+
37+
instance inheritListStylePosition :: Inherit ListStylePosition where
38+
inherit = Inherit
39+
40+
instance unsetListStylePosition :: Unset ListStylePosition where
41+
unset = Unset
42+
43+
inside :: ListStylePosition
44+
inside = Inside
45+
46+
outside :: ListStylePosition
47+
outside = Outside
48+
49+
listStylePosition :: ListStylePosition -> CSS
50+
listStylePosition = key $ fromString "list-style-position"

src/CSS/ListStyle/Type.purs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
module CSS.ListStyle.Type where
2+
3+
import CSS.Common (class Inherit, class Initial, class None, class Unset)
4+
import CSS.Property (class Val)
5+
import CSS.String (fromString)
6+
import CSS.Stylesheet (CSS, key)
7+
import Data.Eq (class Eq)
8+
import Data.Function (($))
9+
import Data.Generic (class Generic, gShow)
10+
import Data.Ord (class Ord)
11+
import Data.Semigroup ((<>))
12+
import Data.Show (class Show)
13+
14+
data ListStyleType
15+
= Disc
16+
| Circle
17+
| Square
18+
| Decimal
19+
| Georgian
20+
| CJKIdeographic
21+
| Kannada
22+
| None
23+
| Inherit
24+
| Initial
25+
| Unset
26+
| CustomStyleType String
27+
| StringStyleType String
28+
29+
derive instance eqListStyleType :: Eq ListStyleType
30+
derive instance ordListStyleType :: Ord ListStyleType
31+
derive instance genericListStyleType :: Generic ListStyleType
32+
33+
instance showListStyleType :: Show ListStyleType where
34+
show = gShow
35+
36+
instance valListStyleType :: Val ListStyleType where
37+
value (Disc) = fromString "disc"
38+
value (Circle) = fromString "circle"
39+
value (Square) = fromString "square"
40+
value (Decimal) = fromString "decimal"
41+
value (Georgian) = fromString "georgian"
42+
value (CJKIdeographic) = fromString "cjk-ideographic"
43+
value (Kannada) = fromString "kannada"
44+
value (None) = fromString "none"
45+
value (Initial) = fromString "initial"
46+
value (Inherit) = fromString "inherit"
47+
value (Unset) = fromString "unset"
48+
value (CustomStyleType s) = fromString ("custom-" <> s)
49+
value (StringStyleType s) = fromString s
50+
51+
instance initialListStyleType :: Initial ListStyleType where
52+
initial = Initial
53+
54+
instance inheritListStyleType :: Inherit ListStyleType where
55+
inherit = Inherit
56+
57+
instance unsetListStyleType :: Unset ListStyleType where
58+
unset = Unset
59+
60+
instance noneListTypeType :: None ListStyleType where
61+
none = None
62+
63+
disc :: ListStyleType
64+
disc = Disc
65+
66+
circle :: ListStyleType
67+
circle = Circle
68+
69+
square :: ListStyleType
70+
square = Square
71+
72+
decimal :: ListStyleType
73+
decimal = Decimal
74+
75+
georgian :: ListStyleType
76+
georgian = Georgian
77+
78+
cjkIdeographic :: ListStyleType
79+
cjkIdeographic = CJKIdeographic
80+
81+
kannada :: ListStyleType
82+
kannada = Kannada
83+
84+
customListStyleType :: String -> ListStyleType
85+
customListStyleType s = CustomStyleType s
86+
87+
stringListStyleType :: String -> ListStyleType
88+
stringListStyleType s = StringStyleType s
89+
90+
listStyleType :: ListStyleType -> CSS
91+
listStyleType = key $ fromString "list-style-type"

0 commit comments

Comments
 (0)