-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from alexmingoia/topic/list-style-rule
Add list-style rule
- Loading branch information
Showing
5 changed files
with
211 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module CSS.ListStyle where | ||
|
||
import CSS.ListStyle.Image (ListStyleImage) | ||
import CSS.ListStyle.Position (ListStylePosition) | ||
import CSS.ListStyle.Type (ListStyleType) | ||
import CSS.Property (class Val, value) | ||
import CSS.String (fromString) | ||
import CSS.Stylesheet (CSS, key) | ||
import Data.Tuple.Nested (tuple3) | ||
|
||
data ListStyle = ListStyle ListStyleType ListStylePosition ListStyleImage | ||
|
||
instance valueListStyle :: Val ListStyle where | ||
value (ListStyle t p i) = value (tuple3 t p i) | ||
|
||
listStyle :: ListStyleType -> ListStylePosition -> ListStyleImage -> CSS | ||
listStyle t p i = key (fromString "list-style") (ListStyle t p i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module CSS.ListStyle.Image where | ||
|
||
import CSS.Common (class Inherit, class Initial, class None, class Unset, class URL) | ||
import CSS.Property (class Val) | ||
import CSS.String (fromString) | ||
import CSS.Stylesheet (CSS, key) | ||
import Data.Eq (class Eq) | ||
import Data.Function (($)) | ||
import Data.Generic (class Generic, gShow) | ||
import Data.Ord (class Ord) | ||
import Data.Semigroup ((<>)) | ||
import Data.Show (class Show) | ||
|
||
data ListStyleImage | ||
= ListStyleImage String | ||
| Initial | ||
| Inherit | ||
| Unset | ||
| None | ||
|
||
derive instance eqListStyleImage :: Eq ListStyleImage | ||
derive instance ordListStyleImage :: Ord ListStyleImage | ||
derive instance genericListStyleImage :: Generic ListStyleImage | ||
|
||
instance showListStyleImage :: Show ListStyleImage where | ||
show = gShow | ||
|
||
instance valListStyleImage :: Val ListStyleImage where | ||
value (Initial) = fromString "initial" | ||
value (Inherit) = fromString "inherit" | ||
value (Unset) = fromString "unset" | ||
value (None) = fromString "none" | ||
value (ListStyleImage url) = fromString ("url('" <> url <> "')") | ||
|
||
instance initialListStyleImage :: Initial ListStyleImage where | ||
initial = Initial | ||
|
||
instance inheritListStyleImage :: Inherit ListStyleImage where | ||
inherit = Inherit | ||
|
||
instance unsetListStyleImage :: Unset ListStyleImage where | ||
unset = Unset | ||
|
||
instance noneListImageImage :: None ListStyleImage where | ||
none = None | ||
|
||
instance urlListStyleImage :: URL ListStyleImage where | ||
url s = ListStyleImage s | ||
|
||
listStyleImage :: ListStyleImage -> CSS | ||
listStyleImage = key $ fromString "list-style-image" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module CSS.ListStyle.Position where | ||
|
||
import CSS.Common (class Inherit, class Initial, class Unset) | ||
import CSS.Property (class Val) | ||
import CSS.String (fromString) | ||
import CSS.Stylesheet (CSS, key) | ||
import Data.Eq (class Eq) | ||
import Data.Function (($)) | ||
import Data.Generic (class Generic, gShow) | ||
import Data.Ord (class Ord) | ||
import Data.Show (class Show) | ||
|
||
data ListStylePosition | ||
= Inside | ||
| Outside | ||
| Inherit | ||
| Initial | ||
| Unset | ||
|
||
derive instance eqListStylePosition :: Eq ListStylePosition | ||
derive instance ordListStylePosition :: Ord ListStylePosition | ||
derive instance genericListStylePosition :: Generic ListStylePosition | ||
|
||
instance showListStylePosition :: Show ListStylePosition where | ||
show = gShow | ||
|
||
instance valListStylePosition :: Val ListStylePosition where | ||
value (Inside) = fromString "inside" | ||
value (Outside) = fromString "outside" | ||
value (Inherit) = fromString "inherit" | ||
value (Initial) = fromString "initial" | ||
value (Unset) = fromString "unset" | ||
|
||
instance initialListStylePosition :: Initial ListStylePosition where | ||
initial = Initial | ||
|
||
instance inheritListStylePosition :: Inherit ListStylePosition where | ||
inherit = Inherit | ||
|
||
instance unsetListStylePosition :: Unset ListStylePosition where | ||
unset = Unset | ||
|
||
inside :: ListStylePosition | ||
inside = Inside | ||
|
||
outside :: ListStylePosition | ||
outside = Outside | ||
|
||
listStylePosition :: ListStylePosition -> CSS | ||
listStylePosition = key $ fromString "list-style-position" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
module CSS.ListStyle.Type where | ||
|
||
import CSS.Common (class Inherit, class Initial, class None, class Unset) | ||
import CSS.Property (class Val) | ||
import CSS.String (fromString) | ||
import CSS.Stylesheet (CSS, key) | ||
import Data.Eq (class Eq) | ||
import Data.Function (($)) | ||
import Data.Generic (class Generic, gShow) | ||
import Data.Ord (class Ord) | ||
import Data.Semigroup ((<>)) | ||
import Data.Show (class Show) | ||
|
||
data ListStyleType | ||
= Disc | ||
| Circle | ||
| Square | ||
| Decimal | ||
| Georgian | ||
| CJKIdeographic | ||
| Kannada | ||
| None | ||
| Inherit | ||
| Initial | ||
| Unset | ||
| CustomStyleType String | ||
| StringStyleType String | ||
|
||
derive instance eqListStyleType :: Eq ListStyleType | ||
derive instance ordListStyleType :: Ord ListStyleType | ||
derive instance genericListStyleType :: Generic ListStyleType | ||
|
||
instance showListStyleType :: Show ListStyleType where | ||
show = gShow | ||
|
||
instance valListStyleType :: Val ListStyleType where | ||
value (Disc) = fromString "disc" | ||
value (Circle) = fromString "circle" | ||
value (Square) = fromString "square" | ||
value (Decimal) = fromString "decimal" | ||
value (Georgian) = fromString "georgian" | ||
value (CJKIdeographic) = fromString "cjk-ideographic" | ||
value (Kannada) = fromString "kannada" | ||
value (None) = fromString "none" | ||
value (Initial) = fromString "initial" | ||
value (Inherit) = fromString "inherit" | ||
value (Unset) = fromString "unset" | ||
value (CustomStyleType s) = fromString ("custom-" <> s) | ||
value (StringStyleType s) = fromString s | ||
|
||
instance initialListStyleType :: Initial ListStyleType where | ||
initial = Initial | ||
|
||
instance inheritListStyleType :: Inherit ListStyleType where | ||
inherit = Inherit | ||
|
||
instance unsetListStyleType :: Unset ListStyleType where | ||
unset = Unset | ||
|
||
instance noneListTypeType :: None ListStyleType where | ||
none = None | ||
|
||
disc :: ListStyleType | ||
disc = Disc | ||
|
||
circle :: ListStyleType | ||
circle = Circle | ||
|
||
square :: ListStyleType | ||
square = Square | ||
|
||
decimal :: ListStyleType | ||
decimal = Decimal | ||
|
||
georgian :: ListStyleType | ||
georgian = Georgian | ||
|
||
cjkIdeographic :: ListStyleType | ||
cjkIdeographic = CJKIdeographic | ||
|
||
kannada :: ListStyleType | ||
kannada = Kannada | ||
|
||
customListStyleType :: String -> ListStyleType | ||
customListStyleType s = CustomStyleType s | ||
|
||
stringListStyleType :: String -> ListStyleType | ||
stringListStyleType s = StringStyleType s | ||
|
||
listStyleType :: ListStyleType -> CSS | ||
listStyleType = key $ fromString "list-style-type" |