Skip to content

Commit 18cb3a2

Browse files
authored
Improvements to examples (resolves #10) (#13)
* Build one example at a time. * Type error examples now function as tests. * Pseudo-element type error examples * grid-template-columns type error examples * Add CHANGELOG entry for example improvements.
1 parent a47da1e commit 18cb3a2

18 files changed

+269
-139
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ New features:
2929
Bugfixes:
3030

3131
Other improvements:
32+
- New examples of type safety
33+
- [`TypeError.SelectorPseudoClassingPseudoElement`](examples/type-errors/SelectorPseudoClassingPseudoElement.purs)
34+
- [`TypeError.SelectorPseudoElementDescendant`](examples/type-errors/SelectorPseudoElementDescendant.purs)
35+
- [`TypeError.GridTemplateColumnsAutoRepeatWithFlex`](examples/type-errors/GridTemplateColumnsAutoRepeatWithFlex.purs)
36+
- [`TypeError.GridTemplateColumnsMultipleAutoRepeat`](examples/type-errors/GridTemplateColumnsMultipleAutoRepeat.purs)
37+
- The `check-examples` script now verifies that each `TypeError.*` example fails
38+
to compile.
3239

3340
## [0.1.3] - 2022-11-09
3441

example.dhall

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
let conf = ./spago.dhall
22

33
in conf // {
4-
sources = conf.sources # ["examples/**/*.purs"],
54
dependencies = conf.dependencies # ["console", "effect"]
65
}

examples/TypeSafety.purs

Lines changed: 0 additions & 107 deletions
This file was deleted.

examples/output/TypeSafety.css

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{-
2+
3+
This example fails to compile because a `@font-face` rule must include a
4+
`font-family` descriptor.
5+
6+
See https://www.w3.org/TR/css-fonts-4/#font-family-desc for more information.
7+
8+
-}
9+
10+
module TypeError.FontFaceMissingFontFamily where
11+
12+
import Tecton (CSS, fontFace, fontFamily, src, url, (?), (:=))
13+
14+
css :: CSS
15+
css = fontFace ? src := url "foo.woff"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{-
2+
3+
This example fails to compile because a `@font-face` rule must include a `src`
4+
descriptor.
5+
6+
See https://www.w3.org/TR/css-fonts-4/#src-desc for more information.
7+
8+
-}
9+
10+
module TypeError.FontFaceMissingSrc where
11+
12+
import Tecton (CSS, fontFace, fontFamily, (:=), (?))
13+
14+
css :: CSS
15+
css = fontFace ? fontFamily := "Roboto"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{-
2+
3+
This example fails to compile because the Fonts Module Level 4 specification
4+
encourages authors "to append a generic font family as a last alternative for
5+
improved robustness" within `font-family` declarations.
6+
7+
See https://www.w3.org/TR/css-fonts-4/#generic-family-value for more
8+
information.
9+
10+
-}
11+
12+
module TypeError.FontFamilyMissingFallback where
13+
14+
import Data.Tuple.Nested ((/\))
15+
import Tecton (CSS, fontFamily, universal, (:=), (?))
16+
17+
css :: CSS
18+
css = universal ? fontFamily := "Roboto" /\ "Arial"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{-
2+
3+
This example fails to compile because the gradient `<color-stop-list>` syntax
4+
does not allow two consecutive transition hints.
5+
6+
See https://www.w3.org/TR/css-images-3/#typedef-color-stop-list for more
7+
information.
8+
9+
-}
10+
11+
module TypeError.GradientConsecutiveTransitionHints where
12+
13+
import Prelude
14+
import Color (black, white)
15+
import Data.Tuple.Nested ((/\))
16+
import Tecton (CSS, backgroundImage, deg, linearGradient, pct, universal, (:=), (?))
17+
18+
css :: CSS
19+
css =
20+
universal ?
21+
backgroundImage :=
22+
linearGradient (deg 180) $ black /\ pct 40 /\ pct 50 /\ white
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{-
2+
3+
This example fails to compile because the gradient `<color-stop-list>` syntax
4+
requires at minimum two color stops.
5+
6+
See https://www.w3.org/TR/css-images-3/#typedef-color-stop-list for more
7+
information.
8+
9+
-}
10+
11+
module TypeError.GradientInsufficientColorStops where
12+
13+
import Color (black, white)
14+
import Tecton (CSS, backgroundImage, deg, linearGradient, universal, (?), (:=))
15+
16+
css :: CSS
17+
css = universal ? backgroundImage := linearGradient (deg 180) black
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{-
2+
3+
This example fails to compile because `<flex>` values (e.g. `1fr`) cannot appear
4+
in the same track list as `<auto-repeat>` values (e.g.
5+
`repeat(auto-fill, 100px 10%)`).
6+
7+
See https://www.w3.org/TR/css-grid-1/#typedef-auto-track-list for more
8+
information.
9+
10+
-}
11+
12+
module TypeError.GridTemplateColumnsAutoRepeatWithFlex where
13+
14+
import Data.Tuple.Nested ((/\))
15+
import Tecton (CSS, autoFill, fr, gridTemplateColumns, pct, px, repeat, universal, (?), (:=))
16+
17+
css :: CSS
18+
css =
19+
universal ?
20+
gridTemplateColumns := fr 1 /\ repeat autoFill (px 100 /\ pct 10)

0 commit comments

Comments
 (0)