Skip to content

Commit 1826e9f

Browse files
extends escaped character list
1 parent b8e284b commit 1826e9f

File tree

5 files changed

+130
-6
lines changed

5 files changed

+130
-6
lines changed

examples/src/Examples/Progress.elm

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
module Examples.Progress exposing (examples)
2+
3+
import Element exposing (..)
4+
import Element.Background as Background
5+
import Element.Border as Border
6+
import Simple.Animation as Animation exposing (Animation)
7+
import Simple.Animation.Property as P
8+
import Utils.Animated as Animated
9+
import Utils.UI exposing (blue, group, groups, small)
10+
11+
12+
13+
-- Animation
14+
15+
16+
animateProgress : Float -> Animation
17+
animateProgress percent_ =
18+
Animation.fromTo
19+
{ duration = 2000
20+
, options = []
21+
}
22+
[ P.property "clip-path" (insetPercent 0) ]
23+
[ P.property "clip-path" (insetPercent percent_) ]
24+
25+
26+
insetPercent : Float -> String
27+
insetPercent n =
28+
"inset(0 " ++ pc (100 - n) ++ " 0 0)"
29+
30+
31+
pc : Float -> String
32+
pc n =
33+
String.fromFloat n ++ "%"
34+
35+
36+
37+
-- Progress Bar
38+
39+
40+
progressBar : Float -> Element msg
41+
progressBar percent =
42+
el
43+
[ width (fill |> maximum 300)
44+
, height (px 22)
45+
, Border.width 2
46+
, Border.rounded 20
47+
]
48+
(Animated.el (animateProgress percent)
49+
[ width fill
50+
, height fill
51+
, Background.color blue
52+
, Border.rounded 20
53+
]
54+
none
55+
)
56+
57+
58+
59+
-- Examples
60+
61+
62+
examples : Element msg -> Element msg
63+
examples =
64+
groups
65+
[ group "clip-path Progress Bars" progressBars
66+
]
67+
68+
69+
progressBars : Element msg
70+
progressBars =
71+
column [ spacing small, width fill ]
72+
[ progressBar 100
73+
, progressBar 50
74+
, progressBar 30
75+
]

examples/src/Examples/Renderers.elm

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ typedCircle =
126126
examples : Element msg -> Element msg
127127
examples =
128128
groups
129-
[ group "With HTML" (Element.html htmlExample)
130-
, group "With SVG" (Element.html svgExample)
131-
, group "With Typed SVG" (Element.html typedSvgExample)
129+
[ group "With HTML" (html htmlExample)
130+
, group "With SVG" (html svgExample)
131+
, group "With Typed SVG" (html typedSvgExample)
132132
]
133133

134134

@@ -143,6 +143,7 @@ stylesheet =
143143
.text {
144144
color: white;
145145
border-radius: 10px;
146+
text-align: center;
146147
margin: 12px 0;
147148
padding: 24px;
148149
}
@@ -151,3 +152,8 @@ stylesheet =
151152
fill: blue;
152153
}
153154
"""
155+
156+
157+
html : Html msg -> Element msg
158+
html =
159+
Element.html >> Element.el [ Element.width (Element.fill |> Element.maximum 200) ]

examples/src/Main.elm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Element exposing (..)
55
import Element.Events exposing (onClick)
66
import Element.Font as Font
77
import Examples.FromTo as FromTo
8+
import Examples.Progress as Progress
89
import Examples.Renderers as Renderers
910
import Examples.Sequence as Sequence
1011
import Examples.Steps as Steps
@@ -39,6 +40,7 @@ type Example
3940
| Steps
4041
| Sequence
4142
| Renderers
43+
| Progress
4244

4345

4446
type Msg
@@ -94,13 +96,17 @@ examples model =
9496
Renderers ->
9597
Renderers.examples
9698

99+
Progress ->
100+
Progress.examples
101+
97102

98103
buttons : Example -> Element Msg
99104
buttons selected =
100105
[ ( FromTo, "FromTo" )
101106
, ( Steps, "Steps" )
102107
, ( Sequence, "Sequence" )
103108
, ( Renderers, "Renderers" )
109+
, ( Progress, "Progress" )
104110
]
105111
|> List.map (button selected)
106112
|> row [ spacing medium ]

examples/src/Utils/UI.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ groups els controls =
4747

4848
group : String -> Element msg -> Element msg
4949
group label x =
50-
column [ spacing medium ] [ text label, x ]
50+
column [ spacing medium, width fill ] [ text label, x ]
5151

5252

5353

src/Internal/Property.elm

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Internal.Property exposing
55
)
66

77
import Internal.Transform as Transform exposing (Transform)
8+
import Set exposing (Set)
89

910

1011

@@ -31,7 +32,7 @@ name prop =
3132
Transform.name t
3233

3334
Raw n p ->
34-
n ++ escape p
35+
escape n ++ escape p
3536

3637

3738
escape : String -> String
@@ -41,7 +42,43 @@ escape =
4142

4243
escapedChars : Char -> Bool
4344
escapedChars c =
44-
not (List.member c [ '.', '#', ',', '(', ')', ' ' ])
45+
not (Set.member c escapedChars_)
46+
47+
48+
escapedChars_ : Set Char
49+
escapedChars_ =
50+
Set.fromList
51+
[ '.'
52+
, ' '
53+
, ','
54+
, '#'
55+
, '$'
56+
, '%'
57+
, '('
58+
, ')'
59+
, '&'
60+
, ';'
61+
, ':'
62+
, '"'
63+
, '\''
64+
, '*'
65+
, '~'
66+
, '!'
67+
, '@'
68+
, '^'
69+
, '+'
70+
, '='
71+
, '/'
72+
, '?'
73+
, '>'
74+
, '<'
75+
, '['
76+
, ']'
77+
, '{'
78+
, '}'
79+
, '|'
80+
, '`'
81+
]
4582

4683

4784
rounded : Int -> Float -> String

0 commit comments

Comments
 (0)