Open ianmackenzie opened 4 years ago
I'm a little torn on this! It would be convenient, a lot of the time, but I worry it would be inconvenient some of the time too.
If I wanted to define a custom palette for my application, say, I might do something like this, where I'm defining less-stark blacks and whites.
module Palette exposing (black, white)
import Color exposing (..) -- <- my impulse is to expose everything from Color if I'm defining a color stylesheet type thing for my application
black : Color
black =
fromRGB ( 20, 20, 20 )
white : Color
white =
fromRGB ( 253, 253, 250 )
https://ellie-app.com/7H9BgFzcpLja1
I wouldn't worry about this if I hadn't seen color design recommendations to avoid using pure black and pure white (people seem to think that it can lead to eyestrain?)
Hmm, that is a bit tricky! What about something like Color.pureBlack
and Color.pureWhite
? Still more convenient than calling fromRGB
, but less likely to cause naming collisions, and the name gently reminds the user that perhaps they should consider using something a bit less harsh.
Hmm yeah! That sounds convenient & useful! I wonder if having pureRed, pureGreen, and pureBlue would be handy too? 🤔Or if that would pollute the purpose of the Color namespace too much.
There's also the Color.Transparent module -- should that have pureColors too?
I personally don't see a real need for pureRed
etc., and especially if you're worried about Color
namespace pollution then I would be inclined to leave them out for now. Easy enough to add them in later, harder to go the other way!
For Color.Transparent
, were you thinking of functions like
pureBlack : Opacity -> Color
pureWhite : Opacity -> Color
? I guess that would be useful for consistency...
Yeah, exactly! Although, like you said, it's easier to not add than it is to try to take out. 🤔
I guess I can see something like Color.Transparent.pureWhite (Color.Transparent.customOpacity 0.2)
being useful for stuff like a partially-transparent overlay behind a modal. But I don't have strong thoughts either way.
Would it make sense to add
Color.black
andColor.white
as convenient alternatives toColor.fromRGB ( 0, 0, 0 )
andColor.fromRGB ( 255, 255, 255 )
? I realize that they exist in the X11 palette but it seems a bit awkward to importPalette.X11
and then writeX11.black
/X11.white
. I've run into this a little bit when updating myelm-3d-scene
examples to use theColor
type from this package, and I think it would come up even more often for things like 2D drawings.Happy to make a PR if you'd like!