cascading-0.1.0: Data/CSS/Properties/Compat.hs
-- |
-- Module: Data.CSS.Properties.Compat
-- Copyright: (c) 2013 Ertugrul Soeylemez
-- License: BSD3
-- Maintainer: Ertugrul Soeylemez <es@ertes.de>
module Data.CSS.Properties.Compat
( -- * Vendor prefixes
vendors
)
where
import qualified Data.ByteString as B
import Control.Lens
import Control.Monad.Writer.Class
import Data.CSS.Types
-- | Adds vendor-prefixed properties for all properties in the given
-- style sheet. The following vendors are currently added:
--
-- * Microsoft (@-ms-@),
--
-- * Mozilla (@-moz-@),
--
-- * Opera (@-o-@),
--
-- * WebKit (@-webkit-@).
--
-- This combinator keeps the original (non-prefixed) property and does
-- not prefix properties that already have a vendor prefix.
vendors ::
(MonadWriter CSS m)
=> m a
-> m a
vendors =
censoring (cssProps . mapped) . concatMap $ \(Property sel (PropName name) val imp) ->
let prefix pfx = Property sel (PropName $ B.append pfx name) val imp
prefixes
| B.isPrefixOf "-" name = [""]
| otherwise = ["", "-moz-", "-ms-", "-o-", "-webkit-"]
in map prefix prefixes