-data Color = Rgba Int Int Int Int
- | Hsla Number Number Number Number
- | Other Value
-
-instance isStringColor :: IsString Color where
- fromString = Other <<< fromString
-
-instance valColor :: Val Color where
- value (Rgba r g b 255) = Value <<< fromString $ "rgb(" <> intercalate ", " [show r, show g, show b] <> ")"
- value (Rgba r g b a) = Value <<< fromString $ "rgba(" <> intercalate ", " [show r, show g, show b, show a] <> ")"
- value (Hsla h s l 1.0) = Value <<< fromString $ "hsl(" <> intercalate ", " [show h, show s, show l] <> ")"
- value (Hsla h s l a) = Value <<< fromString $ "hsla(" <> intercalate ", " [show h, show s, show l, show a] <> ")"
- value (Other v) = v
I think there are a few problems with this:
The alpha value in RGBA colors should be a Number and the values should go from 0.0 to 1.0 (instead of 0 to 255).
Saturation and lightness in HSL colors have to be defined as a percentage in CSS, for example: hsl(120, 100%, 50%).
Consequently, RGBA, HSL and HSLA are not working right now (only RGB).
Excerpt from the current
CSS.Color
module:I think there are a few problems with this:
Number
and the values should go from 0.0 to 1.0 (instead of 0 to 255).hsl(120, 100%, 50%)
.Consequently, RGBA, HSL and HSLA are not working right now (only RGB).