diff --git a/CHANGELOG.md b/CHANGELOG.md index ab60962..bd70588 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based Breaking changes: New features: +- Add `None`, `Inherit`, `Initial`, and `Unset` instances for `Transformation` (#150, #169 by @jibranshaikh0) Bugfixes: diff --git a/src/CSS/Transform.purs b/src/CSS/Transform.purs index a368cc0..3007952 100644 --- a/src/CSS/Transform.purs +++ b/src/CSS/Transform.purs @@ -1,7 +1,7 @@ module CSS.Transform where import Prelude -import CSS.Common (class Inherit, class Initial, class Unset) +import CSS.Common (class Inherit, class Initial, class None, class Unset) import CSS.Property (class Val, Value, noCommas, value) import CSS.Size (Angle, Size) import CSS.String (fromString) @@ -16,6 +16,18 @@ derive instance ordTransformation :: Ord Transformation instance valTransformation :: Val Transformation where value (Transformation v) = v +instance noneTransformation :: None Transformation where + none = Transformation $ fromString "none" + +instance inheritTransformation :: Inherit Transformation where + inherit = Transformation $ fromString "inherit" + +instance initialTransformation :: Initial Transformation where + initial = Transformation $ fromString "initial" + +instance unsetTransformation :: Unset Transformation where + unset = Transformation $ fromString "unset" + transform :: Transformation -> CSS transform = key $ fromString "transform" diff --git a/test/CSS/TransformSpec.purs b/test/CSS/TransformSpec.purs new file mode 100644 index 0000000..67251f2 --- /dev/null +++ b/test/CSS/TransformSpec.purs @@ -0,0 +1,25 @@ +module CSS.TransformSpec where + +import Prelude + +import CSS.Common (inherit, initial, none, unset) +import CSS.Transform (transform) +import Common (shouldRenderFrom) +import Control.Monad.Reader.Class (class MonadReader) +import Data.Traversable (traverse_) +import Data.Tuple.Nested ((/\)) +import Effect.Aff.Class (class MonadAff) +import Test.Utils (describe) + +spec :: forall m. MonadReader Int m => MonadAff m => m Unit +spec = do + describe "transform" do + let testTransform (s /\ v) = ("transform: " <> s) `shouldRenderFrom` transform v + describe "Global and keyword values" $ + traverse_ + testTransform + [ "none" /\ none + , "inherit" /\ inherit + , "initial" /\ initial + , "unset" /\ unset + ] diff --git a/test/Main.purs b/test/Main.purs index 52cdca4..b93606b 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -5,6 +5,7 @@ import Prelude import CSS (Rendered, Path(..), Predicate(..), Refinement(..), Selector(..), FontFaceSrc(..), FontFaceFormat(..), pct, renderedSheet, renderedInline, fromString, selector, block, display, render, borderBox, boxSizing, contentBox, color, body, a, p, px, dashed, border, inlineBlock, black, (?), (&), (|>), (|*), (|+), byId, byClass, (@=), (^=), ($=), (*=), (~=), (|=), hover, fontFaceSrc, fontStyle, deg, rgba, zIndex, textOverflow, opacity, cursor, transform, transition, easeInOut, cubicBezier, ms, direction, width, em, (@+@), (@-@), (@*), (*@), (@/)) import CSS.BorderSpec as BorderSpec import CSS.DisplaySpec as DisplaySpec +import CSS.TransformSpec as TransformSpec import CSS.Cursor as Cursor import CSS.Flexbox (flex) import CSS.FontStyle as FontStyle @@ -295,3 +296,4 @@ main = do flip runReaderT 0 do BorderSpec.spec DisplaySpec.spec + TransformSpec.spec