packages feed

clay 0.13.3 → 0.14.0

raw patch · 26 files changed

+218/−57 lines, 26 filesdep ~basedep ~hspecdep ~hspec-discoverPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, hspec, hspec-discover, mtl, text

API changes (from Hackage documentation)

- Clay.Display: instance Clay.Common.Auto Clay.Display.Visibility
- Clay.List: instance Clay.Common.None Clay.List.ListStylePosition
+ Clay: (|~) :: Selector -> Selector -> Selector
+ Clay: class SpaceEvenly a
+ Clay: spaceEvenly :: SpaceEvenly a => a
+ Clay: textAlignLast :: TextAlign -> Css
+ Clay.Color: infixl 6 -.
+ Clay.Color: infixl 7 *.
+ Clay.Common: emptyPrefix :: (Text, Text)
+ Clay.Common: webkit :: Prefixed
+ Clay.Common: webkitPrefix :: (Text, Text)
+ Clay.Display: instance Clay.Common.Unset Clay.Display.Visibility
+ Clay.Flexbox: class SpaceEvenly a
+ Clay.Flexbox: instance Clay.Flexbox.SpaceEvenly Clay.Flexbox.AlignContentValue
+ Clay.Flexbox: instance Clay.Flexbox.SpaceEvenly Clay.Flexbox.JustifyContentValue
+ Clay.Flexbox: instance Clay.Flexbox.SpaceEvenly Clay.Property.Value
+ Clay.Flexbox: spaceEvenly :: SpaceEvenly a => a
+ Clay.Grid: gridGap :: Size a -> Css
+ Clay.Grid: gridTemplateColumns :: [Size a] -> Css
+ Clay.Selector: (|~) :: Selector -> Selector -> Selector
+ Clay.Selector: Sibling :: f -> f -> Path f
+ Clay.Size: available :: Size LengthUnit
+ Clay.Size: fitContent :: Size LengthUnit
+ Clay.Size: fr :: Double -> Size LengthUnit
+ Clay.Size: maxContent :: Size LengthUnit
+ Clay.Size: minContent :: Size LengthUnit
+ Clay.Text: textAlignLast :: TextAlign -> Css
+ Clay.Transform: data TransformBox
+ Clay.Transform: data TransformStyle
+ Clay.Transform: fillBox :: TransformBox
+ Clay.Transform: flat :: TransformStyle
+ Clay.Transform: instance Clay.Common.Inherit Clay.Transform.TransformBox
+ Clay.Transform: instance Clay.Common.Inherit Clay.Transform.TransformStyle
+ Clay.Transform: instance Clay.Common.Initial Clay.Transform.TransformBox
+ Clay.Transform: instance Clay.Common.Initial Clay.Transform.TransformStyle
+ Clay.Transform: instance Clay.Common.Unset Clay.Transform.TransformBox
+ Clay.Transform: instance Clay.Common.Unset Clay.Transform.TransformStyle
+ Clay.Transform: instance Clay.Property.Val Clay.Transform.TransformBox
+ Clay.Transform: instance Clay.Property.Val Clay.Transform.TransformStyle
+ Clay.Transform: preserve3d :: TransformStyle
+ Clay.Transform: strokeBox :: TransformBox
+ Clay.Transform: transformBorderBox :: TransformBox
+ Clay.Transform: transformBox :: TransformBox -> Css
+ Clay.Transform: transformContentBox :: TransformBox
+ Clay.Transform: transformOrigin :: [Size a] -> Css
+ Clay.Transform: transformStyle :: TransformStyle -> Css
+ Clay.Transform: viewBox :: TransformBox
- Clay.Border: border :: Stroke -> Size LengthUnit -> Color -> Css
+ Clay.Border: border :: Size LengthUnit -> Stroke -> Color -> Css
- Clay.Border: borderBottom :: Stroke -> Size LengthUnit -> Color -> Css
+ Clay.Border: borderBottom :: Size LengthUnit -> Stroke -> Color -> Css
- Clay.Border: borderLeft :: Stroke -> Size LengthUnit -> Color -> Css
+ Clay.Border: borderLeft :: Size LengthUnit -> Stroke -> Color -> Css
- Clay.Border: borderRight :: Stroke -> Size LengthUnit -> Color -> Css
+ Clay.Border: borderRight :: Size LengthUnit -> Stroke -> Color -> Css
- Clay.Border: borderTop :: Stroke -> Size LengthUnit -> Color -> Css
+ Clay.Border: borderTop :: Size LengthUnit -> Stroke -> Color -> Css

Files

CHANGELOG view
@@ -1,5 +1,13 @@ CHANGELOG +  0.14.0:+    - Drop support for GHC 8.2+    - Added `text-align-last`+    - Fix typo in `stepsStart`+    - Added clay-examples+    - Fix `cubicBezier` and other issues+    Thanks to Vasiliy Yorkin, Florian Grignon, Nick Saunders, David Fox, Ben Sima, Murakami Kennzo, Owen Shepherd, Anton Gushcha, Temur Saidkhodjaev, Rob Bassi, Alex Sayers, and further contributors.+   0.13.3:     - Improve README     - Relax types for `sym2` and `sym3` combinators@@ -129,4 +137,3 @@     - Refinements applied to the top level magically introduce star selector.     Thanks to listx, bergmark, Cynede, chrisdone, Primigenus, Sigrlami for the     pull requests and bug reports.-
CONTRIBUTING.md view
@@ -16,11 +16,11 @@ GHC_VERSION=ghc881 nix-build ``` -To find out which GHC versions your nix setup provides:+To find out which GHC versions our nix setup provides:  ```-$ nix eval '(builtins.attrNames ((import <nixpkgs> {}).haskell.compiler))'-[ "ghc822Binary" "ghc844" "ghc863Binary" "ghc865" "ghc881" "ghcHEAD" "ghcjs" "ghcjs86" "integer-simple" ]+$ nix eval '(builtins.attrNames (import (builtins.fetchTarball (import ./nix/nixpkgs.nix)) {}).haskell.compiler)'+[ "ghc8102Binary" "ghc8102BinaryMinimal" "ghc8104" "ghc865Binary" "ghc884" "ghc901" "ghcHEAD" "integer-simple" "native-bignum" ] ```  # Building your pull request@@ -41,3 +41,13 @@  If you fix an important bug or contribute a new feature, consider adding a line to `CHANGELOG` describing what you have changed.++# Running tests locally++Tests will be run with the above `nix-build` calls, but if you want to run them+without doing a full nix build, you can do so with cabal:++```+nix-shell+cabal test+```
clay.cabal view
@@ -1,5 +1,5 @@ Name:     clay-Version:  0.13.3+Version:  0.14.0 Synopsis: CSS preprocessor as embedded Haskell. Description:   Clay is a CSS preprocessor like LESS and Sass, but implemented as an embedded@@ -20,17 +20,18 @@ License:       BSD3 License-File:  LICENSE Category:      Web, Graphics-Cabal-Version: >= 1.8+Cabal-Version: >= 1.10 Build-Type:    Simple  Extra-Source-Files:   README.md CHANGELOG CONTRIBUTING.md  Tested-With:-  GHC==8.2.2,   GHC==8.4.4,   GHC==8.6.5,-  GHC==8.8.1+  GHC==8.8.4,+  GHC==8.10.7,+  GHC==9.0.2  Source-Repository head   Type:     git@@ -58,6 +59,7 @@     Clay.FontFace     Clay.Geometry     Clay.Gradient+    Clay.Grid     Clay.List     Clay.Media     Clay.Mask@@ -73,19 +75,22 @@     Clay.Transition    Build-Depends:-    base  >= 4.10 && < 5,-    mtl   >= 1    && < 2.3,-    text  >= 0.11 && < 1.3+    base  >= 4.11 && < 4.16,+    mtl   >= 1,+    text  >= 0.11   GHC-Options: -Wall -Wcompat+  Default-Language: Haskell2010  Test-Suite Test-Clay   Type: exitcode-stdio-1.0   HS-Source-Dirs: spec, src+  Build-Tools: hspec-discover   main-is: Spec.hs   Build-Depends:-    base                 >= 4.10  && < 5,-    mtl                  >= 1     && < 2.3,-    text                 >= 0.11  && < 1.3,-    hspec                >= 2.2.0 && < 2.8,-    hspec-discover       >= 2.2.0 && < 2.8+    base                 >= 4.11  && < 4.16,+    mtl                  >= 1,+    text                 >= 0.11,+    hspec                >= 2.2.0,+    hspec-discover       >= 2.2.0   GHC-Options: -Wall -Wcompat+  Default-Language: Haskell2010
src/Clay.hs view
@@ -39,6 +39,7 @@ , (|>) , (#) , (|+)+, (|~)  -- ** Refining selectors. @@ -112,6 +113,7 @@ , module Clay.FontFace , module Clay.Geometry , module Clay.Gradient+, module Clay.Grid , module Clay.List , module Clay.Text , module Clay.Transform@@ -155,6 +157,7 @@ import Clay.FontFace import Clay.Geometry import Clay.Gradient+import Clay.Grid import Clay.List import Clay.Size import Clay.Text       hiding (pre)@@ -182,6 +185,6 @@ -- grouped with the preceding value when rendered compactly. -- -- Note that /every/ generated line in the generated content will feature the--- comment. +-- comment. -- -- An empty comment generates '@/*  */@'.
src/Clay/Border.hs view
@@ -56,7 +56,7 @@  ------------------------------------------------------------------------------- -border, borderTop, borderLeft, borderBottom, borderRight :: Stroke -> Size LengthUnit -> Color -> Css+border, borderTop, borderLeft, borderBottom, borderRight :: Size LengthUnit -> Stroke -> Color -> Css  border        a b c = key "border"        (a ! b ! c) borderTop     a b c = key "border-top"    (a ! b ! c)
src/Clay/Box.hs view
@@ -20,7 +20,6 @@ ) where -import Data.Monoid import Data.List.NonEmpty (NonEmpty)  import Clay.Color@@ -82,6 +81,10 @@ -- > boxShadow . pure $ shadow (px 1) (px 1) -- -- Use with @{-# LANGUAGE OverloadedLists #-}@ for the simplest list syntax.+-- Note that sometimes when @{-# LANGUAGE OverloadedLists #-}@ is active, GHC+-- has troubles identifying what type the list should be converted to. Examples:+-- 1) "forM_ [0..10] $ \x -> ..."+-- 2) "[left, top, right, bottom] `forM_` ($ pct 4)" -- -- > boxShadow [none] -- > boxShadow [shadow (px 1) (px 1)]
src/Clay/Color.hs view
@@ -2,7 +2,6 @@ module Clay.Color where  import Data.Char (isHexDigit)-import Data.Monoid import Data.String import Text.Printf @@ -119,14 +118,17 @@ (*.) :: Color -> Integer -> Color (*.) (Rgba r g b a) i = Rgba (clamp (r * i)) (clamp (g * i)) (clamp (b * i)) a (*.) o              _ = o+infixl 7 *.  (+.) :: Color -> Integer -> Color (+.) (Rgba r g b a) i = Rgba (clamp (r + i)) (clamp (g + i)) (clamp (b + i)) a (+.) o              _ = o+infixl 6 +.  (-.) :: Color -> Integer -> Color (-.) (Rgba r g b a) i = Rgba (clamp (r - i)) (clamp (g - i)) (clamp (b - i)) a (-.) o              _ = o+infixl 6 -.  clamp :: Ord a => Num a => a -> a clamp i = max (min i (fromIntegral (255 :: Integer))) (fromIntegral (0 :: Integer))
src/Clay/Comments.hs view
@@ -3,8 +3,6 @@ {-# LANGUAGE OverloadedStrings #-} module Clay.Comments where -import Data.Foldable (foldMap)-import Data.Monoid ((<>)) import Data.Maybe (isNothing) import Data.List (partition) 
src/Clay/Common.hs view
@@ -9,9 +9,9 @@  module Clay.Common where +import Data.Text (Text) import Clay.Property import Data.String (IsString)-import Data.Monoid (Monoid, (<>))  ------------------------------------------------------------------------------- @@ -74,13 +74,25 @@ -- | Common list browser prefixes to make experimental properties work in -- different browsers. +webkitPrefix :: (Text, Text)+webkitPrefix = ( "-webkit-", "" )++emptyPrefix :: (Text, Text)+emptyPrefix = ( "", "" )++webkit :: Prefixed+webkit = Prefixed $+  [ webkitPrefix+  , emptyPrefix+  ]+ browsers :: Prefixed-browsers = Prefixed-  [ ( "-webkit-", "" )-  , (    "-moz-", "" )-  , (     "-ms-", "" )-  , (      "-o-", "" )-  , (         "", "" )+browsers = Prefixed $+  [ webkitPrefix+  , ( "-moz-", "" )+  , (  "-ms-", "" )+  , (   "-o-", "" )+  , emptyPrefix   ]  -------------------------------------------------------------------------------
src/Clay/Display.hs view
@@ -81,7 +81,6 @@ ) where -import Data.Monoid import Data.String  import Clay.Size@@ -128,7 +127,7 @@ absolute = Position "absolute" fixed    = Position "fixed" relative = Position "relative"-sticky = Position "sticky"+sticky = Position $ Value (webkit <> Plain "sticky")  position :: Position -> Css position = key "position"@@ -187,7 +186,7 @@ -------------------------------------------------------------------------------  newtype Visibility = Visibility Value-  deriving (Val, Other, Auto, Inherit, Hidden, Visible)+  deriving (Val, Other, Inherit, Hidden, Unset, Visible)  separate, collapse :: Visibility 
src/Clay/Flexbox.hs view
@@ -14,19 +14,21 @@ class FlexStart    a where flexStart    :: a class SpaceAround  a where spaceAround  :: a class SpaceBetween a where spaceBetween :: a+class SpaceEvenly  a where spaceEvenly  :: a class Stretch      a where stretch      :: a  instance FlexEnd Value      where flexEnd      = "flex-end" instance FlexStart Value    where flexStart    = "flex-start" instance SpaceAround Value  where spaceAround  = "space-around" instance SpaceBetween Value where spaceBetween = "space-between"+instance SpaceEvenly Value  where spaceEvenly  = "space-evenly" instance Stretch Value      where stretch      = "stretch"  -------------------------------------------------------------------------------  newtype AlignContentValue = AlignContentValue Value   deriving (Val, Other, Inherit, FlexStart, FlexEnd-          , Center, SpaceBetween, SpaceAround, Stretch)+          , Center, SpaceBetween, SpaceAround, SpaceEvenly, Stretch)  alignContent :: AlignContentValue -> Css alignContent = key "align-content"@@ -107,7 +109,7 @@  newtype JustifyContentValue = JustifyContentValue Value   deriving (Val, Other, Inherit, Center, FlexEnd-          , FlexStart, SpaceAround, SpaceBetween)+          , FlexStart, SpaceAround, SpaceBetween, SpaceEvenly)  justifyContent :: JustifyContentValue -> Css justifyContent = key "justify-content"
src/Clay/Font.hs view
@@ -102,7 +102,8 @@   [GenericFontFamily]  instance Val (Required a) where-  value (Required a Nothing  c d) = value (a ! (Literal <$> c) ! d)+  value (Required a Nothing  c d) = value a <> " " <> (value $ Literal <$> c) <> sep <> value d+    where sep = if null c || null d then "" else ","   value (Required a (Just b) c d) = value ((value a <> "/" <> value b) ! (Literal <$> c) ! d)  instance Font (          Required a)
src/Clay/FontFace.hs view
@@ -9,8 +9,6 @@ import Clay.Property (Prefixed (Plain), Value(Value), Val (value), quote) import Clay.Stylesheet (Css, key) -import Data.Monoid ((<>))-import Data.Functor ((<$>)) import Data.Maybe (fromMaybe) import Data.Text (Text) 
src/Clay/Gradient.hs view
@@ -36,8 +36,6 @@ ) where -import Data.Monoid- import Clay.Color import Clay.Common import Clay.Property
+ src/Clay/Grid.hs view
@@ -0,0 +1,58 @@+{-# LANGUAGE OverloadedStrings #-}+-- | Partial implementation of <https://alligator.io/css/css-grid-layout-grid-areas grid area CSS API>.+--+-- For instance, you want to generate the following CSS:+--+-- @+-- .grid1 {+--   display: grid;+--   width: max-content;+-- }+--+-- .grid3 {+--   display: grid;+--   width: max-content;+-- }+--+-- \@media (min-width: 40.0rem) {+--   .grid3 {+--     display: grid;+--     grid-template-columns: 1fr 1fr 1fr;+--     grid-gap: 1rem;+--     width: max-content;+--   }+-- }+-- @+--+-- The corresponding clay code:+--+-- @+--  ".grid1" ? do+--    display grid+--    width maxContent+--  ".grid3" ? do+--    display grid+--    width maxContent+--  query M.screen [M.minWidth (rem 40)] $ ".grid3" ? do+--    display grid+--    gridTemplateColumns [fr 1, fr 1, fr 1]+--    gridGap $ rem 1+--    width maxContent+-- @+module Clay.Grid+( gridGap+, gridTemplateColumns+)+where++import Clay.Property+import Clay.Size+import Clay.Stylesheet++-- | Property sets the gaps (gutters) between rows and columns.+gridGap :: Size a -> Css+gridGap = key "grid-gap"++-- | Property defines the line names and track sizing functions of the grid columns.+gridTemplateColumns :: [Size a] -> Css+gridTemplateColumns = key "grid-template-columns" . noCommas
src/Clay/List.hs view
@@ -36,7 +36,6 @@ ) where -import Data.Semigroup import Data.Text (Text)  import Clay.Common@@ -75,7 +74,7 @@ listStyleType = key "list-style-type"  newtype ListStylePosition = ListStylePosition Value-  deriving (Val, Initial, Inherit, None, Other)+  deriving (Val, Initial, Inherit, Other)  inside, outside :: ListStylePosition 
src/Clay/Mask.hs view
@@ -57,8 +57,6 @@ ) where -import Data.Semigroup- import Clay.Background import Clay.Common import Clay.Property
src/Clay/Property.hs view
@@ -6,7 +6,6 @@ import Data.List (partition, sort) import Data.List.NonEmpty (NonEmpty, toList) import Data.Maybe-import Data.Semigroup import Data.String import Data.Text (Text, replace) 
src/Clay/Render.hs view
@@ -14,7 +14,6 @@  import           Control.Applicative import           Control.Monad.Writer-import           Data.Foldable          (foldMap) import           Data.List              (sort) import           Data.Maybe import           Data.Text              (Text, pack)@@ -304,6 +303,7 @@             Child      a b -> ins " > " <$> rec a <*> rec b             Deep       a b -> ins " "   <$> rec a <*> rec b             Adjacent   a b -> ins " + " <$> rec a <*> rec b+            Sibling    a b -> ins " ~ " <$> rec a <*> rec b             Combined   a b -> rec a ++ rec b           where ins s a b = a <> s <> b 
src/Clay/Selector.hs view
@@ -9,8 +9,6 @@   #-} module Clay.Selector where -import Control.Applicative-import Data.Semigroup import Data.String import Data.Text (Text) @@ -53,6 +51,11 @@ (|+) :: Selector -> Selector -> Selector (|+) a b = In (SelectorF (Refinement []) (Adjacent a b)) +-- | The general sibling selector composer. Maps to @sel1 ~ sel2@ in CSS.++(|~) :: Selector -> Selector -> Selector+(|~) a b = In (SelectorF (Refinement []) (Sibling a b))+ -- | Named alias for `#`.  with :: Selector -> Refinement -> Selector@@ -176,6 +179,7 @@   | Child     f f   | Deep      f f   | Adjacent  f f+  | Sibling   f f   | Combined  f f   deriving Show 
src/Clay/Size.hs view
@@ -33,6 +33,11 @@ , vh , vmin , vmax+, fr+, maxContent+, minContent+, available+, fitContent  -- * Calculation operators for calc @@ -142,7 +147,7 @@ -- | Size in picas (1pc = 12pt). pc i = SimpleSize (cssDoubleText i <> "pc") -em, ex, rem, vw, vh, vmin, vmax :: Double -> Size LengthUnit+em, ex, rem, vw, vh, vmin, vmax, fr :: Double -> Size LengthUnit  -- | Size in em's (computed cssDoubleText of the font-size). em i = SimpleSize (cssDoubleText i <> "em")@@ -164,6 +169,25 @@  -- | SimpleSize in vmax's (the larger of vw or vh). vmax i = SimpleSize (cssDoubleText i <> "vmax")++-- | 'SimpleSize' in fr's (a fractional unit and 1fr is for 1 part of the available space in grid areas).+fr i = SimpleSize (cssDoubleText i <> "fr")++-- | SimpleSize for the intrinsic preferred width.+maxContent :: Size LengthUnit+maxContent = SimpleSize "max-content"++-- | SimpleSize for the intrinsic minimum width.+minContent :: Size LengthUnit+minContent = SimpleSize "min-content"++-- | SimpleSize for the containing block width minus horizontal margin, border, and padding.+available :: Size LengthUnit+available = SimpleSize "available"++-- | The larger of the intrinsic minimum width or the smaller of the intrinsic preferred width and the available width.+fitContent :: Size LengthUnit+fitContent = SimpleSize "fit-content"  -- | SimpleSize in percents. pct :: Double -> Size Percentage
src/Clay/Stylesheet.hs view
@@ -7,10 +7,7 @@ import Control.Applicative import Control.Arrow (second) import Control.Monad.Writer (Writer, execWriter, tell)-import Data.Foldable (foldMap) import Data.Maybe (isJust)-import Data.Monoid (Monoid(..))-import Data.Semigroup (Semigroup(..)) import Data.String (IsString) import Data.Text (Text) 
src/Clay/Text.hs view
@@ -35,6 +35,7 @@  , TextAlign , textAlign+, textAlignLast , justify, matchParent, start, end , alignSide , alignString@@ -94,7 +95,6 @@ ) where -import Data.Monoid import Data.String import Data.Text (Text) @@ -207,6 +207,9 @@  textAlign :: TextAlign -> Css textAlign = key "text-align"++textAlignLast :: TextAlign -> Css+textAlignLast = key "text-align-last"  ------------------------------------------------------------------------------- 
src/Clay/Time.hs view
@@ -12,7 +12,6 @@ ) where -import Data.Monoid import Data.Text (pack)  import Clay.Common
src/Clay/Transform.hs view
@@ -7,6 +7,18 @@   Transformation , transform , transforms+, TransformStyle+, transformStyle+, flat+, preserve3d+, TransformBox+, transformBox+, transformContentBox+, transformBorderBox+, fillBox+, strokeBox+, viewBox+, transformOrigin  -- * Translating. @@ -39,7 +51,6 @@ ) where -import Data.Monoid import Prelude hiding (Left, Right)  import Clay.Property@@ -55,6 +66,38 @@  transforms :: [Transformation] -> Css transforms xs = prefixed (browsers <> "transform") (noCommas xs)++-------------------------------------------------------------------------------++newtype TransformStyle = TransformStyle Value+  deriving (Val, Inherit, Initial, Unset)++transformStyle :: TransformStyle -> Css+transformStyle = prefixed (browsers <> "transform-style")++flat, preserve3d :: TransformStyle+flat = TransformStyle "flat"+preserve3d = TransformStyle "preserve-3d"++-------------------------------------------------------------------------------++newtype TransformBox = TransformBox Value+  deriving (Val, Inherit, Initial, Unset)++transformBox :: TransformBox -> Css+transformBox = prefixed (browsers <> "transform-box")++transformContentBox, transformBorderBox, fillBox, strokeBox, viewBox :: TransformBox+transformContentBox = TransformBox "contentBox"+transformBorderBox = TransformBox "borderBox"+fillBox = TransformBox "fillBox"+strokeBox = TransformBox "strokeBox"+viewBox = TransformBox "viewBox"++-------------------------------------------------------------------------------++transformOrigin :: [Size a] -> Css+transformOrigin = prefixed (browsers <> "transform-origin") . noCommas  ------------------------------------------------------------------------------- 
src/Clay/Transition.hs view
@@ -36,7 +36,6 @@ ) where -import Data.Monoid import Data.Text (Text)  import Clay.Common@@ -90,11 +89,11 @@  stepsStart, stepsStop :: Integer -> TimingFunction -stepsStart s = other ("steps(" <> value s <> ", end)")+stepsStart s = other ("steps(" <> value s <> ", start)") stepsStop  s = other ("steps(" <> value s <> ", end)")  cubicBezier :: Double -> Double -> Double -> Double -> TimingFunction-cubicBezier a b c d = other ("cubic-bezier(" <> value (a ! b ! c ! d) <> ")")+cubicBezier a b c d = other ("cubic-bezier(" <> value [a, b, c, d] <> ")")  transitionTimingFunction :: TimingFunction -> Css transitionTimingFunction = key "transition-timing-function"