Skip to content

Instantly share code, notes, and snippets.

@carlfredrikhero
Last active May 4, 2021 21:36
Show Gist options
  • Save carlfredrikhero/2a90fb5149e76fb8c72d0449941629b4 to your computer and use it in GitHub Desktop.
Save carlfredrikhero/2a90fb5149e76fb8c72d0449941629b4 to your computer and use it in GitHub Desktop.
HSL(A) Type in elm
{-| 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