module Data.CSS.Properties.Text
(
letterSpacing,
textAlign,
textIndent,
whiteSpace,
wordSpacing,
direction,
unicodeBidi,
content,
contentUrl,
counterIncrement,
counterReset,
quotes,
listStyle,
listStyleImage,
listStyleImageUrl,
listStylePosition,
listStyleType,
listStyleUrl,
orphans,
widows,
textTransform
)
where
import Blaze.ByteString.Builder
import Blaze.ByteString.Builder.Char8
import Data.ByteString (ByteString)
import Data.CSS.Build
import Data.CSS.Properties.Types
import Data.CSS.Properties.Utils
import Data.CSS.Types
import Data.CSS.Utils
import Data.Monoid
import Data.Text (Text)
import Web.Routes.RouteT
content :: Maybe [ContentPart (CssUrl Text)] -> SetProp
content = setProp "content" . maybeProp "normal"
contentUrl :: (MonadRoute m) => Maybe [ContentPart (URL m)] -> SetPropM m
contentUrl parts = do
renderUrl <- askRouteFn
content . fmap (map (fmap $ CssUrl . flip renderUrl [])) $ parts
counterIncrement :: (Integral a) => [(ByteString, a)] -> SetProp
counterIncrement [] = setProp "counter-increment" (PropValue "none")
counterIncrement cs = setProp "counter-increment" (map (formatCounter 1) cs)
counterReset :: (Integral a) => [(ByteString, a)] -> SetProp
counterReset [] = setProp "counter-reset" (PropValue "none")
counterReset cs = setProp "counter-reset" (map (formatCounter 0) cs)
direction :: TextDirection -> SetProp
direction = setProp "direction"
formatCounter :: (Integral a) => a -> (ByteString, a) -> ByteString
formatCounter def (ctr, n)
| n == def = ctr
| otherwise =
toByteString $
fromByteString ctr <>
fromChar ' ' <>
showReal n
letterSpacing :: (Real a) => Maybe (Length a) -> SetProp
letterSpacing = setProp "letter-spacing" . maybeProp "normal"
listStyle :: ListStyle -> ListPosition -> Maybe (CssUrl Text) -> SetProp
listStyle style pos url = setProp "list-style" (style, pos, maybeProp "none" url)
listStyleImage :: Maybe (CssUrl Text) -> SetProp
listStyleImage = setProp "list-style-image" . maybeProp "none"
listStyleImageUrl :: (MonadRoute m) => Maybe (URL m) -> SetPropM m
listStyleImageUrl url = do
renderUrl <- askRouteFn
listStyleImage . fmap (CssUrl . flip renderUrl []) $ url
listStylePosition :: ListPosition -> SetProp
listStylePosition = setProp "list-style-position"
listStyleType :: ListStyle -> SetProp
listStyleType = setProp "list-style-type"
listStyleUrl ::
(MonadRoute m)
=> ListStyle
-> ListPosition
-> Maybe (URL m)
-> SetPropM m
listStyleUrl style pos url = do
renderUrl <- askRouteFn
listStyle style pos (fmap (CssUrl . flip renderUrl []) url)
orphans :: (Integral a) => a -> SetProp
orphans = setProp "orphans" . toInteger
quotes :: [(CssString Text, CssString Text)] -> SetProp
quotes [] = setProp "quotes" (PropValue "none")
quotes qs = setProp "quotes" qs
textAlign :: TextAlign -> SetProp
textAlign = setProp "text-align"
textIndent :: (Real a) => FactorLen Length a -> SetProp
textIndent = setProp "text-indent"
textTransform :: Maybe TextTransform -> SetProp
textTransform = setProp "text-transform" . maybeProp "none"
unicodeBidi :: UnicodeBidiMode -> SetProp
unicodeBidi = setProp "unicode-bidi"
whiteSpace :: TextWrapMode -> SetProp
whiteSpace = setProp "white-space"
widows :: (Integral a) => a -> SetProp
widows = setProp "widows" . toInteger
wordSpacing :: (Real a) => Maybe (Length a) -> SetProp
wordSpacing = setProp "word-spacing" . maybeProp "normal"