Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendering of the Number type #256

Merged
merged 7 commits into from
Nov 15, 2023
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
13 changes: 11 additions & 2 deletions spec/Clay/MediaSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module Clay.MediaSpec (spec) where

import Clay (Css, em, query)
import Clay (compact, Css, em, opacity, query, renderWith)
import Clay.Media
import Clay.Stylesheet (Feature, MediaType)
import Clay.Stylesheet (Feature, keyframes, MediaType)
import Common
import Data.Text.Lazy (Text, unpack)
import Test.Hspec
Expand Down Expand Up @@ -73,6 +73,15 @@ spec = do
"prefers-color-scheme: light" `shouldRenderFromFeature` prefersColorScheme light
"prefers-color-scheme: dark" `shouldRenderFromFeature` prefersColorScheme dark

describe "keyframes tests" $ do
it "keyframes test 1" $
(renderWith compact [] $ keyframes "blink-animation" [(0, opacity 0), (100, opacity 1)])
`shouldBe` ("@-webkit-keyframes blink-animation{0% {opacity:0}100% {opacity:1}}" <>
"@-moz-keyframes blink-animation{0% {opacity:0}100% {opacity:1}}" <>
"@-ms-keyframes blink-animation{0% {opacity:0}100% {opacity:1}}" <>
"@-o-keyframes blink-animation{0% {opacity:0}100% {opacity:1}}" <>
"@keyframes blink-animation{0% {opacity:0}100% {opacity:1}}")

-- | Empty CSS for when CSS is needed but we don't care about it.
emptyStyle :: Css
emptyStyle = pure ()
Expand Down
4 changes: 2 additions & 2 deletions src/Clay/Render.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Control.Applicative
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 ((**))

Expand Down Expand Up @@ -150,7 +150,7 @@ kframe cfg (Keyframes ident xs) =
frame :: Config -> (Number, [Rule]) -> Builder
frame cfg (p, rs) =
mconcat
[ fromText (pack (show p))
[ fromText (cssNumberText p)
turion marked this conversation as resolved.
Show resolved Hide resolved
, "% "
, rules cfg [] rs
]
Expand Down
Loading