-- | -- Module: Data.CSS.Properties.Font -- Copyright: (c) 2013 Ertugrul Soeylemez -- License: BSD3 -- Maintainer: Ertugrul Soeylemez module Data.CSS.Properties.Font ( -- * Colors and background backgroundAttachment, backgroundColor, backgroundImage, backgroundImageUrl, backgroundPosition, backgroundRepeat, color, -- * Fonts fontFamily, fontSize, fontStyle, fontVariant, fontWeight, -- * Text decoration textDecoration ) where import qualified Data.ByteString.Char8 as Bc import Data.Colour import Data.CSS.Properties.Types import Data.CSS.Properties.Utils import Data.CSS.Build import Data.CSS.Types import Data.Text (Text) import Web.Routes.RouteT -- | Set the @background-attachment@. backgroundAttachment :: BackgroundAttachment -> SetProp backgroundAttachment = setProp "background-attachment" -- | Set the @background-color@. backgroundColor :: (ColourOps f, ToPropValue (f a)) => f a -> SetProp backgroundColor = setProp "background-color" -- | Set the @background-image@. backgroundImage :: Maybe (CssUrl Text) -> SetProp backgroundImage = setProp "background-image" . maybeProp "none" -- | Set the @background-image@. backgroundImageUrl :: (MonadRoute m) => Maybe (URL m) -> SetPropM m backgroundImageUrl img = do renderUrl <- askRouteFn backgroundImage . fmap (CssUrl . flip renderUrl []) $ img -- | Set the @background-position@. backgroundPosition :: (Real a, Real b) => FactorLen Length a -> FactorLen Length b -> SetProp backgroundPosition = curry (setProp "background-position") -- | Set @background-repeat@. backgroundRepeat :: BackgroundRepeat -> SetProp backgroundRepeat = setProp "background-repeat" -- | Set the foreground @color@. color :: (ColourOps f, ToPropValue (f a)) => f a -> SetProp color = setProp "color" -- | Set the @font-family@ choices. fontFamily :: [FontFamily] -> SetProp fontFamily = setProp "font-family" . PropValue . Bc.intercalate "," . map (_propValueStr . toPropValue) -- | Set the @font-size@. fontSize :: (Real a) => FontSize a -> SetProp fontSize = setProp "font-size" -- | Set the @font-style@. fontStyle :: FontStyle -> SetProp fontStyle = setProp "font-style" -- | Set the @font-variant@. fontVariant :: FontVariant -> SetProp fontVariant = setProp "font-variant" -- | Set the @font-weight@. fontWeight :: FontWeight -> SetProp fontWeight = setProp "font-weight" -- | Set the @text-decoration@. textDecoration :: Maybe TextDecoration -> SetProp textDecoration = setProp "text-decoration" . maybeProp "none"