diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1892bf5..4f0f99f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -37,3 +38,12 @@ jobs: - 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 81c7cae..a4cf596 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,26 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] +Breaking changes: + +New features: + +Bugfixes: + +Other improvements: + +## [v6.0.0](https://github.com/purescript-contrib/purescript-css/releases/tag/v6.0.0) - 2022-04-27 + 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) diff --git a/bower.json b/bower.json index b036f04..2fbdd9b 100644 --- a/bower.json +++ b/bower.json @@ -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": "^7.0.1", + "purescript-console": "^6.0.0", + "purescript-effect": "^4.0.0", + "purescript-nonempty": "^7.0.0", + "purescript-profunctor": "^6.0.0", + "purescript-strings": "^6.0.0", + "purescript-these": "^6.0.0", + "purescript-transformers": "^6.0.0" }, "devDependencies": { - "purescript-exceptions": "^5.0.0" + "purescript-aff": "^7.0.0", + "purescript-assert": "^6.0.0", + "purescript-control": "^6.0.0", + "purescript-exceptions": "^6.0.0", + "purescript-partial": "^4.0.0" } } diff --git a/packages.dhall b/packages.dhall index d30cf7d..582d6d3 100644 --- a/packages.dhall +++ b/packages.dhall @@ -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 diff --git a/spago.dhall b/spago.dhall index 432b1cc..42fe136 100644 --- a/spago.dhall +++ b/spago.dhall @@ -11,7 +11,6 @@ , "nonempty" , "prelude" , "profunctor" - , "psci-support" , "strings" , "these" , "transformers" diff --git a/src/CSS.purs b/src/CSS.purs index 4d6f9f7..092104a 100644 --- a/src/CSS.purs +++ b/src/CSS.purs @@ -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 diff --git a/src/CSS/Color.purs b/src/CSS/Color.purs index 57f593e..8337fa7 100644 --- a/src/CSS/Color.purs +++ b/src/CSS/Color.purs @@ -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) diff --git a/test.dhall b/test.dhall index 4e5f143..c137090 100644 --- a/test.dhall +++ b/test.dhall @@ -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", "assert", "control", "exceptions", "partial"] } diff --git a/test/CSS/BorderSpec.purs b/test/CSS/BorderSpec.purs index af04586..85ba0bb 100644 --- a/test/CSS/BorderSpec.purs +++ b/test/CSS/BorderSpec.purs @@ -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)" $ @@ -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 diff --git a/test/CSS/DisplaySpec.purs b/test/CSS/DisplaySpec.purs index 1b5d918..cfcf69b 100644 --- a/test/CSS/DisplaySpec.purs +++ b/test/CSS/DisplaySpec.purs @@ -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" $ diff --git a/test/Common.purs b/test/Common.purs index 7abf0b8..f149100 100644 --- a/test/Common.purs +++ b/test/Common.purs @@ -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 @@ -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 diff --git a/test/Main.purs b/test/Main.purs index 8e54d79..52cdca4 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -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 @@ -13,6 +13,8 @@ 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(..)) @@ -20,10 +22,8 @@ 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 @@ -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 diff --git a/test/Utils.purs b/test/Utils.purs new file mode 100644 index 0000000..2fefbb7 --- /dev/null +++ b/test/Utils.purs @@ -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 + +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 }