Skip to content

Commit f47bd21

Browse files
committed
Add list-style rules.
1 parent 77625e2 commit f47bd21

File tree

4 files changed

+191
-0
lines changed

4 files changed

+191
-0
lines changed

src/CSS/ListStyle.purs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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)
7+
import CSS.String (fromString)
8+
import CSS.Stylesheet (CSS, key)
9+
import Data.Function (($))
10+
import Data.Semigroup ((<>))
11+
import Data.Show (show)
12+
13+
data ListStyle = ListStyle ListStyleType ListStylePosition ListStyleImage
14+
15+
instance valueListStyle :: Val ListStyle where
16+
value (ListStyle t p i) =
17+
fromString $ (show t) <> " " <> (show p) <> " " <> (show i)
18+
19+
listStyle :: ListStyleType -> ListStylePosition -> ListStyleImage -> CSS
20+
listStyle t p i = key (fromString "list-style") (ListStyle t p i)

src/CSS/ListStyle/Image.purs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.Function (($))
8+
import Data.Semigroup ((<>))
9+
import Data.Show (class Show, show)
10+
11+
data ListStyleImage
12+
= ListStyleImage String
13+
| Initial
14+
| Inherit
15+
| Unset
16+
| None
17+
18+
instance valListStyleImage :: Val ListStyleImage where
19+
value s = fromString (show s)
20+
21+
instance showListStyleImage :: Show ListStyleImage where
22+
show (Initial) = "initial"
23+
show (Inherit) = "inherit"
24+
show (Unset) = "unset"
25+
show (None) = "none"
26+
show (ListStyleImage url) = ("url('" <> url <> "')")
27+
28+
instance initialListStyleImage :: Initial ListStyleImage where
29+
initial = Initial
30+
31+
instance inheritListStyleImage :: Inherit ListStyleImage where
32+
inherit = Inherit
33+
34+
instance unsetListStyleImage :: Unset ListStyleImage where
35+
unset = Unset
36+
37+
instance noneListImageImage :: None ListStyleImage where
38+
none = None
39+
40+
instance urlListStyleImage :: URL ListStyleImage where
41+
url s = ListStyleImage s
42+
43+
listStyleImage :: ListStyleImage -> CSS
44+
listStyleImage = key $ fromString "list-style-image"

src/CSS/ListStyle/Position.purs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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.Function (($))
8+
import Data.Show (class Show, show)
9+
10+
data ListStylePosition
11+
= Inside
12+
| Outside
13+
| Inherit
14+
| Initial
15+
| Unset
16+
17+
instance valListStylePosition :: Val ListStylePosition where
18+
value s = fromString (show s)
19+
20+
instance showListStylePosition :: Show ListStylePosition where
21+
show (Inside) = "inside"
22+
show (Outside) = "outside"
23+
show (Inherit) = "inherit"
24+
show (Initial) = "initial"
25+
show (Unset) = "unset"
26+
27+
instance initialListStylePosition :: Initial ListStylePosition where
28+
initial = Initial
29+
30+
instance inheritListStylePosition :: Inherit ListStylePosition where
31+
inherit = Inherit
32+
33+
instance unsetListStylePosition :: Unset ListStylePosition where
34+
unset = Unset
35+
36+
inside :: ListStylePosition
37+
inside = Inside
38+
39+
outside :: ListStylePosition
40+
outside = Outside
41+
42+
listStylePosition :: ListStylePosition -> CSS
43+
listStylePosition = key $ fromString "list-style-position"

src/CSS/ListStyle/Type.purs

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

0 commit comments

Comments
 (0)