-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
470 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
on: [pull_request] | ||
name: build | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
ghc: ['8.4.4', '8.6.5', '8.8.4', '8.10.7', '9.0.2', '9.2.2', '9.4.2'] | ||
name: Haskell GHC ${{ matrix.ghc }} cabal | ||
env: | ||
cabal_project_freeze: cabal.project.${{ matrix.ghc }}.freeze | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: haskell/actions/setup@v2 | ||
id: setup-haskell-build | ||
with: | ||
ghc-version: ${{ matrix.ghc }} | ||
- name: Cache Cabal build artifacts | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
${{ steps.setup-haskell-build.outputs.cabal-store }} | ||
dist-newstyle | ||
key: ${{ runner.os }}-cabal-${{ matrix.ghc }}-${{ hashFiles(env.cabal_project_freeze) }} | ||
restore-keys: | | ||
${{ runner.os }}-cabal-${{ matrix.ghc }} | ||
- name: Cabal build dependencies | ||
run: | | ||
cabal build all --enable-tests --only-dependencies --project-file=cabal.project.${{ matrix.ghc }} | ||
- name: Cabal build packages | ||
run: | | ||
cabal build all --enable-tests --project-file=cabal.project.${{ matrix.ghc }} | ||
- name: Cabal test | ||
run: | | ||
cabal test all --enable-tests --test-show-details=Always --project-file=cabal.project.${{ matrix.ghc }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
packages: clay.cabal | ||
tests: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cabal.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cabal.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cabal.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cabal.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cabal.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cabal.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cabal.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Clay.MediaSpec (spec) where | ||
|
||
import Clay (Css, em, query) | ||
import Clay.Media | ||
import Clay.Stylesheet (Feature, MediaType) | ||
import Common | ||
import Data.Text.Lazy (Text, unpack) | ||
import Test.Hspec | ||
import Prelude hiding (all, print) | ||
|
||
spec :: Spec | ||
spec = do | ||
describe "media types" $ do | ||
"all" `shouldRenderFromMediaType` all | ||
"screen" `shouldRenderFromMediaType` screen | ||
"print" `shouldRenderFromMediaType` print | ||
|
||
context "with deprecated types" $ do | ||
"aural" `shouldRenderFromMediaType` aural | ||
"braille" `shouldRenderFromMediaType` braille | ||
"handheld" `shouldRenderFromMediaType` handheld | ||
"projection" `shouldRenderFromMediaType` projection | ||
"tty" `shouldRenderFromMediaType` tty | ||
"tv" `shouldRenderFromMediaType` tv | ||
"embossed" `shouldRenderFromMediaType` embossed | ||
|
||
describe "geometrical features" $ do | ||
"width: 11em" `shouldRenderFromFeature` width (em 11) | ||
"min-width: 12em" `shouldRenderFromFeature` minWidth (em 12) | ||
"max-width: 13em" `shouldRenderFromFeature` maxWidth (em 13) | ||
"height: 14em" `shouldRenderFromFeature` height (em 14) | ||
"min-height: 15em" `shouldRenderFromFeature` minHeight (em 15) | ||
"max-height: 16em" `shouldRenderFromFeature` maxHeight (em 16) | ||
"device-width: 17em" `shouldRenderFromFeature` deviceWidth (em 17) | ||
"min-device-width: 18em" `shouldRenderFromFeature` minDeviceWidth (em 18) | ||
"max-device-width: 19em" `shouldRenderFromFeature` maxDeviceWidth (em 19) | ||
"device-height: 20em" `shouldRenderFromFeature` deviceHeight (em 20) | ||
"min-device-height: 21em" `shouldRenderFromFeature` minDeviceHeight (em 21) | ||
"max-device-height: 22em" `shouldRenderFromFeature` maxDeviceHeight (em 22) | ||
|
||
describe "aspect ratio features" $ do | ||
"aspect-ratio: 2/3" `shouldRenderFromFeature` aspectRatio (2, 3) | ||
"min-aspect-ratio: 4/5" `shouldRenderFromFeature` minAspectRatio (4, 5) | ||
"max-aspect-ratio: 6/7" `shouldRenderFromFeature` maxAspectRatio (6, 7) | ||
"device-aspect-ratio: 2/3" `shouldRenderFromFeature` deviceAspectRatio (2, 3) | ||
"min-device-aspect-ratio: 4/5" `shouldRenderFromFeature` minDeviceAspectRatio (4, 5) | ||
"max-device-aspect-ratio: 6/7" `shouldRenderFromFeature` maxDeviceAspectRatio (6, 7) | ||
|
||
describe "color features" $ do | ||
"color" `shouldRenderFromFeature` color | ||
"monochrome" `shouldRenderFromFeature` monochrome | ||
"scan" `shouldRenderFromFeature` scan | ||
"grid" `shouldRenderFromFeature` grid | ||
"min-color: 23" `shouldRenderFromFeature` minColor 23 | ||
"max-color: 25" `shouldRenderFromFeature` maxColor 25 | ||
"color-index: 15" `shouldRenderFromFeature` colorIndex 15 | ||
"min-color-index: 17" `shouldRenderFromFeature` minColorIndex 17 | ||
"max-color-index: 19" `shouldRenderFromFeature` maxColorIndex 19 | ||
"min-monochrome: 77" `shouldRenderFromFeature` minMonochrome 77 | ||
"max-monochrome: 99" `shouldRenderFromFeature` maxMonochrome 99 | ||
|
||
describe "resolution features" $ do | ||
"resolution: 45dpi" `shouldRenderFromFeature` resolution (dpi 45) | ||
"resolution: 74dppx" `shouldRenderFromFeature` resolution (dppx 74) | ||
"min-resolution: 45dpi" `shouldRenderFromFeature` minResolution (dpi 45) | ||
"min-resolution: 74dppx" `shouldRenderFromFeature` minResolution (dppx 74) | ||
"max-resolution: 45dpi" `shouldRenderFromFeature` maxResolution (dpi 45) | ||
"max-resolution: 74dppx" `shouldRenderFromFeature` maxResolution (dppx 74) | ||
|
||
describe "preference features" $ do | ||
"prefers-color-scheme: light" `shouldRenderFromFeature` prefersColorScheme light | ||
"prefers-color-scheme: dark" `shouldRenderFromFeature` prefersColorScheme dark | ||
|
||
-- | Empty CSS for when CSS is needed but we don't care about it. | ||
emptyStyle :: Css | ||
emptyStyle = pure () | ||
|
||
-- | The text should be rendered from the media type. | ||
shouldRenderFromMediaType :: Text -> MediaType -> SpecWith () | ||
shouldRenderFromMediaType text mediaType = | ||
shouldRenderAsFrom (unpack text) fullText css | ||
where | ||
fullText = "@media " <> text <> "{}" | ||
css = query mediaType [] emptyStyle | ||
|
||
-- | The text should be rendered from the feature. | ||
shouldRenderFromFeature :: Text -> Feature -> SpecWith () | ||
shouldRenderFromFeature text feature = | ||
shouldRenderAsFrom (unpack text) fullText css | ||
where | ||
fullText = "@media all and (" <> text <> "){}" | ||
css = query all [feature] emptyStyle | ||
|
||
infixr 0 `shouldRenderFromMediaType` | ||
|
||
infixr 0 `shouldRenderFromFeature` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.