Skip to content

Commit c08ec00

Browse files
author
Richard Feldman
committed
Revert "Use multiple tags for |%| and |%>|"
This reverts commit 42f5639bbfb31a84e772e9e1f7a559901cd1b83d.
1 parent 805a3ad commit c08ec00

File tree

2 files changed

+31
-42
lines changed

2 files changed

+31
-42
lines changed

src/Stylesheets.elm

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,23 @@ attributeToString (Attribute str) =
6767

6868
{- Tags -}
6969

70-
html = [ Tag "html" ]
71-
body = [ Tag "body" ]
72-
div = [ Tag "div" ]
73-
span = [ Tag "span" ]
74-
nowrap = [ Tag "nowrap" ]
75-
button = [ Tag "button" ]
76-
h1 = [ Tag "h1" ]
77-
h2 = [ Tag "h2" ]
78-
h3 = [ Tag "h3" ]
79-
h4 = [ Tag "h4" ]
80-
p = [ Tag "p" ]
81-
ol = [ Tag "ol" ]
82-
input = [ Tag "input" ]
70+
html = Tag "html"
71+
body = Tag "body"
72+
div = Tag "div"
73+
span = Tag "span"
74+
nowrap = Tag "nowrap"
75+
button = Tag "button"
76+
h1 = Tag "h1"
77+
h2 = Tag "h2"
78+
h3 = Tag "h3"
79+
h4 = Tag "h4"
80+
p = Tag "p"
81+
ol = Tag "ol"
82+
input = Tag "input"
8383

8484
tagToString (Tag str) = str
8585

8686

87-
type alias ElementSelector =
88-
List Tag
89-
90-
customElement : String -> ElementSelector
91-
customElement str =
92-
[ Tag str ]
93-
94-
95-
9687
-- TODO these are just for @media - maybe improve type guarantees?
9788
screen = "screen"
9889
print = "print"
@@ -412,8 +403,14 @@ styleWithPrefix prefix (Style selector attrs children) childSelector =
412403
|> Style selector attrs
413404

414405

415-
(|%|) : Style class id -> ElementSelector -> Style class id
416-
(|%|) (Style selector attrs children) tags =
406+
(|%|) : Style class id -> Tag -> Style class id
407+
(|%|) (Style selector attrs children) tag =
408+
children ++ [ Style (tagToString tag) [] [] ]
409+
|> Style selector attrs
410+
411+
412+
(|%|...) : Style class id -> List Tag -> Style class id
413+
(|%|...) (Style selector attrs children) tags =
417414
let
418415
childSelector =
419416
tags
@@ -433,24 +430,16 @@ styleWithPrefix prefix (Style selector attrs children) childSelector =
433430

434431

435432
-- TODO use tagToString
436-
(|>%|) : Style class id -> ElementSelector -> Style class id
437-
(|>%|) (Style selector attrs children) tags =
438-
let
439-
selectorFromTag tag =
440-
case splitStartLast children of
441-
( _, Nothing ) ->
442-
selector ++ " > " ++ tagToString tag
443-
444-
( start, Just (Style activeSelector _ _) ) ->
445-
activeSelector ++ " > " ++ tagToString tag
433+
(|>%|) : Style class id -> Tag -> Style class id
434+
(|>%|) (Style selector attrs children) tag =
435+
case splitStartLast children of
436+
( _, Nothing ) ->
437+
children ++ [ Style (selector ++ " > " ++ tagToString tag) [] [] ]
438+
|> Style selector attrs
446439

447-
childSelector =
448-
tags
449-
|> List.map selectorFromTag
450-
|> String.join ", "
451-
in
452-
children ++ [ Style childSelector [] [] ]
453-
|> Style selector attrs
440+
( start, Just (Style activeSelector _ _) ) ->
441+
children ++ [ Style (activeSelector ++ " > " ++ tagToString tag) [] [] ]
442+
|> Style selector attrs
454443

455444

456445
(|.|) : Style class id -> class -> Style class id

test/Fixtures.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ divWidthHeight =
2121
dreamwriter : Style CssClasses CssIds
2222
dreamwriter =
2323
stylesheet
24-
|%| (html ++ body)
24+
|%|... [ html, body ]
2525
|-| width 100 pct
2626
|-| height 100 pct
2727
|-| boxSizing borderBox

0 commit comments

Comments
 (0)