diff --git a/src/CSS/Common.purs b/src/CSS/Common.purs index 8deee1e..40a3ae5 100644 --- a/src/CSS/Common.purs +++ b/src/CSS/Common.purs @@ -27,10 +27,10 @@ class Visible a where visible :: a class Hidden a where hidden :: a class Initial a where initial :: a class Unset a where unset :: a - class Top a where top :: a class Middle a where middle :: a class Bottom a where bottom :: a +class URL a where url :: String -> a -- | The other type class is used to escape from the type safety introduced by -- embedding CSS properties into the typed world of purescript-css. @@ -50,10 +50,10 @@ instance hiddenValue :: Hidden Value where hidden = fromString "hidden" instance otherValue :: Other Value where other = id instance initialValue :: Initial Value where initial = fromString "initial" instance unsetValue :: Unset Value where unset = fromString "unset" - instance topValue :: Top Value where top = fromString "top" instance middleValue :: Middle Value where middle = fromString "middle" instance bottomValue :: Bottom Value where bottom = fromString "bottom" +instance urlValue :: URL Value where url s = fromString ("url(\"" <> s <> "\")") ------------------------------------------------------------------------------- diff --git a/src/CSS/ListStyle.purs b/src/CSS/ListStyle.purs new file mode 100644 index 0000000..139a1e6 --- /dev/null +++ b/src/CSS/ListStyle.purs @@ -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) diff --git a/src/CSS/ListStyle/Image.purs b/src/CSS/ListStyle/Image.purs new file mode 100644 index 0000000..001b27f --- /dev/null +++ b/src/CSS/ListStyle/Image.purs @@ -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" diff --git a/src/CSS/ListStyle/Position.purs b/src/CSS/ListStyle/Position.purs new file mode 100644 index 0000000..c74acbf --- /dev/null +++ b/src/CSS/ListStyle/Position.purs @@ -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" diff --git a/src/CSS/ListStyle/Type.purs b/src/CSS/ListStyle/Type.purs new file mode 100644 index 0000000..2c7c530 --- /dev/null +++ b/src/CSS/ListStyle/Type.purs @@ -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"