-- |
-- Module:     Data.CSS.Properties.UI
-- Copyright:  (c) 2013 Ertugrul Soeylemez
-- License:    BSD3
-- Maintainer: Ertugrul Soeylemez <es@ertes.de>

module Data.CSS.Properties.UI
    ( -- * Cursor
      cursor,
      cursorUrl,

      -- * Outlines
      outline,
      outlineColor,
      outlineStyle,
      outlineWidth
    )
    where

import Data.Colour
import Data.CSS.Build
import Data.CSS.Properties.Types
import Data.CSS.Properties.Utils
import Data.CSS.Types
import Data.Text (Text)
import Web.Routes.RouteT


-- | Set the @cursor@ to the specified value or @auto@.

cursor :: Maybe (Cursor (CssUrl Text)) -> SetProp
cursor = setProp "cursor" . maybeProp "auto"


-- | Set the @cursor@ to the specified value or @auto@.

cursorUrl :: (MonadRoute m) => Maybe (Cursor (URL m)) -> SetPropM m
cursorUrl c = do
    renderUrl <- askRouteFn
    cursor . fmap (fmap (CssUrl . flip renderUrl [])) $ c


-- | Set the @outline@ properties.

outline ::
    (ColourOps f, Real b, ToPropValue (f a))
    => Maybe (f a)    -- ^ Color or @invert@.
    -> BorderStyle    -- ^ Outline style.
    -> BorderWidth b  -- ^ Outline width.
    -> SetProp
outline col style w = setProp "outline" (maybeProp "invert" col, style, w)


-- | Set the @outline-color@ to the given color or @invert@.

outlineColor :: (ColourOps f, ToPropValue (f a)) => Maybe (f a) -> SetProp
outlineColor = setProp "outline-color" . maybeProp "invert"


-- | Set the @outline-style@.

outlineStyle :: BorderStyle -> SetProp
outlineStyle = setProp "outline-style"


-- | Set the @outline-width@.

outlineWidth :: (Real a) => BorderWidth a -> SetProp
outlineWidth = setProp "outline-width"