clay 0.14.0 → 0.15.0
raw patch · 14 files changed
+270/−73 lines, 14 filesdep ~basenew-uploaderPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
- Clay.Property: cssDoubleText :: Double -> Text
- Clay.Property: instance Clay.Property.Val GHC.Integer.Type.Integer
- Clay.Property: instance Clay.Property.Val GHC.Types.Double
+ Clay: data HyphenateCharacter
+ Clay: data HyphenateLimit
+ Clay: data Hyphens
+ Clay: hyphenateCharacter :: HyphenateCharacter -> Css
+ Clay: hyphenateLimitChars :: HyphenateLimit -> HyphenateLimit -> HyphenateLimit -> Css
+ Clay: hyphens :: Hyphens -> Css
+ Clay: manual :: Hyphens
+ Clay.Media: all :: MediaType
+ Clay.Media: dark :: ColorScheme
+ Clay.Media: data ColorScheme
+ Clay.Media: instance Clay.Common.Other Clay.Media.ColorScheme
+ Clay.Media: instance Clay.Property.Val Clay.Media.ColorScheme
+ Clay.Media: light :: ColorScheme
+ Clay.Media: prefersColorScheme :: ColorScheme -> Feature
+ Clay.Property: Number :: Fixed E5 -> Number
+ Clay.Property: [unNumber] :: Number -> Fixed E5
+ Clay.Property: cssNumberText :: Number -> Text
+ Clay.Property: instance Clay.Property.Val Clay.Property.Number
+ Clay.Property: instance Clay.Property.Val GHC.Num.Integer.Integer
+ Clay.Property: instance GHC.Classes.Eq Clay.Property.Number
+ Clay.Property: instance GHC.Classes.Ord Clay.Property.Number
+ Clay.Property: instance GHC.Enum.Enum Clay.Property.Number
+ Clay.Property: instance GHC.Num.Num Clay.Property.Number
+ Clay.Property: instance GHC.Read.Read Clay.Property.Number
+ Clay.Property: instance GHC.Real.Fractional Clay.Property.Number
+ Clay.Property: instance GHC.Real.Real Clay.Property.Number
+ Clay.Property: instance GHC.Real.RealFrac Clay.Property.Number
+ Clay.Property: instance GHC.Show.Show Clay.Property.Number
+ Clay.Property: newtype Number
+ Clay.Size: ch :: Number -> Size LengthUnit
+ Clay.Size: dvh :: Number -> Size LengthUnit
+ Clay.Size: dvw :: Number -> Size LengthUnit
+ Clay.Size: lh :: Number -> Size LengthUnit
+ Clay.Size: lvh :: Number -> Size LengthUnit
+ Clay.Size: lvw :: Number -> Size LengthUnit
+ Clay.Size: rlh :: Number -> Size LengthUnit
+ Clay.Size: svh :: Number -> Size LengthUnit
+ Clay.Size: svw :: Number -> Size LengthUnit
+ Clay.Size: vb :: Number -> Size LengthUnit
+ Clay.Size: vi :: Number -> Size LengthUnit
+ Clay.Text: data HyphenateCharacter
+ Clay.Text: data HyphenateLimit
+ Clay.Text: data Hyphens
+ Clay.Text: hyphenateCharacter :: HyphenateCharacter -> Css
+ Clay.Text: hyphenateLimitChars :: HyphenateLimit -> HyphenateLimit -> HyphenateLimit -> Css
+ Clay.Text: hyphens :: Hyphens -> Css
+ Clay.Text: instance Clay.Common.Auto Clay.Text.HyphenateCharacter
+ Clay.Text: instance Clay.Common.Auto Clay.Text.HyphenateLimit
+ Clay.Text: instance Clay.Common.Auto Clay.Text.Hyphens
+ Clay.Text: instance Clay.Common.Inherit Clay.Text.HyphenateCharacter
+ Clay.Text: instance Clay.Common.Inherit Clay.Text.HyphenateLimit
+ Clay.Text: instance Clay.Common.Inherit Clay.Text.Hyphens
+ Clay.Text: instance Clay.Common.Initial Clay.Text.HyphenateCharacter
+ Clay.Text: instance Clay.Common.Initial Clay.Text.HyphenateLimit
+ Clay.Text: instance Clay.Common.Initial Clay.Text.Hyphens
+ Clay.Text: instance Clay.Common.None Clay.Text.Hyphens
+ Clay.Text: instance Clay.Common.Other Clay.Text.HyphenateCharacter
+ Clay.Text: instance Clay.Common.Other Clay.Text.HyphenateLimit
+ Clay.Text: instance Clay.Common.Other Clay.Text.Hyphens
+ Clay.Text: instance Clay.Common.Unset Clay.Text.HyphenateCharacter
+ Clay.Text: instance Clay.Common.Unset Clay.Text.HyphenateLimit
+ Clay.Text: instance Clay.Common.Unset Clay.Text.Hyphens
+ Clay.Text: instance Clay.Property.Val Clay.Text.HyphenateCharacter
+ Clay.Text: instance Clay.Property.Val Clay.Text.HyphenateLimit
+ Clay.Text: instance Clay.Property.Val Clay.Text.Hyphens
+ Clay.Text: instance Data.String.IsString Clay.Text.HyphenateCharacter
+ Clay.Text: instance GHC.Num.Num Clay.Text.HyphenateLimit
+ Clay.Text: manual :: Hyphens
- Clay: brightness :: Double -> Filter
+ Clay: brightness :: Number -> Filter
- Clay: keyframes :: Text -> [(Double, Css)] -> Css
+ Clay: keyframes :: Text -> [(Number, Css)] -> Css
- Clay: opacity :: Double -> Css
+ Clay: opacity :: Number -> Css
- Clay.Animation: iterationCount :: Double -> IterationCount
+ Clay.Animation: iterationCount :: Number -> IterationCount
- Clay.Display: opacity :: Double -> Css
+ Clay.Display: opacity :: Number -> Css
- Clay.Filter: brightness :: Double -> Filter
+ Clay.Filter: brightness :: Number -> Filter
- Clay.Size: (*@) :: Double -> Size a -> Size a
+ Clay.Size: (*@) :: Number -> Size a -> Size a
- Clay.Size: (@*) :: Size a -> Double -> Size a
+ Clay.Size: (@*) :: Size a -> Number -> Size a
- Clay.Size: (@/) :: Size a -> Double -> Size a
+ Clay.Size: (@/) :: Size a -> Number -> Size a
- Clay.Size: cm :: Double -> Size LengthUnit
+ Clay.Size: cm :: Number -> Size LengthUnit
- Clay.Size: deg :: Double -> Angle Deg
+ Clay.Size: deg :: Number -> Angle Deg
- Clay.Size: em :: Double -> Size LengthUnit
+ Clay.Size: em :: Number -> Size LengthUnit
- Clay.Size: ex :: Double -> Size LengthUnit
+ Clay.Size: ex :: Number -> Size LengthUnit
- Clay.Size: fr :: Double -> Size LengthUnit
+ Clay.Size: fr :: Number -> Size LengthUnit
- Clay.Size: grad :: Double -> Angle Grad
+ Clay.Size: grad :: Number -> Angle Grad
- Clay.Size: inches :: Double -> Size LengthUnit
+ Clay.Size: inches :: Number -> Size LengthUnit
- Clay.Size: mm :: Double -> Size LengthUnit
+ Clay.Size: mm :: Number -> Size LengthUnit
- Clay.Size: pc :: Double -> Size LengthUnit
+ Clay.Size: pc :: Number -> Size LengthUnit
- Clay.Size: pct :: Double -> Size Percentage
+ Clay.Size: pct :: Number -> Size Percentage
- Clay.Size: pt :: Double -> Size LengthUnit
+ Clay.Size: pt :: Number -> Size LengthUnit
- Clay.Size: px :: Double -> Size LengthUnit
+ Clay.Size: px :: Number -> Size LengthUnit
- Clay.Size: rad :: Double -> Angle Rad
+ Clay.Size: rad :: Number -> Angle Rad
- Clay.Size: rem :: Double -> Size LengthUnit
+ Clay.Size: rem :: Number -> Size LengthUnit
- Clay.Size: turn :: Double -> Angle Turn
+ Clay.Size: turn :: Number -> Angle Turn
- Clay.Size: unitless :: Double -> Size a
+ Clay.Size: unitless :: Number -> Size a
- Clay.Size: vh :: Double -> Size LengthUnit
+ Clay.Size: vh :: Number -> Size LengthUnit
- Clay.Size: vmax :: Double -> Size LengthUnit
+ Clay.Size: vmax :: Number -> Size LengthUnit
- Clay.Size: vmin :: Double -> Size LengthUnit
+ Clay.Size: vmin :: Number -> Size LengthUnit
- Clay.Size: vw :: Double -> Size LengthUnit
+ Clay.Size: vw :: Number -> Size LengthUnit
- Clay.Stylesheet: Keyframes :: Text -> [(Double, [Rule])] -> Keyframes
+ Clay.Stylesheet: Keyframes :: Text -> [(Number, [Rule])] -> Keyframes
- Clay.Stylesheet: keyframes :: Text -> [(Double, Css)] -> Css
+ Clay.Stylesheet: keyframes :: Text -> [(Number, Css)] -> Css
- Clay.Transform: matrix :: Double -> Double -> Double -> Double -> Double -> Double -> Transformation
+ Clay.Transform: matrix :: Number -> Number -> Number -> Number -> Number -> Number -> Transformation
- Clay.Transform: matrix3d :: Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Transformation
+ Clay.Transform: matrix3d :: Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Transformation
- Clay.Transform: perspective :: Double -> Transformation
+ Clay.Transform: perspective :: Number -> Transformation
- Clay.Transform: rotate3d :: Double -> Double -> Double -> Angle a -> Transformation
+ Clay.Transform: rotate3d :: Number -> Number -> Number -> Angle a -> Transformation
- Clay.Transform: scale :: Double -> Double -> Transformation
+ Clay.Transform: scale :: Number -> Number -> Transformation
- Clay.Transform: scale3d :: Double -> Double -> Double -> Transformation
+ Clay.Transform: scale3d :: Number -> Number -> Number -> Transformation
- Clay.Transform: scaleX :: Double -> Transformation
+ Clay.Transform: scaleX :: Number -> Transformation
- Clay.Transform: scaleY :: Double -> Transformation
+ Clay.Transform: scaleY :: Number -> Transformation
- Clay.Transform: scaleZ :: Double -> Transformation
+ Clay.Transform: scaleZ :: Number -> Transformation
- Clay.Transition: cubicBezier :: Double -> Double -> Double -> Double -> TimingFunction
+ Clay.Transition: cubicBezier :: Number -> Number -> Number -> Number -> TimingFunction
Files
- CHANGELOG +11/−0
- README.md +1/−1
- clay.cabal +6/−4
- src/Clay/Animation.hs +1/−1
- src/Clay/Display.hs +1/−1
- src/Clay/Filter.hs +1/−1
- src/Clay/Media.hs +40/−4
- src/Clay/Property.hs +13/−9
- src/Clay/Render.hs +4/−4
- src/Clay/Size.hs +75/−31
- src/Clay/Stylesheet.hs +2/−2
- src/Clay/Text.hs +103/−3
- src/Clay/Transform.hs +11/−11
- src/Clay/Transition.hs +1/−1
CHANGELOG view
@@ -1,5 +1,16 @@ CHANGELOG + 0.15.0:+ - Add `all` media type.+ - Support `prefers-color-scheme` media feature.+ - Use `matrix` rather than `matrix3d`+ - Add media type `all`+ - Add some relative units+ - Add CSS properties related to hyphenation+ - Use `Number` type instead of `Double` as an argument type in many places+ - Fix rendering of `Number` type+ Thanks to Yoo Chung, Charles Bayley and David Fox+ 0.14.0: - Drop support for GHC 8.2 - Added `text-align-last`
README.md view
@@ -1,6 +1,6 @@ # Clay -[](https://travis-ci.org/sebastiaanvisser/clay)+[](https://github.com/sebastiaanvisser/clay/actions/workflows/ci.yml) [](https://hackage.haskell.org/package/clay) Clay is a CSS preprocessor like LESS and Sass, but implemented as an embedded
clay.cabal view
@@ -1,5 +1,5 @@ Name: clay-Version: 0.14.0+Version: 0.15.0 Synopsis: CSS preprocessor as embedded Haskell. Description: Clay is a CSS preprocessor like LESS and Sass, but implemented as an embedded@@ -31,7 +31,9 @@ GHC==8.6.5, GHC==8.8.4, GHC==8.10.7,- GHC==9.0.2+ GHC==9.0.2,+ GHC==9.2.2,+ GHC==9.4.2 Source-Repository head Type: git@@ -75,7 +77,7 @@ Clay.Transition Build-Depends:- base >= 4.11 && < 4.16,+ base >= 4.11 && < 4.20, mtl >= 1, text >= 0.11 GHC-Options: -Wall -Wcompat@@ -87,7 +89,7 @@ Build-Tools: hspec-discover main-is: Spec.hs Build-Depends:- base >= 4.11 && < 4.16,+ base >= 4.11 && < 4.20, mtl >= 1, text >= 0.11, hspec >= 2.2.0,
src/Clay/Animation.hs view
@@ -142,7 +142,7 @@ infinite :: IterationCount infinite = IterationCount "infinite" -iterationCount :: Double -> IterationCount+iterationCount :: Number -> IterationCount iterationCount = IterationCount . value -------------------------------------------------------------------------------
src/Clay/Display.hs view
@@ -209,7 +209,7 @@ ------------------------------------------------------------------------------- -opacity :: Double -> Css+opacity :: Number -> Css opacity = key "opacity" zIndex :: Integer -> Css
src/Clay/Filter.hs view
@@ -52,7 +52,7 @@ blur :: Size LengthUnit -> Filter blur i = Filter ("blur(" <> value i <> ")") -brightness :: Double -> Filter+brightness :: Number -> Filter brightness i = Filter ("brightness(" <> value i <> ")") contrast :: Size Percentage -> Filter
src/Clay/Media.hs view
@@ -4,9 +4,13 @@ -- * Media types. - aural, braille, handheld, print, projection-, screen, tty, tv, embossed+ all, screen, print +-- ** Deprecated.++-- | These media types were deprecated by Media Queries 4.+, aural, braille, handheld, projection, tty, tv, embossed+ -- * Geometrical features. , width, minWidth, maxWidth, height, minHeight, maxHeight, deviceWidth@@ -33,6 +37,16 @@ , Resolution , dpi , dppx++-- * Preference related features.++, prefersColorScheme++-- ** Preference related values.++, ColorScheme+, light+, dark ) where@@ -40,7 +54,7 @@ import Data.Text (Text, pack) import Data.Monoid -import Clay.Common+import Clay.Common hiding (all) import Clay.Size import Clay.Property import Clay.Stylesheet@@ -49,14 +63,18 @@ ------------------------------------------------------------------------------- -aural, braille, handheld, print, projection+all, aural, braille, handheld, print, projection , screen, tty, tv, embossed :: MediaType +-- | Suitable for all devices.+all = MediaType "all" aural = MediaType "aural" braille = MediaType "braille" handheld = MediaType "handheld"+-- | Intended primarily for printed material or in a print layout. print = MediaType "print" projection = MediaType "projection"+-- | Intended primarily for screen-based devices. screen = MediaType "screen" tty = MediaType "tty" tv = MediaType "tv"@@ -132,3 +150,21 @@ dppx :: Integer -> Resolution dppx i = Resolution (value (pack (show i) <> "dppx")) +-------------------------------------------------------------------------------++-- | Feature detecting whether user prefers light or dark color scheme.+prefersColorScheme :: ColorScheme -> Feature+prefersColorScheme = with "prefers-color-scheme"++-- | A color scheme preferred by a user.+newtype ColorScheme = ColorScheme Value+ deriving (Val, Other)++-- | User indicates that they prefer a light theme with their interface,+-- or that they have not indicated a preference.+light :: ColorScheme+light = ColorScheme (value (pack "light"))++-- | User indicates that they prefer a dark theme with their interface.+dark :: ColorScheme+dark = ColorScheme (value (pack "dark"))
src/Clay/Property.hs view
@@ -71,15 +71,6 @@ data E5 = E5 instance HasResolution E5 where resolution _ = 100000 -instance Val Double where- value = Value . Plain . cssDoubleText--cssDoubleText :: Double -> Text-cssDoubleText = fromString . showFixed' . realToFrac- where- showFixed' :: Fixed E5 -> String- showFixed' = showFixed True- instance Val Value where value = id @@ -103,6 +94,19 @@ intercalate :: Monoid a => a -> [a] -> a intercalate _ [] = mempty intercalate s (x:xs) = foldl (\a b -> a `mappend` s `mappend` b) x xs++-------------------------------------------------------------------------------++-- | A number type to represent the CSS @number@ type.+-- It has fixed precision, supporting up to 5 decimal places.+newtype Number = Number { unNumber :: Fixed E5 }+ deriving (Enum, Eq, Fractional, Num, Ord, Read, Real, RealFrac, Show)++instance Val Number where+ value = Value . Plain . cssNumberText++cssNumberText :: Number -> Text+cssNumberText = fromString . showFixed True . unNumber -------------------------------------------------------------------------------
src/Clay/Render.hs view
@@ -16,7 +16,7 @@ import Control.Monad.Writer import Data.List (sort) import Data.Maybe-import Data.Text (Text, pack)+import Data.Text (Text) import Data.Text.Lazy.Builder import Prelude hiding ((**)) @@ -147,10 +147,10 @@ ) (unPrefixed browsers) -frame :: Config -> (Double, [Rule]) -> Builder+frame :: Config -> (Number, [Rule]) -> Builder frame cfg (p, rs) = mconcat- [ fromText (pack (show p))+ [ fromText (cssNumberText p) , "% " , rules cfg [] rs ]@@ -184,7 +184,7 @@ feature :: Feature -> Builder feature (Feature k mv) = case mv of- Nothing -> fromText k+ Nothing -> mconcat [ "(", fromText k, ")" ] Just (Value v) -> mconcat [ "(" , fromText k , ": " , fromText (plain v) , ")" ]
src/Clay/Size.hs view
@@ -27,12 +27,23 @@ , pc , em , ex+, ch , pct , rem+, lh+, rlh , vw , vh , vmin , vmax+, vb+, vi+, svw+, svh+, lvw+, lvh+, dvw+, dvh , fr , maxContent , minContent@@ -94,8 +105,8 @@ 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) |+ MultSize Number (Size a) |+ DivSize Number (Size a) | OtherSize Value deriving instance Show (Size a)@@ -104,8 +115,8 @@ 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 (MultSize a b) = mconcat ["(", cssNumberText a, " * ", sizeToText b, ")"]+sizeToText (DivSize a b) = mconcat ["(", sizeToText b, " / ", cssNumberText a, ")"] sizeToText (OtherSize a) = plain $ unValue a instance Val (Size a) where@@ -124,54 +135,87 @@ nil = SimpleSize "0" -- | Unitless size (as recommended for line-height).-unitless :: Double -> Size a+unitless :: Number -> Size a unitless i = SimpleSize ((plain . unValue . value) i) -cm, mm, inches, px, pt, pc :: Double -> Size LengthUnit+cm, mm, inches, px, pt, pc :: Number -> Size LengthUnit -- | Size in centimeters.-cm i = SimpleSize (cssDoubleText i <> "cm")+cm i = SimpleSize (cssNumberText i <> "cm") -- | Size in millimeters.-mm i = SimpleSize (cssDoubleText i <> "mm")+mm i = SimpleSize (cssNumberText i <> "mm") -- | Size in inches (1in = 2.54 cm).-inches i = SimpleSize (cssDoubleText i <> "in")+inches i = SimpleSize (cssNumberText i <> "in") -- | Size in pixels.-px i = SimpleSize (cssDoubleText i <> "px")+px i = SimpleSize (cssNumberText i <> "px") -- | Size in points (1pt = 1/72 of 1in).-pt i = SimpleSize (cssDoubleText i <> "pt")+pt i = SimpleSize (cssNumberText i <> "pt") -- | Size in picas (1pc = 12pt).-pc i = SimpleSize (cssDoubleText i <> "pc")+pc i = SimpleSize (cssNumberText i <> "pc") -em, ex, rem, vw, vh, vmin, vmax, fr :: Double -> Size LengthUnit+em, ex, ch, rem, lh, rlh, vw, vh, vmin, vmax, vb, vi, svw, svh, lvw, lvh, dvw, dvh, fr :: Number -> Size LengthUnit --- | Size in em's (computed cssDoubleText of the font-size).-em i = SimpleSize (cssDoubleText i <> "em")+-- | Size in em's (computed cssNumberText of the font-size).+em i = SimpleSize (cssNumberText i <> "em") -- | SimpleSize in ex'es (x-height of the first avaliable font).-ex i = SimpleSize (cssDoubleText i <> "ex")+ex i = SimpleSize (cssNumberText i <> "ex") +-- | SimpleSize in ch's (The width of the glyph "0" of the element's font).+ch i = SimpleSize (cssNumberText i <> "ch")+ -- | SimpleSize in rem's (em's, but always relative to the root element).-rem i = SimpleSize (cssDoubleText i <> "rem")+rem i = SimpleSize (cssNumberText i <> "rem") +-- | SimpleSize in lh's (Line height of the element).+lh i = SimpleSize (cssNumberText i <> "lh")++-- | SimpleSize in rlh's (lh's, but always relative to the root element).+rlh i = SimpleSize (cssNumberText i <> "rlh")+ -- | SimpleSize in vw's (1vw = 1% of viewport width).-vw i = SimpleSize (cssDoubleText i <> "vw")+vw i = SimpleSize (cssNumberText i <> "vw") -- | SimpleSize in vh's (1vh = 1% of viewport height).-vh i = SimpleSize (cssDoubleText i <> "vh")+vh i = SimpleSize (cssNumberText i <> "vh") -- | SimpleSize in vmin's (the smaller of vw or vh).-vmin i = SimpleSize (cssDoubleText i <> "vmin")+vmin i = SimpleSize (cssNumberText i <> "vmin") -- | SimpleSize in vmax's (the larger of vw or vh).-vmax i = SimpleSize (cssDoubleText i <> "vmax")+vmax i = SimpleSize (cssNumberText i <> "vmax") +-- | SimpleSize in vb's (1vb = 1% of the parent's size in the direction of the root element's block axis).+vb i = SimpleSize (cssNumberText i <> "vb")++-- | SimpleSize in vi's (1vi = 1% of the parent's size in the direction of the root element's inline axis).+vi i = SimpleSize (cssNumberText i <> "vi")++-- | SimpleSize in svw's (1svw = 1% of the small viewport's width).+svw i = SimpleSize (cssNumberText i <> "svw")++-- | SimpleSize in svh's (1svh = 1% of the small viewport's height).+svh i = SimpleSize (cssNumberText i <> "svh")++-- | SimpleSize in lvw's (1lvw = 1% of the large viewport's width).+lvw i = SimpleSize (cssNumberText i <> "lvw")++-- | SimpleSize in lvh's (1lvh = 1% of the large viewport's height).+lvh i = SimpleSize (cssNumberText i <> "lvh")++-- | SimpleSize in dvw's (1dvw = 1% of the dynamic viewport's width).+dvw i = SimpleSize (cssNumberText i <> "dvw")++-- | SimpleSize in dvh's (1dvh = 1% of the dynamic viewport's height).+dvh i = SimpleSize (cssNumberText i <> "dvh")+ -- | '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")+fr i = SimpleSize (cssNumberText i <> "fr") -- | SimpleSize for the intrinsic preferred width. maxContent :: Size LengthUnit@@ -190,8 +234,8 @@ fitContent = SimpleSize "fit-content" -- | SimpleSize in percents.-pct :: Double -> Size Percentage-pct i = SimpleSize (cssDoubleText i <> "%")+pct :: Number -> Size Percentage+pct i = SimpleSize (cssNumberText i <> "%") instance Num (Size LengthUnit) where fromInteger = px . fromInteger@@ -236,17 +280,17 @@ -- | Times operator to combine sizes into calc function infixl 7 *@-(*@) :: Double -> Size a -> Size a+(*@) :: Number -> 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+(@*) :: Size a -> Number -> Size a a @* b = MultSize b a -- | Division operator to combine sizes into calc function infixl 7 @/-(@/) :: Size a -> Double -> Size a+(@/) :: Size a -> Number -> Size a a @/ b = DivSize b a -------------------------------------------------------------------------------@@ -271,19 +315,19 @@ deriving (Val, Auto, Inherit, Other) -- | Angle in degrees.-deg :: Double -> Angle Deg+deg :: Number -> Angle Deg deg i = Angle (value i <> "deg") -- | Angle in radians.-rad :: Double -> Angle Rad+rad :: Number -> Angle Rad rad i = Angle (value i <> "rad") -- | Angle in gradians (also knows as gons or grades).-grad :: Double -> Angle Grad+grad :: Number -> Angle Grad grad i = Angle (value i <> "grad") -- | Angle in turns.-turn :: Double -> Angle Turn+turn :: Number -> Angle Turn turn i = Angle (value i <> "turn") instance Num (Angle Deg) where
src/Clay/Stylesheet.hs view
@@ -55,7 +55,7 @@ | Sub Selector deriving Show -data Keyframes = Keyframes Text [(Double, [Rule])]+data Keyframes = Keyframes Text [(Number, [Rule])] deriving Show data Rule@@ -165,7 +165,7 @@ ------------------------------------------------------------------------------- -keyframes :: Text -> [(Double, Css)] -> Css+keyframes :: Text -> [(Number, Css)] -> Css keyframes n xs = rule $ Keyframe (Keyframes n (map (second runS) xs)) keyframesFromTo :: Text -> Css -> Css -> Css
src/Clay/Text.hs view
@@ -73,14 +73,24 @@ , wordBreak , breakAll , keepAll- + -- * Overflow-wrap (and Word-wrap). , OverflowWrap , overflowWrap , wordWrap , breakWord- ++-- * Hyphenation.++, hyphens+, hyphenateCharacter+, hyphenateLimitChars+, manual+, Hyphens+, HyphenateCharacter+, HyphenateLimit+ -- * Content. , Content@@ -96,7 +106,7 @@ where import Data.String-import Data.Text (Text)+import Data.Text (Text, pack) import Clay.Background import Clay.Border@@ -305,6 +315,96 @@ textOverflow :: TextOverflow -> Css textOverflow = key "text-overflow"++-------------------------------------------------------------------------------++-- | Type for values which can be provided to 'hyphens'.+newtype Hyphens = Hyphens Value+ deriving (Val, None, Auto, Initial, Inherit, Unset, Other)++-- | Specifies how words should be hyphenated.+--+-- Possible values are:+--+-- ['none']: No hyphenation.+-- Words will not be hyphenated even if it is explicitly suggested for a word.+--+-- ['manual']: Manual hyphenation.+-- Specific characters such as @­@ in a word will suggest break points.+-- This is the default.+--+-- ['auto']: Automatic hyphenation.+-- The browser is free to hyphenate words as it sees fit.+-- However, explicitly suggested break points will take precedence.+--+-- For example,+--+-- >>> hyphens auto+--+-- The hyphenation rules depend on the language,+-- which must be specified by the @lang@ attribute.+--+-- For reference, see+-- [@hyphens@](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens).+hyphens :: Hyphens -> Css+hyphens = key "hyphens"++-- | Value for 'hyphens' specifying that hyphenation be manual.+manual :: Hyphens+manual = Hyphens "manual"+-- 'manual' feels like it should be a function and type class in Clay.Common,+-- but @hyphens@ is the only CSS property which uses it as a specified value.++-- | Type for values which can be provided to 'hyphenateCharacter'.+newtype HyphenateCharacter = HyphenateCharacter Value+ deriving (Val, Auto, Initial, Inherit, Unset, Other)++-- Allow a 'HyphenateCharacter' value to be specified directly with a string.+instance IsString HyphenateCharacter where+ fromString = HyphenateCharacter . Value . Plain . quote . pack++-- | Customizes the character used for hyphenation.+--+-- For example,+--+-- >>> hyphenateCharacter "~"+--+-- For reference, see+-- [@hyphenate-character@](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphenate-character).+hyphenateCharacter :: HyphenateCharacter -> Css+hyphenateCharacter = key "hyphenate-character"++-- | Type for values which can be provded to 'hyphenateLimitChars'.+newtype HyphenateLimit = HyphenateLimit Value+ deriving (Val, Auto, Initial, Inherit, Unset, Other)++-- Allow a 'HyphenateLimit' value to be specified directly with a number.+instance Num HyphenateLimit where+ fromInteger = HyphenateLimit . value+ (+) = error "plus not implemented for HyphenateLimit"+ (*) = error "times not implemented for HyphenateLimit"+ abs = error "abs not implemented for HyphenateLimit"+ signum = error "signum not implemented for HyphenateLimit"+ negate = error "negate not implemented for HyphenateLimit"++-- | Adjusts the minumum number of characters involved in hyphenation.+--+-- I.e., specifies the minumum number of characters allowed in a breakable word,+-- before a break point, and after a break point when hyphenating a word.+--+-- For example,+--+-- >>> hyphenateLimitChars 14 auto auto+--+-- For reference, see+-- [@hyphenate-limit-chars@](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphenate-limit-chars).+hyphenateLimitChars+ :: HyphenateLimit -- ^ Minimum length of a word which can be hyphenated.+ -> HyphenateLimit -- ^ Minimum number of characters allowed before a break point.+ -> HyphenateLimit -- ^ Minimum number of characters allowed after a break point.+ -> Css+hyphenateLimitChars word before after =+ key "hyphenate-limit-chars" (word ! before ! after) -------------------------------------------------------------------------------
src/Clay/Transform.hs view
@@ -101,16 +101,16 @@ ------------------------------------------------------------------------------- -scale :: Double -> Double -> Transformation+scale :: Number -> Number -> Transformation scale x y = Transformation ("scale(" <> value [x, y] <> ")") -scaleX, scaleY, scaleZ :: Double -> Transformation+scaleX, scaleY, scaleZ :: Number -> Transformation scaleX x = Transformation ("scaleX(" <> value x <> ")") scaleY y = Transformation ("scaleY(" <> value y <> ")") scaleZ z = Transformation ("scaleZ(" <> value z <> ")") -scale3d :: Double -> Double -> Double -> Transformation+scale3d :: Number -> Number -> Number -> Transformation scale3d x y z = Transformation ("scale3d(" <> value [x, y, z] <> ")") -------------------------------------------------------------------------------@@ -124,7 +124,7 @@ rotateY y = Transformation ("rotateY(" <> value y <> ")") rotateZ z = Transformation ("rotateZ(" <> value z <> ")") -rotate3d :: Double -> Double -> Double -> Angle a -> Transformation+rotate3d :: Number -> Number -> Number -> Angle a -> Transformation rotate3d x y z a = Transformation ("rotate3d(" <> value [value x, value y, value z, value a] <> ")") -------------------------------------------------------------------------------@@ -154,16 +154,16 @@ ------------------------------------------------------------------------------- -perspective :: Double -> Transformation+perspective :: Number -> Transformation perspective p = Transformation ("perspective(" <> value p <> ")") -matrix :: Double -> Double -> Double -> Double -> Double -> Double -> Transformation-matrix u v w x y z = Transformation ("matrix3d(" <> value [ u, v, w, x, y, z ] <> ")")+matrix :: Number -> Number -> Number -> Number -> Number -> Number -> Transformation+matrix u v w x y z = Transformation ("matrix(" <> value [ u, v, w, x, y, z ] <> ")") -matrix3d :: Double -> Double -> Double -> Double- -> Double -> Double -> Double -> Double- -> Double -> Double -> Double -> Double- -> Double -> Double -> Double -> Double+matrix3d :: Number -> Number -> Number -> Number + -> Number -> Number -> Number -> Number+ -> Number -> Number -> Number -> Number+ -> Number -> Number -> Number -> Number -> Transformation matrix3d w0 x0 y0 z0 w1 x1 y1 z1
src/Clay/Transition.hs view
@@ -92,7 +92,7 @@ stepsStart s = other ("steps(" <> value s <> ", start)") stepsStop s = other ("steps(" <> value s <> ", end)") -cubicBezier :: Double -> Double -> Double -> Double -> TimingFunction+cubicBezier :: Number -> Number -> Number -> Number -> TimingFunction cubicBezier a b c d = other ("cubic-bezier(" <> value [a, b, c, d] <> ")") transitionTimingFunction :: TimingFunction -> Css