Skip to content

Commit 52cad96

Browse files
author
Richard Feldman
committed
Simplify ExplicitColor
1 parent 770bceb commit 52cad96

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

src/Stylesheets.elm

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ whiteSpaceToString =
157157

158158
colorToString : Color -> String
159159
colorToString =
160-
explicitColorToString
160+
(\(ExplicitColor str) -> str)
161161
|> autoToString
162162
|> inheritToString
163163

@@ -168,18 +168,6 @@ textShadowToString =
168168
|> inheritToString
169169

170170

171-
explicitColorToString : ExplicitColor -> String
172-
explicitColorToString value =
173-
case value of
174-
RGB r g b ->
175-
"rgb(" ++ (toString r) ++ ", " ++ (toString g) ++ ", " ++ (toString b) ++ ")"
176-
177-
RGBA r g b a ->
178-
"rgba(" ++ (toString r) ++ ", " ++ (toString g) ++ ", " ++ (toString b) ++ ", " ++ (toString a) ++ ")"
179-
180-
Hex str ->
181-
"#" ++ str
182-
183171
explicitTextShadowToString : ExplicitTextShadow -> String
184172
explicitTextShadowToString value =
185173
case value of
@@ -223,11 +211,7 @@ type ExplicitBoxSizing = ExplicitBoxSizing String
223211
type ExplicitOverflow = ExplicitOverflow String
224212
type ExplicitDisplay = ExplicitDisplay String
225213
type ExplicitWhiteSpace = ExplicitWhiteSpace String
226-
227-
type ExplicitColor
228-
= RGB Float Float Float
229-
| RGBA Float Float Float Float
230-
| Hex String
214+
type ExplicitColor = ExplicitColor String
231215

232216
type ExplicitOutline
233217
= ExplicitOutline Float ExplicitUnits OutlineStyle OpacityStyle
@@ -249,15 +233,20 @@ transparent = OpacityStyle "transparent"
249233

250234
rgb : number -> number -> number -> Color
251235
rgb r g b =
252-
RGB r g b |> NotAuto |> NotInherit
236+
ExplicitColor ("rgb(" ++ (toString r) ++ ", " ++ (toString g) ++ ", " ++ (toString b) ++ ")")
237+
|> NotAuto |> NotInherit
238+
253239

254240
rgba : number -> number -> number -> number -> Color
255241
rgba r g b a =
256-
RGBA r g b a |> NotAuto |> NotInherit
242+
ExplicitColor ("rgba(" ++ (toString r) ++ ", " ++ (toString g) ++ ", " ++ (toString b) ++ ", " ++ (toString a) ++ ")")
243+
|> NotAuto |> NotInherit
244+
257245

258246
hex : String -> Color
259247
hex str =
260-
Hex str |> NotAuto |> NotInherit
248+
ExplicitColor ("#" ++ str)
249+
|> NotAuto |> NotInherit
261250

262251
pct : Units
263252
pct = "%" |> ExplicitUnits |> NotInherit

0 commit comments

Comments
 (0)