Skip to content

Commit e3b1fa3

Browse files
committed
Introduce &:: operator for pseudo-elements.
1 parent 1c85c68 commit e3b1fa3

File tree

9 files changed

+97
-85
lines changed

9 files changed

+97
-85
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ Notable changes are documented in this file. The format is based on [Keep a Chan
55
## [Unreleased]
66

77
Breaking changes:
8+
- _For pseudo-elements only_, the `&:` operator has bee replaced by `&::`. Pseudo-classes continue to work with the `&:` operator. (nsaunders/purescript-tecton#33)
9+
10+
For example:
11+
12+
**Before**
13+
```purescript
14+
universal &: after ? content := ""
15+
```
16+
17+
**After**
18+
```purescript
19+
universal &:: after ? content := ""
20+
```
821

922
New features:
1023
- `box-sizing` property nsaunders/purescript-tecton#31

examples/ZenGarments.purs

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ import Tecton
156156
, width
157157
, (&.)
158158
, (&:)
159+
, (&::)
159160
, (&@)
160161
, (*=)
161162
, (:=)
@@ -231,8 +232,8 @@ main = log $ renderSheet pretty do
231232

232233
label ? Rule.do
233234
fontSize := rem 1.6
234-
( input &. "empty" &: placeholder
235-
/\ textarea &. "empty" &: placeholder
235+
( input &. "empty" &:: placeholder
236+
/\ textarea &. "empty" &:: placeholder
236237
) ? Rule.do
237238
color := rgb 255 0 0
238239
universal &. "error" ? Rule.do
@@ -265,7 +266,7 @@ main = log $ renderSheet pretty do
265266
transitionDuration := sec 0.25
266267
transitionTimingFunction := linear
267268

268-
a &: after ? Rule.do
269+
a &:: after ? Rule.do
269270
content := ""
270271
display := block
271272
backgroundColor := hsl 37.0 0.33 0.48
@@ -281,7 +282,7 @@ main = log $ renderSheet pretty do
281282

282283
a &: hover /\ a &: focus ? Rule.do
283284
color := black
284-
a &: hover &: after /\ a &: focus &: after ? Rule.do
285+
a &: hover &:: after /\ a &: focus &:: after ? Rule.do
285286
opacity := 1
286287
bottom := nil
287288

@@ -313,7 +314,7 @@ main = log $ renderSheet pretty do
313314
sub /\ sup ? Rule.do
314315
lineHeight := 0
315316

316-
universal &: selection ? Rule.do
317+
universal &:: selection ? Rule.do
317318
backgroundColor := rgb 213 217 220
318319
color := rgb 51 51 51
319320

@@ -332,7 +333,7 @@ main = log $ renderSheet pretty do
332333
overflow := hidden
333334

334335
-- Easy Clearing - http://www.positioniseverything.net/easyclearing.html
335-
universal &. "clearfix" &: after ? Rule.do
336+
universal &. "clearfix" &:: after ? Rule.do
336337
content := "."
337338
display := block
338339
height := nil
@@ -387,9 +388,9 @@ main = log $ renderSheet pretty do
387388
) ? Rule.do
388389
fontWeight := 900
389390

390-
( universal &. "main" |* h3 &: after
391-
/\ universal &. "preamble" |* h3 &: after
392-
/\ universal &. "select" &: after
391+
( universal &. "main" |* h3 &:: after
392+
/\ universal &. "preamble" |* h3 &:: after
393+
/\ universal &. "select" &:: after
393394
) ? Rule.do
394395
visibility := visible
395396
display := block
@@ -409,11 +410,11 @@ main = log $ renderSheet pretty do
409410
) ? Rule.do
410411
transitionProperty := none
411412

412-
( universal &. "next" |* a &: after
413-
/\ universal &. "previous" |* a &: after
414-
/\ universal &. "viewall" |* a &: after
415-
/\ universal &. "zen-resources" |* a &: after
416-
/\ universal &. "summary" |* p &: nthChild (nth 0 2) |* a &: after
413+
( universal &. "next" |* a &:: after
414+
/\ universal &. "previous" |* a &:: after
415+
/\ universal &. "viewall" |* a &:: after
416+
/\ universal &. "zen-resources" |* a &:: after
417+
/\ universal &. "summary" |* p &: nthChild (nth 0 2) |* a &:: after
417418
) ? Rule.do
418419
opacity := 0
419420

@@ -427,11 +428,11 @@ main = log $ renderSheet pretty do
427428
fontWeight := 900
428429
color := hsl 216.0 0.53 0.2
429430
visibility := hidden
430-
universal &@ role @= "banner" |* h1 &: before ? Rule.do
431+
universal &@ role @= "banner" |* h1 &:: before ? Rule.do
431432
content := "CSS Zen Garments"
432433
visibility := visible
433434
display := block
434-
universal &@ role @= "banner" |* h1 &: after ? Rule.do
435+
universal &@ role @= "banner" |* h1 &:: after ? Rule.do
435436
content := "Made Locally"
436437
visibility := visible
437438
display := block
@@ -447,7 +448,7 @@ main = log $ renderSheet pretty do
447448
textTransform := uppercase
448449
fontWeight := 400
449450
color := rgba 41 78 134 0.5
450-
universal &@ role @= "banner" |* h2 &: after ? Rule.do
451+
universal &@ role @= "banner" |* h2 &:: after ? Rule.do
451452
content := "Impeccable Quality"
452453
visibility := visible
453454
display := block
@@ -467,28 +468,28 @@ main = log $ renderSheet pretty do
467468
backgroundImage := url "i/sep.png"
468469
backgroundRepeat := noRepeat
469470
backgroundPosition := pct 50 ~ nil
470-
universal &. "preamble" |* h3 &: after ? Rule.do
471+
universal &. "preamble" |* h3 &:: after ? Rule.do
471472
visibility := visible
472473
content := "A Fashion-Forward Future"
473474

474475
-- Explanation
475476

476-
universal &. "explanation" |* h3 &: after ? Rule.do
477+
universal &. "explanation" |* h3 &:: after ? Rule.do
477478
content := "See Yourself in a Different Way"
478479

479480
-- Participation
480481

481-
universal &. "participation" |* h3 &: after ? Rule.do
482+
universal &. "participation" |* h3 &:: after ? Rule.do
482483
content := "Get Into a Brand New Pair"
483484

484485
-- Benefits
485486

486-
universal &. "benefits" |* h3 &: after ? Rule.do
487+
universal &. "benefits" |* h3 &:: after ? Rule.do
487488
content := "Look Great\\2026 and Feel Great Too!"
488489

489490
-- Requirements
490491

491-
universal &. "requirements" |* h3 &: after ? Rule.do
492+
universal &. "requirements" |* h3 &:: after ? Rule.do
492493
content := "“One Size Fits” All Be Damned!"
493494
textIndent := em (-0.5)
494495

@@ -500,7 +501,7 @@ main = log $ renderSheet pretty do
500501
listStyleType := none
501502
width := pct 94
502503
margin := nil ~ auto
503-
universal &. "design-selection" |* ul &: after ? Rule.do
504+
universal &. "design-selection" |* ul &:: after ? Rule.do
504505
content := "."
505506
display := block
506507
height := nil
@@ -525,18 +526,18 @@ main = log $ renderSheet pretty do
525526
textTransform := uppercase
526527
letterSpacing := em 0.1
527528
position := relative
528-
universal &. "design-name" &: after ? Rule.do
529+
universal &. "design-name" &:: after ? Rule.do
529530
backgroundImage := none
530531
opacity := 0
531532
universal &. "design-name" &: hover ? Rule.do
532533
fontStyle := italic
533534

534535
universal &. "designer-name" ? Rule.do
535536
color := rgb 121 137 163
536-
universal &. "designer-name" &: after /\ footer |* a &: after ? Rule.do
537+
universal &. "designer-name" &:: after /\ footer |* a &:: after ? Rule.do
537538
height := px 1
538539

539-
universal &. "select" &: after ? Rule.do
540+
universal &. "select" &:: after ? Rule.do
540541
content := "Washes & Styles"
541542
fontSize := rem 1.8
542543
textAlign := center
@@ -621,7 +622,7 @@ main = log $ renderSheet pretty do
621622
listStyleType := none
622623
margin := em 2 ~ nil ~ em 4
623624
textAlign := center
624-
universal &. "zen-resources" |* ul &: before ? Rule.do
625+
universal &. "zen-resources" |* ul &:: before ? Rule.do
625626
content := ""
626627
height := px 4
627628
width := px 80
@@ -687,7 +688,7 @@ main = log $ renderSheet pretty do
687688
backgroundAttachment := fixed
688689
backgroundPosition := pct 90 ~ pct 80
689690

690-
universal &. "intro" &: before ? Rule.do
691+
universal &. "intro" &:: before ? Rule.do
691692
content := ""
692693
display := block
693694
width := px 105
@@ -715,7 +716,7 @@ main = log $ renderSheet pretty do
715716
textAlign := left
716717
fontSize := rem 1.5
717718
letterSpacing := nil
718-
universal &@ role @= "article" |* h3 &: after ? Rule.do
719+
universal &@ role @= "article" |* h3 &:: after ? Rule.do
719720
position := absolute
720721
top := nil
721722

@@ -727,7 +728,7 @@ main = log $ renderSheet pretty do
727728
fontSize := rem 4.8
728729
letterSpacing := nil
729730
lineHeight := 0.8
730-
universal &@ role @= "banner" |* h1 &: after ? Rule.do
731+
universal &@ role @= "banner" |* h1 &:: after ? Rule.do
731732
position := absolute
732733
top := em 15.7
733734
right := pct 30
@@ -739,7 +740,7 @@ main = log $ renderSheet pretty do
739740
left := pct 75.5
740741
fontSize := rem 1.9
741742
lineHeight := 1
742-
universal &@ role @= "banner" |* h2 &: before ? Rule.do
743+
universal &@ role @= "banner" |* h2 &:: before ? Rule.do
743744
visibility := visible
744745
content := "Est. 2003"
745746
display := block
@@ -765,7 +766,7 @@ main = log $ renderSheet pretty do
765766
top := em 2
766767
fontSize := rem 1.4
767768

768-
universal &. "summary" |* p &: nthChild (nth 0 2) &: before ? Rule.do
769+
universal &. "summary" |* p &: nthChild (nth 0 2) &:: before ? Rule.do
769770
content := ""
770771
display := block
771772
visibility := visible
@@ -779,7 +780,7 @@ main = log $ renderSheet pretty do
779780
width := em 6
780781
height := px 30
781782

782-
universal &. "summary" |* p &: nthChild (nth 0 2) &: after ? Rule.do
783+
universal &. "summary" |* p &: nthChild (nth 0 2) &:: after ? Rule.do
783784
content := ""
784785
display := block
785786
visibility := visible
@@ -874,7 +875,7 @@ main = log $ renderSheet pretty do
874875
) ? Rule.do
875876
width := pct 100
876877
padding := nil
877-
universal &. "select" &: after ? Rule.do
878+
universal &. "select" &:: after ? Rule.do
878879
textAlign := left
879880
backgroundPosition := nil ~ bottom
880881
padding := nil ~ nil ~ em 2

examples/type-errors/SelectorMultiplePseudoElements.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import Tecton
2121
, currentColor
2222
, placeholder
2323
, universal
24-
, (&:)
24+
, (&::)
2525
, (:=)
2626
, (?)
2727
)
2828
import Tecton.Rule as Rule
2929

3030
css :: CSS
3131
css =
32-
universal &: placeholder &: after ? Rule.do
32+
universal &:: placeholder &:: after ? Rule.do
3333
color := currentColor

examples/type-errors/SelectorPseudoClassingPseudoElement.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import Tecton
2020
, underline
2121
, universal
2222
, (&:)
23+
, (&::)
2324
, (:=)
2425
, (?)
2526
)
2627
import Tecton.Rule as Rule
2728

2829
css :: CSS
2930
css =
30-
universal &: after &: hover ? Rule.do
31+
universal &:: after &: hover ? Rule.do
3132
textDecorationLine := underline

examples/type-errors/SelectorPseudoElementDescendant.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ information.
1010

1111
module TypeError.SelectorPseudoElementDescendant where
1212

13-
import Tecton (CSS, after, nil, universal, width, (&:), (:=), (?), (|*))
13+
import Tecton (CSS, after, nil, universal, width, (&::), (:=), (?), (|*))
1414
import Tecton.Rule as Rule
1515

1616
css :: CSS
1717
css =
18-
universal &: after |* universal ? Rule.do
18+
universal &:: after |* universal ? Rule.do
1919
width := nil

src/Tecton.purs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ import Tecton.Internal
713713
, (&#)
714714
, (&.)
715715
, (&:)
716+
, (&::)
716717
, (&@)
717718
, (*=)
718719
, (*@)

0 commit comments

Comments
 (0)