clay 0.11 → 0.12
raw patch · 13 files changed
+258/−91 lines, 13 filesdep ~basedep ~hspec-expectationsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, hspec-expectations
API changes (from Hackage documentation)
- Clay.Display: instance Clay.Common.Baseline (Clay.Display.VerticalAlignValue a)
- Clay.Display: instance Clay.Display.VerticalAlign (Clay.Display.VerticalAlignValue a)
- Clay.Display: instance Clay.Property.Val (Clay.Display.VerticalAlignValue a)
- Clay.Size: data Abs
- Clay.Size: data Rel
- Clay.Size: instance GHC.Num.Num (Clay.Size.Size Clay.Size.Abs)
- Clay.Size: instance GHC.Num.Num (Clay.Size.Size Clay.Size.Rel)
- Clay.Size: instance GHC.Real.Fractional (Clay.Size.Size Clay.Size.Abs)
- Clay.Size: instance GHC.Real.Fractional (Clay.Size.Size Clay.Size.Rel)
+ Clay.Display: displayTable :: Display
+ Clay.Display: instance Clay.Common.Baseline Clay.Display.VerticalAlignValue
+ Clay.Display: instance Clay.Display.VerticalAlign Clay.Display.VerticalAlignValue
+ Clay.Display: instance Clay.Property.Val Clay.Display.VerticalAlignValue
+ Clay.Property: cssDoubleText :: Double -> Text
+ Clay.Pseudo: not :: Text -> Refinement
+ Clay.Render: [lbrace] :: Config -> Builder
+ Clay.Render: [rbrace] :: Config -> Builder
+ Clay.Render: htmlInline :: Config
+ Clay.Size: (*@) :: Double -> Size a -> Size a
+ Clay.Size: (@*) :: Size a -> Double -> Size a
+ Clay.Size: (@+@) :: Size a -> Size b -> Size (SizeCombination a b)
+ Clay.Size: (@-@) :: Size a -> Size b -> Size (SizeCombination a b)
+ Clay.Size: (@/) :: Size a -> Double -> Size a
+ Clay.Size: data LengthUnit
+ Clay.Size: data Percentage
+ Clay.Size: infixl 6 @-@
+ Clay.Size: infixl 7 @/
+ Clay.Size: instance GHC.Num.Num (Clay.Size.Size Clay.Size.LengthUnit)
+ Clay.Size: instance GHC.Num.Num (Clay.Size.Size Clay.Size.Percentage)
+ Clay.Size: instance GHC.Real.Fractional (Clay.Size.Size Clay.Size.LengthUnit)
+ Clay.Size: instance GHC.Real.Fractional (Clay.Size.Size Clay.Size.Percentage)
+ Clay.Size: instance GHC.Show.Show (Clay.Size.Size a)
+ Clay.Text: breakAll :: WordBreak
+ Clay.Text: breakWord :: OverflowWrap
+ Clay.Text: data OverflowWrap
+ Clay.Text: data TextOverflow
+ Clay.Text: data WordBreak
+ Clay.Text: instance Clay.Common.Inherit Clay.Text.OverflowWrap
+ Clay.Text: instance Clay.Common.Inherit Clay.Text.TextOverflow
+ Clay.Text: instance Clay.Common.Inherit Clay.Text.WordBreak
+ Clay.Text: instance Clay.Common.Initial Clay.Text.OverflowWrap
+ Clay.Text: instance Clay.Common.Initial Clay.Text.TextOverflow
+ Clay.Text: instance Clay.Common.Initial Clay.Text.WordBreak
+ Clay.Text: instance Clay.Common.None Clay.Text.TextOverflow
+ Clay.Text: instance Clay.Common.Normal Clay.Text.OverflowWrap
+ Clay.Text: instance Clay.Common.Normal Clay.Text.WordBreak
+ Clay.Text: instance Clay.Common.Unset Clay.Text.OverflowWrap
+ Clay.Text: instance Clay.Common.Unset Clay.Text.WordBreak
+ Clay.Text: instance Clay.Property.Val Clay.Text.OverflowWrap
+ Clay.Text: instance Clay.Property.Val Clay.Text.TextOverflow
+ Clay.Text: instance Clay.Property.Val Clay.Text.WordBreak
+ Clay.Text: keepAll :: WordBreak
+ Clay.Text: overflowClip :: TextOverflow
+ Clay.Text: overflowEllipsis :: TextOverflow
+ Clay.Text: overflowWrap :: OverflowWrap -> Css
+ Clay.Text: textOverflow :: TextOverflow -> Css
+ Clay.Text: wordBreak :: WordBreak -> Css
+ Clay.Text: wordWrap :: OverflowWrap -> Css
+ Clay.Transition: transitionTimingFunctions :: [TimingFunction] -> Css
- Clay.Border: border :: Stroke -> Size Abs -> Color -> Css
+ Clay.Border: border :: Stroke -> Size LengthUnit -> Color -> Css
- Clay.Border: borderBottom :: Stroke -> Size Abs -> Color -> Css
+ Clay.Border: borderBottom :: Stroke -> Size LengthUnit -> Color -> Css
- Clay.Border: borderBottomWidth :: Size Abs -> Css
+ Clay.Border: borderBottomWidth :: Size LengthUnit -> Css
- Clay.Border: borderLeft :: Stroke -> Size Abs -> Color -> Css
+ Clay.Border: borderLeft :: Stroke -> Size LengthUnit -> Color -> Css
- Clay.Border: borderLeftWidth :: Size Abs -> Css
+ Clay.Border: borderLeftWidth :: Size LengthUnit -> Css
- Clay.Border: borderRight :: Stroke -> Size Abs -> Color -> Css
+ Clay.Border: borderRight :: Stroke -> Size LengthUnit -> Color -> Css
- Clay.Border: borderRightWidth :: Size Abs -> Css
+ Clay.Border: borderRightWidth :: Size LengthUnit -> Css
- Clay.Border: borderTop :: Stroke -> Size Abs -> Color -> Css
+ Clay.Border: borderTop :: Stroke -> Size LengthUnit -> Color -> Css
- Clay.Border: borderTopWidth :: Size Abs -> Css
+ Clay.Border: borderTopWidth :: Size LengthUnit -> Css
- Clay.Border: borderWidth :: Size Abs -> Css
+ Clay.Border: borderWidth :: Size LengthUnit -> Css
- Clay.Border: borderWidth4 :: Size Abs -> Size Abs -> Size Abs -> Size Abs -> Css
+ Clay.Border: borderWidth4 :: Size LengthUnit -> Size LengthUnit -> Size LengthUnit -> Size LengthUnit -> Css
- Clay.Border: outline :: Stroke -> Size Abs -> Color -> Css
+ Clay.Border: outline :: Stroke -> Size LengthUnit -> Color -> Css
- Clay.Border: outlineBottom :: Stroke -> Size Abs -> Color -> Css
+ Clay.Border: outlineBottom :: Stroke -> Size LengthUnit -> Color -> Css
- Clay.Border: outlineBottomWidth :: Size Abs -> Css
+ Clay.Border: outlineBottomWidth :: Size LengthUnit -> Css
- Clay.Border: outlineLeft :: Stroke -> Size Abs -> Color -> Css
+ Clay.Border: outlineLeft :: Stroke -> Size LengthUnit -> Color -> Css
- Clay.Border: outlineLeftWidth :: Size Abs -> Css
+ Clay.Border: outlineLeftWidth :: Size LengthUnit -> Css
- Clay.Border: outlineOffset :: Size Abs -> Css
+ Clay.Border: outlineOffset :: Size LengthUnit -> Css
- Clay.Border: outlineRight :: Stroke -> Size Abs -> Color -> Css
+ Clay.Border: outlineRight :: Stroke -> Size LengthUnit -> Color -> Css
- Clay.Border: outlineRightWidth :: Size Abs -> Css
+ Clay.Border: outlineRightWidth :: Size LengthUnit -> Css
- Clay.Border: outlineTop :: Stroke -> Size Abs -> Color -> Css
+ Clay.Border: outlineTop :: Stroke -> Size LengthUnit -> Color -> Css
- Clay.Border: outlineTopWidth :: Size Abs -> Css
+ Clay.Border: outlineTopWidth :: Size LengthUnit -> Css
- Clay.Border: outlineWidth :: Size Abs -> Css
+ Clay.Border: outlineWidth :: Size LengthUnit -> Css
- Clay.Border: outlineWidth4 :: Size Abs -> Size Abs -> Size Abs -> Size Abs -> Css
+ Clay.Border: outlineWidth4 :: Size LengthUnit -> Size LengthUnit -> Size LengthUnit -> Size LengthUnit -> Css
- Clay.Display: middle :: VerticalAlignValue Value
+ Clay.Display: middle :: VerticalAlignValue
- Clay.Display: textBottom :: VerticalAlignValue Value
+ Clay.Display: textBottom :: VerticalAlignValue
- Clay.Display: textTop :: VerticalAlignValue Value
+ Clay.Display: textTop :: VerticalAlignValue
- Clay.Display: vAlignBottom :: VerticalAlignValue Value
+ Clay.Display: vAlignBottom :: VerticalAlignValue
- Clay.Display: vAlignSub :: VerticalAlignValue Value
+ Clay.Display: vAlignSub :: VerticalAlignValue
- Clay.Display: vAlignSuper :: VerticalAlignValue Value
+ Clay.Display: vAlignSuper :: VerticalAlignValue
- Clay.Display: vAlignTop :: VerticalAlignValue Value
+ Clay.Display: vAlignTop :: VerticalAlignValue
- Clay.Filter: blur :: Size Abs -> Filter
+ Clay.Filter: blur :: Size LengthUnit -> Filter
- Clay.Filter: contrast :: Size Rel -> Filter
+ Clay.Filter: contrast :: Size Percentage -> Filter
- Clay.Filter: dropShadow :: Size Abs -> Size Abs -> Size Abs -> Color -> Filter
+ Clay.Filter: dropShadow :: Size LengthUnit -> Size LengthUnit -> Size LengthUnit -> Color -> Filter
- Clay.Filter: grayscale :: Size Rel -> Filter
+ Clay.Filter: grayscale :: Size Percentage -> Filter
- Clay.Filter: invert :: Size Rel -> Filter
+ Clay.Filter: invert :: Size Percentage -> Filter
- Clay.Filter: opacity :: Size Rel -> Filter
+ Clay.Filter: opacity :: Size Percentage -> Filter
- Clay.Filter: saturate :: Size Rel -> Filter
+ Clay.Filter: saturate :: Size Percentage -> Filter
- Clay.Filter: sepia :: Size Rel -> Filter
+ Clay.Filter: sepia :: Size Percentage -> Filter
- Clay.Gradient: circular :: Size Abs -> Radial
+ Clay.Gradient: circular :: Size LengthUnit -> Radial
- Clay.Gradient: type Ramp = [(Color, Size Rel)]
+ Clay.Gradient: type Ramp = [(Color, Size Percentage)]
- Clay.Media: deviceHeight :: Size Abs -> Feature
+ Clay.Media: deviceHeight :: Size LengthUnit -> Feature
- Clay.Media: deviceWidth :: Size Abs -> Feature
+ Clay.Media: deviceWidth :: Size LengthUnit -> Feature
- Clay.Media: height :: Size Abs -> Feature
+ Clay.Media: height :: Size LengthUnit -> Feature
- Clay.Media: maxDeviceHeight :: Size Abs -> Feature
+ Clay.Media: maxDeviceHeight :: Size LengthUnit -> Feature
- Clay.Media: maxDeviceWidth :: Size Abs -> Feature
+ Clay.Media: maxDeviceWidth :: Size LengthUnit -> Feature
- Clay.Media: maxHeight :: Size Abs -> Feature
+ Clay.Media: maxHeight :: Size LengthUnit -> Feature
- Clay.Media: maxWidth :: Size Abs -> Feature
+ Clay.Media: maxWidth :: Size LengthUnit -> Feature
- Clay.Media: minDeviceHeight :: Size Abs -> Feature
+ Clay.Media: minDeviceHeight :: Size LengthUnit -> Feature
- Clay.Media: minDeviceWidth :: Size Abs -> Feature
+ Clay.Media: minDeviceWidth :: Size LengthUnit -> Feature
- Clay.Media: minHeight :: Size Abs -> Feature
+ Clay.Media: minHeight :: Size LengthUnit -> Feature
- Clay.Media: minWidth :: Size Abs -> Feature
+ Clay.Media: minWidth :: Size LengthUnit -> Feature
- Clay.Media: width :: Size Abs -> Feature
+ Clay.Media: width :: Size LengthUnit -> Feature
- Clay.Render: Config :: Builder -> Builder -> Builder -> Bool -> Bool -> Bool -> Bool -> Config
+ Clay.Render: Config :: Builder -> Builder -> Builder -> Builder -> Builder -> Bool -> Bool -> Bool -> Bool -> Config
- Clay.Size: cm :: Double -> Size Abs
+ Clay.Size: cm :: Double -> Size LengthUnit
- Clay.Size: em :: Double -> Size Rel
+ Clay.Size: em :: Double -> Size LengthUnit
- Clay.Size: ex :: Double -> Size Rel
+ Clay.Size: ex :: Double -> Size LengthUnit
- Clay.Size: inches :: Double -> Size Abs
+ Clay.Size: inches :: Double -> Size LengthUnit
- Clay.Size: mm :: Double -> Size Abs
+ Clay.Size: mm :: Double -> Size LengthUnit
- Clay.Size: pc :: Double -> Size Abs
+ Clay.Size: pc :: Double -> Size LengthUnit
- Clay.Size: pct :: Double -> Size Rel
+ Clay.Size: pct :: Double -> Size Percentage
- Clay.Size: pt :: Double -> Size Abs
+ Clay.Size: pt :: Double -> Size LengthUnit
- Clay.Size: px :: Double -> Size Abs
+ Clay.Size: px :: Double -> Size LengthUnit
- Clay.Size: rem :: Double -> Size Rel
+ Clay.Size: rem :: Double -> Size LengthUnit
- Clay.Size: vh :: Double -> Size Rel
+ Clay.Size: vh :: Double -> Size LengthUnit
- Clay.Size: vmax :: Double -> Size Rel
+ Clay.Size: vmax :: Double -> Size LengthUnit
- Clay.Size: vmin :: Double -> Size Rel
+ Clay.Size: vmin :: Double -> Size LengthUnit
- Clay.Size: vw :: Double -> Size Rel
+ Clay.Size: vw :: Double -> Size LengthUnit
- Clay.Transform: translate :: Size Abs -> Size Abs -> Transformation
+ Clay.Transform: translate :: Size a -> Size b -> Transformation
- Clay.Transform: translate3d :: Size Abs -> Size Abs -> Size Abs -> Transformation
+ Clay.Transform: translate3d :: Size a -> Size b -> Size LengthUnit -> Transformation
- Clay.Transform: translateX :: Size Abs -> Transformation
+ Clay.Transform: translateX :: Size LengthUnit -> Transformation
- Clay.Transform: translateY :: Size Abs -> Transformation
+ Clay.Transform: translateY :: Size LengthUnit -> Transformation
- Clay.Transform: translateZ :: Size Abs -> Transformation
+ Clay.Transform: translateZ :: Size LengthUnit -> Transformation
Files
- clay.cabal +2/−10
- src/Clay/Border.hs +7/−7
- src/Clay/Display.hs +9/−6
- src/Clay/Filter.hs +8/−8
- src/Clay/Gradient.hs +3/−3
- src/Clay/Media.hs +1/−1
- src/Clay/Property.hs +4/−1
- src/Clay/Pseudo.hs +2/−1
- src/Clay/Render.hs +30/−6
- src/Clay/Size.hs +112/−38
- src/Clay/Text.hs +61/−0
- src/Clay/Transform.hs +6/−5
- src/Clay/Transition.hs +13/−5
clay.cabal view
@@ -1,5 +1,5 @@ Name: clay-Version: 0.11+Version: 0.12 Synopsis: CSS preprocessor as embedded Haskell. Description: Clay is a CSS preprocessor like LESS and Sass, but implemented as an embedded@@ -10,14 +10,6 @@ The project is described on <http://fvisser.nl/clay>. . The API documentation can be found in the top level module "Clay".- .- > 0.10 -> 0.10.1- > - Expose a render function for single selectors.- > - Added super for vertical-align.- > - Added support for border-collapse.- > - Allow initial for the content property.- > - Added support for CSS import.- > Thanks to Heather, Collin J. Doering, Fraser Murray and Jonathan Fischoff. Author: Sebastiaan Visser@@ -90,6 +82,6 @@ base >= 4 && < 5, mtl >= 1 && < 2.3, text >= 0.11 && < 1.3,- hspec-expectations >= 0.7.2 && < 0.8,+ hspec-expectations >= 0.7.2 && < 0.9, hspec >= 2.2.0 && < 2.3 Ghc-Options: -Wall
src/Clay/Border.hs view
@@ -56,7 +56,7 @@ ------------------------------------------------------------------------------- -border, borderTop, borderLeft, borderBottom, borderRight :: Stroke -> Size Abs -> Color -> Css+border, borderTop, borderLeft, borderBottom, borderRight :: Stroke -> Size LengthUnit -> Color -> Css border a b c = key "border" (a ! b ! c) borderTop a b c = key "border-top" (a ! b ! c)@@ -86,10 +86,10 @@ borderTopStyle = key "border-top-style" borderBottomStyle = key "border-bottom-style" -borderWidth4 :: Size Abs -> Size Abs -> Size Abs -> Size Abs -> Css+borderWidth4 :: Size LengthUnit -> Size LengthUnit -> Size LengthUnit -> Size LengthUnit -> Css borderWidth4 a b c d = key "border-width" (a ! b ! c ! d) -borderWidth, borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth :: Size Abs -> Css+borderWidth, borderLeftWidth, borderRightWidth, borderTopWidth, borderBottomWidth :: Size LengthUnit -> Css borderWidth = key "border-width" borderLeftWidth = key "border-left-width"@@ -99,7 +99,7 @@ ------------------------------------------------------------------------------- -outline, outlineTop, outlineLeft, outlineBottom, outlineRight :: Stroke -> Size Abs -> Color -> Css+outline, outlineTop, outlineLeft, outlineBottom, outlineRight :: Stroke -> Size LengthUnit -> Color -> Css outline a b c = key "outline" (a ! b ! c) outlineTop a b c = key "outline-top" (a ! b ! c)@@ -129,10 +129,10 @@ outlineTopStyle = key "outline-top-style" outlineBottomStyle = key "outline-bottom-style" -outlineWidth4 :: Size Abs -> Size Abs -> Size Abs -> Size Abs -> Css+outlineWidth4 :: Size LengthUnit -> Size LengthUnit -> Size LengthUnit -> Size LengthUnit -> Css outlineWidth4 a b c d = key "outline-width" (a ! b ! c ! d) -outlineWidth, outlineLeftWidth, outlineRightWidth, outlineTopWidth, outlineBottomWidth :: Size Abs -> Css+outlineWidth, outlineLeftWidth, outlineRightWidth, outlineTopWidth, outlineBottomWidth :: Size LengthUnit -> Css outlineWidth = key "outline-width" outlineLeftWidth = key "outline-left-width"@@ -140,7 +140,7 @@ outlineTopWidth = key "outline-top-width" outlineBottomWidth = key "outline-bottom-width" -outlineOffset :: Size Abs -> Css+outlineOffset :: Size LengthUnit -> Css outlineOffset = key "outline-offset" -------------------------------------------------------------------------------
src/Clay/Display.hs view
@@ -23,7 +23,7 @@ , Display , display-, inline, block, listItem, runIn, inlineBlock, table, inlineTable, tableRowGroup+, inline, block, listItem, runIn, inlineBlock, table, displayTable, inlineTable, tableRowGroup , tableHeaderGroup, tableFooterGroup, tableRow, tableColumnGroup, tableColumn , tableCell, tableCaption, displayNone, displayInherit, flex , inlineFlex, grid, inlineGrid@@ -131,7 +131,7 @@ newtype Display = Display Value deriving (Val, Other, None, Inherit) -inline, block, listItem, runIn, inlineBlock, table, inlineTable, tableRowGroup,+inline, block, listItem, runIn, inlineBlock, table, displayTable, inlineTable, tableRowGroup, tableHeaderGroup, tableFooterGroup, tableRow, tableColumnGroup, tableColumn, tableCell, tableCaption, displayNone, displayInherit, flex, inlineFlex, grid, inlineGrid :: Display@@ -141,6 +141,8 @@ listItem = Display "list-item" runIn = Display "runIn" inlineBlock = Display "inline-block"+displayTable = Display "table"+{-# DEPRECATED table "Use `displayTable` instead." #-} table = Display "table" inlineTable = Display "inline-table" tableRowGroup = Display "table-row-Group"@@ -232,15 +234,16 @@ verticalAlign :: a -> Css verticalAlign = key "vertical-align" -newtype VerticalAlignValue a = VerticalAlignValue Value deriving (Val, Baseline)+newtype VerticalAlignValue = VerticalAlignValue Value deriving (Val, Baseline) -instance VerticalAlign (VerticalAlignValue a)+instance VerticalAlign VerticalAlignValue instance VerticalAlign (Size a) -middle,vAlignSub,vAlignSuper,textTop,textBottom,vAlignTop,vAlignBottom :: VerticalAlignValue Value+middle,vAlignSub,vAlignSuper,textTop,textBottom,vAlignTop,vAlignBottom,vAlignBaseline :: VerticalAlignValue middle = VerticalAlignValue "middle" vAlignSub = VerticalAlignValue "sub"+vAlignBaseline = baseline vAlignSuper = VerticalAlignValue "super" textTop = VerticalAlignValue "text-top" textBottom = VerticalAlignValue "text-bottom"@@ -260,7 +263,7 @@ crosshair,cursorDefault,pointer,move,eResize,neResize,nwResize,nResize,seResize,swResize,sResize,wResize,cursorText,wait,cursorProgress,help :: CursorValue Value crosshair = CursorValue "crosshair"-cursorDefault = CursorValue "cursorDefault"+cursorDefault = CursorValue "default" pointer = CursorValue "pointer" move = CursorValue "move" eResize = CursorValue "e-resize"
src/Clay/Filter.hs view
@@ -49,33 +49,33 @@ url :: Text -> Filter url u = Filter ("url(" <> value u <> ")") -blur :: Size Abs -> Filter+blur :: Size LengthUnit -> Filter blur i = Filter ("blur(" <> value i <> ")") brightness :: Double -> Filter brightness i = Filter ("brightness(" <> value i <> ")") -contrast :: Size Rel -> Filter+contrast :: Size Percentage -> Filter contrast i = Filter ("contrast(" <> value i <> ")") -dropShadow :: Size Abs -> Size Abs -> Size Abs -> Color -> Filter+dropShadow :: Size LengthUnit -> Size LengthUnit -> Size LengthUnit -> Color -> Filter dropShadow x y s c = Filter ("drop-shadow(" <> value (x ! y ! s ! c) <> ")") -grayscale :: Size Rel -> Filter+grayscale :: Size Percentage -> Filter grayscale g = Filter ("grayscale(" <> value g <> ")") hueRotate :: Angle a -> Filter hueRotate h = Filter ("hue-rotate(" <> value h <> ")") -invert :: Size Rel -> Filter+invert :: Size Percentage -> Filter invert i = Filter ("invert(" <> value i <> ")") -opacity :: Size Rel -> Filter+opacity :: Size Percentage -> Filter opacity i = Filter ("opacity(" <> value i <> ")") -saturate :: Size Rel -> Filter+saturate :: Size Percentage -> Filter saturate i = Filter ("saturate(" <> value i <> ")") -sepia :: Size Rel -> Filter+sepia :: Size Percentage -> Filter sepia i = Filter ("sepia(" <> value i <> ")")
src/Clay/Gradient.hs view
@@ -44,7 +44,7 @@ import Clay.Size import Clay.Background -type Ramp = [(Color, Size Rel)]+type Ramp = [(Color, Size Percentage)] ------------------------------------------------------------------------------- @@ -81,7 +81,7 @@ ellipse :: Extend -> Radial ellipse ext = Radial ("ellipse " <> value ext) -circular :: Size Abs -> Radial+circular :: Size LengthUnit -> Radial circular radius = Radial (value (radius, radius)) elliptical :: Size a -> Size a -> Radial@@ -115,5 +115,5 @@ ramp xs = value (map (\(a, b) -> value (value a, value b)) xs) shortcut :: (Ramp -> BackgroundImage) -> Color -> Color -> BackgroundImage-shortcut g f t = g [(f, 0), (t, 100)]+shortcut g f t = g [(f, (pct 0)), (t, (pct 100))]
src/Clay/Media.hs view
@@ -72,7 +72,7 @@ width, minWidth, maxWidth, height, minHeight, maxHeight, deviceWidth , minDeviceWidth, maxDeviceWidth, deviceHeight, minDeviceHeight- , maxDeviceHeight :: Size Abs -> Feature+ , maxDeviceHeight :: Size LengthUnit -> Feature width = with "width" minWidth = with "min-width"
src/Clay/Property.hs view
@@ -69,7 +69,10 @@ instance HasResolution E5 where resolution _ = 100000 instance Val Double where- value = fromString . showFixed' . realToFrac+ value = Value . Plain . cssDoubleText++cssDoubleText :: Double -> Text+cssDoubleText = fromString . showFixed' . realToFrac where showFixed' :: Fixed E5 -> String showFixed' = showFixed True
src/Clay/Pseudo.hs view
@@ -53,10 +53,11 @@ target = ":target" valid = ":valid" -lang, nthChild, nthLastChild, nthLastOfType, nthOfType :: Text -> Refinement+lang, nthChild, nthLastChild, nthLastOfType, nthOfType, not :: Text -> Refinement lang n = func "lang" [n] nthChild n = func "nth-child" [n] nthLastChild n = func "nth-last-child" [n] nthLastOfType n = func "nth-last-of-type" [n] nthOfType n = func "nth-of-type" [n]+not n = func "not" [n]
src/Clay/Render.hs view
@@ -4,6 +4,7 @@ , pretty , compact , render+, htmlInline , putCss , renderWith , renderSelector@@ -36,6 +37,8 @@ { indentation :: Builder , newline :: Builder , sep :: Builder+ , lbrace :: Builder+ , rbrace :: Builder , finalSemicolon :: Bool , warn :: Bool , align :: Bool@@ -49,6 +52,8 @@ { indentation = " " , newline = "\n" , sep = " "+ , lbrace = "{"+ , rbrace = "}" , finalSemicolon = True , warn = True , align = True@@ -62,12 +67,29 @@ { indentation = "" , newline = "" , sep = ""+ , lbrace = "{"+ , rbrace = "}" , finalSemicolon = False , warn = False , align = False , banner = False } +-- | Configuration to print to a compacted unreadable CSS output for embedding inline with HTML.++htmlInline :: Config+htmlInline = Config+ { indentation = ""+ , newline = ""+ , sep = ""+ , lbrace = ""+ , rbrace = ""+ , finalSemicolon = False+ , warn = False+ , align = False+ , banner = False+ }+ -- | Render to CSS using the default configuration (`pretty`) and directly -- print to the standard output. @@ -110,10 +132,10 @@ mconcat [ "@" <> fromText browser <> "keyframes " , fromText ident , newline cfg- , "{"+ , lbrace cfg , newline cfg , foldMap (frame cfg) xs- , "}"+ , rbrace cfg , newline cfg , newline cfg ]@@ -133,10 +155,10 @@ mconcat [ mediaQuery q , newline cfg- , "{"+ , lbrace cfg , newline cfg , rules cfg sel rs- , "}"+ , rbrace cfg , newline cfg ] @@ -206,10 +228,10 @@ in mconcat [ selector cfg (merger sel) , newline cfg- , "{"+ , lbrace cfg , newline cfg , properties cfg xs- , "}"+ , rbrace cfg , newline cfg ] @@ -250,6 +272,8 @@ in mconcat [ind, fromText k, pad, ":", sep cfg, fromText v] selector :: Config -> Selector -> Builder+selector Config { lbrace = "", rbrace = "" } = rec+ where rec _ = "" selector cfg = intersperse ("," <> newline cfg) . rec where rec (In (SelectorF (Refinement ft) p)) = (<> foldMap predicate (sort ft)) <$> case p of
src/Clay/Size.hs view
@@ -3,14 +3,17 @@ , OverloadedStrings , GeneralizedNewtypeDeriving , FlexibleInstances+ , ExistentialQuantification+ , StandaloneDeriving+ , TypeFamilies #-} module Clay.Size ( -- * Size type. Size-, Abs-, Rel+, LengthUnit+, Percentage , nil , unitless @@ -31,6 +34,14 @@ , vmin , vmax +-- * Calculation operators for calc++, (@+@)+, (@-@)+, (@*)+, (*@)+, (@/)+ -- * Shorthands for properties that can be applied separately to each box side. , sym@@ -57,6 +68,7 @@ import Data.Monoid import Prelude hiding (rem)+import Data.Text (Text) import Clay.Common import Clay.Property@@ -64,70 +76,100 @@ ------------------------------------------------------------------------------- --- | Sizes can be relative like percentages or rems.-data Rel+-- | Sizes can be given using a length unit (e.g. em, px).+data LengthUnit --- | Sizes can be absolute like pixels, points, etc.-data Abs+-- | Sizes can be given in percentages.+data Percentage -newtype Size a = Size Value- deriving (Val, Auto, Normal, Inherit, None, Other)+-- | When combining percentages with units using calc, we get a combination+data Combination +data Size a =+ SimpleSize Text |+ forall b c. SumSize (Size b) (Size c) |+ forall b c. DiffSize (Size b) (Size c) |+ MultSize Double (Size a) |+ DivSize Double (Size a) |+ OtherSize Value++deriving instance Show (Size a)++sizeToText :: Size a -> Text+sizeToText (SimpleSize txt) = txt+sizeToText (SumSize a b) = mconcat ["(", sizeToText a, " + ", sizeToText b, ")"]+sizeToText (DiffSize a b) = mconcat ["(", sizeToText a, " - ", sizeToText b, ")"]+sizeToText (MultSize a b) = mconcat ["(", cssDoubleText a, " * ", sizeToText b, ")"]+sizeToText (DivSize a b) = mconcat ["(", sizeToText b, " / ", cssDoubleText a, ")"]+sizeToText (OtherSize a) = plain $ unValue a++instance Val (Size a) where+ value (SimpleSize a) = value a+ value (OtherSize a) = a+ value s = Value $ browsers <> Plain ("calc" <> sizeToText s)++instance Auto (Size a) where auto = Clay.Common.auto+instance Normal (Size a) where normal = Clay.Common.normal+instance Inherit (Size a) where inherit = Clay.Common.inherit+instance None (Size a) where none = Clay.Common.none+instance Other (Size a) where other a = OtherSize a+ -- | Zero size. nil :: Size a-nil = Size "0"+nil = SimpleSize "0" -- | Unitless size (as recommended for line-height). unitless :: Double -> Size a-unitless i = Size (value i)+unitless i = SimpleSize ((plain . unValue . value) i) -cm, mm, inches, px, pt, pc :: Double -> Size Abs+cm, mm, inches, px, pt, pc :: Double -> Size LengthUnit -- | Size in centimeters.-cm i = Size (value i <> "cm")+cm i = SimpleSize (cssDoubleText i <> "cm") -- | Size in millimeters.-mm i = Size (value i <> "mm")+mm i = SimpleSize (cssDoubleText i <> "mm") -- | Size in inches (1in = 2.54 cm).-inches i = Size (value i <> "in")+inches i = SimpleSize (cssDoubleText i <> "in") -- | Size in pixels.-px i = Size (value i <> "px")+px i = SimpleSize (cssDoubleText i <> "px") -- | Size in points (1pt = 1/72 of 1in).-pt i = Size (value i <> "pt")+pt i = SimpleSize (cssDoubleText i <> "pt") -- | Size in picas (1pc = 12pt).-pc i = Size (value i <> "pc")+pc i = SimpleSize (cssDoubleText i <> "pc") -em, ex, pct, rem, vw, vh, vmin, vmax :: Double -> Size Rel+em, ex, rem, vw, vh, vmin, vmax :: Double -> Size LengthUnit --- | Size in em's (computed value of the font-size).-em i = Size (value i <> "em")+-- | Size in em's (computed cssDoubleText of the font-size).+em i = SimpleSize (cssDoubleText i <> "em") --- | Size in ex'es (x-height of the first avaliable font).-ex i = Size (value i <> "ex")+-- | SimpleSize in ex'es (x-height of the first avaliable font).+ex i = SimpleSize (cssDoubleText i <> "ex") --- | Size in percents.-pct i = Size (value i <> "%")+-- | SimpleSize in rem's (em's, but always relative to the root element).+rem i = SimpleSize (cssDoubleText i <> "rem") --- | Size in rem's (em's, but always relative to the root element).-rem i = Size (value i <> "rem")+-- | SimpleSize in vw's (1vw = 1% of viewport width).+vw i = SimpleSize (cssDoubleText i <> "vw") --- | Size in vw's (1vw = 1% of viewport width).-vw i = Size (value i <> "vw")+-- | SimpleSize in vh's (1vh = 1% of viewport height).+vh i = SimpleSize (cssDoubleText i <> "vh") --- | Size in vh's (1vh = 1% of viewport height).-vh i = Size (value i <> "vh")+-- | SimpleSize in vmin's (the smaller of vw or vh).+vmin i = SimpleSize (cssDoubleText i <> "vmin") --- | Size in vmin's (the smaller of vw or vh).-vmin i = Size (value i <> "vmin")+-- | SimpleSize in vmax's (the larger of vw or vh).+vmax i = SimpleSize (cssDoubleText i <> "vmax") --- | Size in vmax's (the larger of vw or vh).-vmax i = Size (value i <> "vmax")+-- | SimpleSize in percents.+pct :: Double -> Size Percentage+pct i = SimpleSize (cssDoubleText i <> "%") -instance Num (Size Abs) where+instance Num (Size LengthUnit) where fromInteger = px . fromInteger (+) = error "plus not implemented for Size" (*) = error "times not implemented for Size"@@ -135,11 +177,11 @@ signum = error "signum not implemented for Size" negate = error "negate not implemented for Size" -instance Fractional (Size Abs) where+instance Fractional (Size LengthUnit) where fromRational = px . fromRational recip = error "recip not implemented for Size" -instance Num (Size Rel) where+instance Num (Size Percentage) where fromInteger = pct . fromInteger (+) = error "plus not implemented for Size" (*) = error "times not implemented for Size"@@ -147,9 +189,41 @@ signum = error "signum not implemented for Size" negate = error "negate not implemented for Size" -instance Fractional (Size Rel) where+instance Fractional (Size Percentage) where fromRational = pct . fromRational recip = error "recip not implemented for Size"++-- | Type family to define what is the result of a calc operation++type family SizeCombination sa sb where+ SizeCombination Percentage Percentage = Percentage+ SizeCombination LengthUnit LengthUnit = LengthUnit+ SizeCombination a b = Combination++-- | Plus operator to combine sizes into calc function+infixl 6 @+@+(@+@) :: Size a -> Size b -> Size (SizeCombination a b)+a @+@ b = SumSize a b++-- | Minus operator to combine sizes into calc function+infixl 6 @-@+(@-@) :: Size a -> Size b -> Size (SizeCombination a b)+a @-@ b = DiffSize a b++-- | Times operator to combine sizes into calc function+infixl 7 *@+(*@) :: Double -> Size a -> Size a+a *@ b = MultSize a b++-- | Reversed times operator to combine sizes into calc function+infixl 7 @*+(@*) :: Size a -> Double -> Size a+a @* b = MultSize b a++-- | Division operator to combine sizes into calc function+infixl 7 @/+(@/) :: Size a -> Double -> Size a+a @/ b = DivSize b a -------------------------------------------------------------------------------
src/Clay/Text.hs view
@@ -59,6 +59,26 @@ , textTransform , capitalize, uppercase, lowercase, fullWidth +-- * Text-overflow.++, TextOverflow+, textOverflow+, overflowClip, overflowEllipsis++-- * Word-break.++, WordBreak+, wordBreak+, breakAll+, keepAll+ +-- * Overflow-wrap (and Word-wrap).++, OverflowWrap+, overflowWrap+, wordWrap+, breakWord+ -- * Content. , Content@@ -216,6 +236,47 @@ textTransform :: TextTransform -> Css textTransform = key "text-transform"++-------------------------------------------------------------------------------++newtype WordBreak = WordBreak Value+ deriving (Val, Inherit, Initial, Unset, Normal)++breakAll, keepAll :: WordBreak++breakAll = WordBreak "break-all"+keepAll = WordBreak "keep-all"++wordBreak :: WordBreak -> Css++wordBreak = key "word-break"++-------------------------------------------------------------------------------++newtype OverflowWrap = OverflowWrap Value+ deriving (Val, Inherit, Initial, Unset, Normal)++breakWord :: OverflowWrap++breakWord = OverflowWrap "break-word"++overflowWrap, wordWrap :: OverflowWrap -> Css++wordWrap = key "word-wrap"+overflowWrap = key "overflow-wrap"++-------------------------------------------------------------------------------++newtype TextOverflow = TextOverflow Value+ deriving (Val, None, Inherit, Initial)++overflowClip, overflowEllipsis :: TextOverflow++overflowClip = TextOverflow "clip"+overflowEllipsis = TextOverflow "ellipsis"++textOverflow :: TextOverflow -> Css+textOverflow = key "text-overflow" -------------------------------------------------------------------------------
src/Clay/Transform.hs view
@@ -86,17 +86,18 @@ ------------------------------------------------------------------------------- -translate :: Size Abs -> Size Abs -> Transformation-translate x y = Transformation ("translate(" <> value [x, y] <> ")")+translate :: Size a -> Size b -> Transformation+translate x y = Transformation ("translate(" <> value [value x, value y] <> ")") -translateX, translateY, translateZ :: Size Abs -> Transformation+translateX, translateY :: Size LengthUnit -> Transformation+translateZ :: Size LengthUnit -> Transformation translateX x = Transformation ("translateX(" <> value x <> ")") translateY y = Transformation ("translateY(" <> value y <> ")") translateZ z = Transformation ("translateZ(" <> value z <> ")") -translate3d :: Size Abs -> Size Abs -> Size Abs -> Transformation-translate3d x y z = Transformation ("translate3d(" <> value [x, y, z] <> ")")+translate3d :: Size a -> Size b -> Size LengthUnit -> Transformation+translate3d x y z = Transformation ("translate3d(" <> value [value x, value y, value z] <> ")") -------------------------------------------------------------------------------
src/Clay/Transition.hs view
@@ -24,6 +24,7 @@ , TimingFunction , transitionTimingFunction+, transitionTimingFunctions , ease, easeIn, easeOut, easeInOut, linear, stepStart, stepStop , stepsStart, stepsStop , cubicBezier@@ -47,8 +48,9 @@ transition p d f e = prefixed (browsers <> "transition") (p ! d ! f ! e) transitions :: [(Text, Time, TimingFunction, Time)] -> Css-transitions = prefixed (browsers <> "transition")- . map (\(p, d, f, e) -> value (p ! d ! f ! e))+transitions [] = key "transition" (none :: Value)+transitions x = prefixed (browsers <> "transition")+ $ map (\(p, d, f, e) -> value (p ! d ! f ! e)) x ------------------------------------------------------------------------------- @@ -56,15 +58,17 @@ transitionProperty = key "transition-property" transitionProperties :: [Text] -> Css-transitionProperties = key "transition-property"+transitionProperties [] = key "transition-property" (none :: Value)+transitionProperties x = key "transition-property" x ------------------------------------------------------------------------------- transitionDuration :: Time -> Css transitionDuration = key "transition-duration" -transitionDurations :: [Time] -> Css-transitionDurations = key "transition-duration"+transitionDurations :: [Time] -> Css +transitionDurations [] = key "transition-duration" (none :: Value)+transitionDurations x = key "transition-duration" x ------------------------------------------------------------------------------- @@ -91,6 +95,10 @@ transitionTimingFunction :: TimingFunction -> Css transitionTimingFunction = key "transition-timing-function"++transitionTimingFunctions :: [TimingFunction] -> Css+transitionTimingFunctions [] = key "transition-timing-function" (none :: Value)+transitionTimingFunctions x = key "transition-timing-function" x -------------------------------------------------------------------------------