Last active
May 4, 2021 21:36
-
-
Save carlfredrikhero/2a90fb5149e76fb8c72d0449941629b4 to your computer and use it in GitHub Desktop.
HSL(A) Type in elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-| The internal type is an opaque type but we expose helper functions for each colors and mapping functions for each value. | |
-} | |
type Hsla | |
= Hsla Hue Saturation Lightness Alpha | |
{-| Each defined color is exposed as another custom type, to enable easy pattern matching. | |
It's useful in configurations for example. | |
-} | |
type Color | |
= White | |
| Base | |
| Dark | |
| Darker | |
| Darkest | |
| Black | |
| Primary | |
| Link | |
| Buy | |
... | |
-- Helper functions for each defined color is exposed. Use them when there is no need to pattern match on the color | |
{-| #009e2f Green | |
-} | |
primary : Hsla | |
primary = | |
Hsla 138 1 0.31 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment