Skip to content

Update to PureScript v0.15.0 #156

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

Merged
merged 13 commits into from
Mar 23, 2022
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
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- name: Set up a PureScript toolchain
uses: purescript-contrib/setup-purescript@main
with:
purescript: "unstable"
purs-tidy: "latest"

- name: Cache PureScript dependencies
Expand All @@ -32,8 +33,17 @@ jobs:
- name: Build source
run: spago build --no-install --purs-args '--censor-lib --strict'

- name: Run tests
run: spago -x test.dhall test
# - name: Run tests
# run: spago -x test.dhall test

- name: Check formatting
run: purs-tidy check src test

- name: Verify Bower & Pulp
run: |
npm install bower pulp@16.0.0-0
npx bower install
npx pulp build -- --censor-lib --strict
if [ -d "test" ]; then
npx pulp test
fi
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Breaking changes:
- Add support for `calc` expressions (#140 by @nsaunders)
- Add table selector (#141 by @plurip-software)
- Update the box-shadow implementation (#88 by @vyorkin)
- Update project and deps to PureScript v0.15.0 (#156 by @JordanMartinez)
- Dropped almost all named colors (#156 by @JordanMartinez)

These colors were originally defined in `purescript-colors` (i.e.
one module per schema) because each schema should be defined as its
own library. This change was propagated to this release.

New features:
- Add smart constructors for generic font families (#68, #136 by @Unisay and @JordanMartinez)
Expand Down
22 changes: 13 additions & 9 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@
"tests"
],
"dependencies": {
"purescript-colors": "^6.0.0",
"purescript-console": "^5.0.0",
"purescript-effect": "^3.0.0",
"purescript-nonempty": "^6.0.0",
"purescript-profunctor": "^5.0.0",
"purescript-strings": "^5.0.0",
"purescript-these": "^5.0.0",
"purescript-transformers": "^5.0.0"
"purescript-colors": "main",
"purescript-console": "master",
"purescript-effect": "master",
"purescript-nonempty": "master",
"purescript-profunctor": "master",
"purescript-strings": "master",
"purescript-these": "main",
"purescript-transformers": "master"
},
"devDependencies": {
"purescript-exceptions": "^5.0.0"
"purescript-aff": "main",
"purescript-assert": "master",
"purescript-control": "master",
"purescript-exceptions": "master",
"purescript-partial": "master"
}
}
2 changes: 1 addition & 1 deletion packages.dhall
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.5-20211116/packages.dhall sha256:7ba810597a275e43c83411d2ab0d4b3c54d0b551436f4b1632e9ff3eb62e327a
https://raw.githubusercontent.com/purescript/package-sets/prepare-0.15/src/packages.dhall

in upstream
1 change: 0 additions & 1 deletion spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
, "nonempty"
, "prelude"
, "profunctor"
, "psci-support"
, "strings"
, "these"
, "transformers"
Expand Down
2 changes: 1 addition & 1 deletion src/CSS.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CSS.Animation (AnimationDirection(..), AnimationName(..), FillMode(..), I
import CSS.Background (class Background, class Loc, BackgroundAttachment, BackgroundClip, BackgroundImage, BackgroundOrigin, BackgroundPosition, BackgroundRepeat, BackgroundSize, Direction, Location, Side, angular, attachFixed, attachScroll, background, backgroundAttachment, backgroundAttachments, backgroundClip, backgroundClips, backgroundColor, backgroundImage, backgroundImages, backgroundOrigin, backgroundOrigins, backgroundPosition, backgroundPositions, backgroundRepeat, backgroundRepeats, backgroundSize, backgroundSizes, boxClip, by, contain, cover, location, noRepeat, origin, placed, positioned, repeat, repeatX, repeatY, round, sideBottom, sideCenter, sideLeft, sideMiddle, sideRight, sideTop, space, straight, url, xyRepeat) as X
import CSS.Border (Stroke(..), border, borderBottom, borderColor, borderLeft, borderRadius, borderRight, borderSpacing, borderTop, dashed, dotted, double, groove, inset, outline, outlineColor, outlineOffset, outlineStyle, outlineWidth, outset, ridge, solid, wavy) as X
import CSS.Box (BoxType, BoxShadow, borderBox, boxShadow, boxSizing, contentBox, paddingBox) as X
import CSS.Color (Color, ColorSpace(..), aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brightness, brown, burlywood, cadetblue, chartreuse, chocolate, complementary, contrast, coral, cornflowerblue, cornsilk, crimson, cssStringHSLA, cssStringRGBA, cyan, darkblue, darkcyan, darken, darkgoldenrod, darkgray, darkgreen, darkgrey, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, desaturate, dimgray, dimgrey, distance, dodgerblue, firebrick, floralwhite, forestgreen, fromHexString, fromInt, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, graytone, green, greenyellow, grey, honeydew, hotpink, hsl, hsla, indianred, indigo, isLight, isReadable, ivory, khaki, lab, lavender, lavenderblush, lawngreen, lch, lemonchiffon, lightblue, lightcoral, lightcyan, lighten, lightgoldenrodyellow, lightgray, lightgreen, lightgrey, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, luminance, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, mix, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rgb, rgb', rgba, rgba', rosybrown, rotateHue, royalblue, saddlebrown, salmon, sandybrown, saturate, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, textColor, thistle, toGray, toHSLA, toHexString, toLCh, toLab, toRGBA, toRGBA', toXYZ, tomato, turquoise, violet, wheat, white, whitesmoke, xyz, yellow, yellowgreen) as X
import CSS.Color (Color, ColorSpace(..), black, brightness, complementary, contrast, cssStringHSLA, cssStringRGBA, darken, desaturate, distance, fromHexString, fromInt, graytone, hsl, hsla, isLight, isReadable, lab, lch, lighten, luminance, mix, rgb, rgb', rgba, rgba', rotateHue, saturate, textColor, toGray, toHSLA, toHexString, toLCh, toLab, toRGBA, toRGBA', toXYZ, white, xyz) as X
import CSS.Display (ClearFloat(..), Display(..), Float(..), Position(..), absolute, block, clear, clearBoth, clearInlineEnd, clearInlineStart, clearLeft, clearRight, display, displayInherit, displayNone, fixed, flex, float, floatLeft, floatRight, grid, inline, inlineBlock, inlineFlex, inlineGrid, inlineTable, listItem, position, relative, runIn, static, displayTable, tableCaption, tableCell, tableColumn, tableColumnGroup, tableFooterGroup, tableHeaderGroup, tableRow, tableRowGroup, visibility, collapse, zIndex, opacity) as X
import CSS.Elements (table, a, abbr, address, area, article, aside, audio, b, bdi, bdo, blockquote, body, br, button, canvas, caption, cite, code, col, colgroup, datalist, dd, del, details, dfn, div, dl, dt, embed, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hr, html, i, iframe, img, input, ins, kbd, label, legend, li, main, map, mark, meter, nav, object, ol, optgroup, output, p, pre, progress, q, s, samp, section, small, span, strong, sub, summary, sup, tbody, td, textarea, tfoot, th, thead, tr, u, ul, var) as X
import CSS.Flexbox (class FlexEnd, class FlexStart, class SpaceAround, class SpaceBetween, class Stretch, AlignContentValue(..), AlignItemsValue(..), AlignSelfValue(..), FlexDirection(..), FlexWrap(..), JustifyContentValue(..), alignContent, alignItems, alignSelf, column, columnReverse, flexBasis, flexDirection, flexEnd, flexFlow, flexGrow, flexShrink, flexStart, flexWrap, justifyContent, nowrap, order, row, rowReverse, spaceAround, spaceBetween, stretch, wrap, wrapReverse) as X
Expand Down
2 changes: 0 additions & 2 deletions src/CSS/Color.purs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module CSS.Color
( module Color
, module Color.Scheme.X11
) where

import Color (Color, ColorSpace(..), black, brightness, complementary, contrast, cssStringHSLA, cssStringRGBA, darken, desaturate, distance, fromHexString, fromInt, graytone, hsl, hsla, isLight, isReadable, lab, lch, lighten, luminance, mix, rgb, rgb', rgba, rgba', rotateHue, saturate, textColor, toGray, toHSLA, toHexString, toLCh, toLab, toRGBA, toRGBA', toXYZ, white, xyz)
import Color.Scheme.X11 (aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen, darkgrey, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, green, greenyellow, grey, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgreen, lightgrey, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, whitesmoke, yellow, yellowgreen)
2 changes: 1 addition & 1 deletion test.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ let conf = ./spago.dhall

in conf // {
sources = conf.sources # ["test/**/*.purs"],
dependencies = conf.dependencies # ["aff", "control", "exceptions", "partial", "spec"]
dependencies = conf.dependencies # ["aff", "control", "exceptions", "partial"]
}
11 changes: 6 additions & 5 deletions test/CSS/BorderSpec.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ module CSS.BorderSpec where
import Prelude

import CSS.Border (dashed, dotted, double, groove, inset, outline, outlineColor, outlineOffset, outlineStyle, outlineWidth, ridge, solid)
import CSS.Color (green)
import CSS.Color as Color
import CSS.Common (inherit, initial, unset)
import CSS.Size (em, px)
import Common (shouldRenderFrom)
import Common (shouldRenderFrom, green, blue)
import Control.Monad.Reader.Class (class MonadReader)
import Data.Maybe (fromJust)
import Data.Traversable (traverse_)
import Data.Tuple.Nested ((/\))
import Effect.Aff.Class (class MonadAff)
import Partial.Unsafe (unsafePartial)
import Test.Spec (Spec, describe)
import Test.Utils (describe)

spec :: Spec Unit
spec :: forall m. MonadReader Int m => MonadAff m => m Unit
spec = do

describe "outline (Mozilla examples)" $
Expand Down Expand Up @@ -50,7 +51,7 @@ spec = do
testOutlineColor
[ "hsl(0.0, 94.64%, 56.08%)" /\ (unsafePartial $ fromJust $ Color.fromHexString "#f92525")
, "hsl(148.44, 76.19%, 49.41%)" /\ Color.rgb 30 222 121
, "hsl(240.0, 100.0%, 50.0%)" /\ Color.blue
, "hsl(240.0, 100.0%, 50.0%)" /\ blue
]

describe "outline-width (Mozilla examples)" do
Expand Down
12 changes: 4 additions & 8 deletions test/CSS/DisplaySpec.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ module CSS.DisplaySpec where

import Prelude

import CSS.Color (green)
import CSS.Color as Color
import CSS.Common (hidden, inherit, initial, unset, visible)
import CSS.Display (collapse, visibility)
import CSS.Size (em, px)
import Common (shouldRenderFrom)
import Data.Maybe (fromJust)
import Control.Monad.Reader.Class (class MonadReader)
import Data.Traversable (traverse_)
import Data.Tuple.Nested ((/\))
import Partial.Unsafe (unsafePartial)
import Test.Spec (Spec, describe)
import Effect.Aff.Class (class MonadAff)
import Test.Utils (describe)

spec :: Spec Unit
spec :: forall m. MonadReader Int m => MonadAff m => m Unit
spec = do

describe "visibility (Mozilla examples)" do
let testVisibility (s /\ v) = ("visibility: " <> s) `shouldRenderFrom` visibility v
describe "Keyword values" $
Expand Down
39 changes: 30 additions & 9 deletions test/Common.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@ import Prelude

import CSS (renderedInline)
import CSS.Render (render, renderedSheet)
import CSS.Color (Color, rgb)
import CSS.Stylesheet (CSS)
import Control.Alt ((<|>))
import Control.Monad.Error.Class (class MonadThrow)
import Effect.Exception (Error)
import Test.Spec (SpecT, it)
import Test.Spec.Assertions (shouldEqual)
import Control.Monad.Reader.Class (class MonadReader)
import Effect.Aff.Class (class MonadAff)
import Test.Utils (it, shouldEqual)

shouldRenderFrom
:: forall g m
. Monad m
=> MonadThrow Error g
:: forall m
. MonadReader Int m
=> MonadAff m
=> String
-> CSS
-> SpecT g Unit m Unit
-> m Unit
shouldRenderFrom expected given =
it ("renders " <> expected) $ expected `shouldRenderItFrom` given

shouldRenderItFrom
:: forall m
. MonadThrow Error m
. MonadReader Int m
=> MonadAff m
=> String
-> CSS
-> m Unit
Expand All @@ -33,3 +34,23 @@ shouldRenderItFrom expected given =
actual = renderedInline r <|> renderedSheet r
in
actual `shouldEqual` pure expected

-- Colors below are originally from the X11 scheme:
-- https://github.com/purescript-contrib/purescript-colors/blob/b65b99478ce97adc819950de0316e46a941571dd/src/Color/Scheme/X11.purs
green :: Color
green = rgb 0 128 0

blue :: Color
blue = rgb 0 0 255

red :: Color
red = rgb 255 0 0

gold :: Color
gold = rgb 255 215 0

teal :: Color
teal = rgb 0 128 128

olive :: Color
olive = rgb 128 128 0
10 changes: 5 additions & 5 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Test.Main where

import Prelude

import CSS (Rendered, Path(..), Predicate(..), Refinement(..), Selector(..), FontFaceSrc(..), FontFaceFormat(..), pct, renderedSheet, renderedInline, fromString, selector, block, display, render, borderBox, boxSizing, contentBox, blue, color, body, a, p, px, dashed, border, inlineBlock, red, gold, teal, olive, black, (?), (&), (|>), (|*), (|+), byId, byClass, (@=), (^=), ($=), (*=), (~=), (|=), hover, fontFaceSrc, fontStyle, deg, rgba, zIndex, textOverflow, opacity, cursor, transform, transition, easeInOut, cubicBezier, ms, direction, width, em, (@+@), (@-@), (@*), (*@), (@/))
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.Cursor as Cursor
Expand All @@ -13,17 +13,17 @@ import CSS.Text.Overflow as TextOverflow
import CSS.Transform as Transform
import CSS.Common (none)
import CSS.Box (boxShadow, shadow, shadowWithBlur, shadowWithSpread, bsColor, bsInset)
import Common (blue, gold, red, teal, olive)
import Control.Monad.Reader (runReaderT)
import Control.Monad.RWS (modify_)
import Control.Monad.State (StateT, execStateT)
import Data.Maybe (Maybe(..))
import Data.NonEmpty (singleton, (:|))
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Class (liftEffect)
import Effect.Class.Console (log)
import Effect.Console (log)
import Effect.Exception (error, throwException)
import Test.Spec.Reporter (consoleReporter)
import Test.Spec.Runner (runSpec)

example1 :: Rendered
example1 = render do
Expand Down Expand Up @@ -292,6 +292,6 @@ main = do
log $ "\x1b[32m" <> show count <> " test" <> if count == 1 then "" else "s" <> " passed. These will be migrated to the new format in the future.\x1b[0m\n"

launchAff_ $
runSpec [ consoleReporter ] do
flip runReaderT 0 do
BorderSpec.spec
DisplaySpec.spec
28 changes: 28 additions & 0 deletions test/Utils.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Test.Utils where

import Prelude

import Control.Monad.Reader.Class (class MonadReader, ask, local)
import Data.Monoid (power, guard)
import Effect.Console (log)
import Effect.Class (liftEffect)
import Effect.Aff.Class (class MonadAff)
import Test.Assert (assertEqual)

-----------------------------------------------------------------

-- Provide similar API to purescript-spec to reduce code changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For those who aren't aware, this is done so that we don't depend on spec (a testing library external to the organization).


describe :: forall m. MonadReader Int m => MonadAff m => String -> m Unit -> m Unit
describe msg runTest = do
indentation <- ask
let spacing = guard (indentation > 0) " "
liftEffect $ log $ (power ">>" indentation) <> spacing <> msg
local (_ + 1) runTest

it :: forall m. MonadReader Int m => MonadAff m => String -> m Unit -> m Unit
it = describe

shouldEqual :: forall m a. MonadAff m => Eq a => Show a => a -> a -> m Unit
shouldEqual actual expected =
liftEffect $ assertEqual { actual, expected }