Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
14 changes: 13 additions & 1 deletion src/CSS/Transform.purs
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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"

Expand Down
25 changes: 25 additions & 0 deletions test/CSS/TransformSpec.purs
Original file line number Diff line number Diff line change
@@ -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
]
2 changes: 2 additions & 0 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -295,3 +296,4 @@ main = do
flip runReaderT 0 do
BorderSpec.spec
DisplaySpec.spec
TransformSpec.spec
Loading