Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color Palette #116

Closed
ogoffart opened this issue Nov 25, 2020 · 13 comments
Closed

Color Palette #116

ogoffart opened this issue Nov 25, 2020 · 13 comments
Labels
enhancement New feature or request rfc Request for comments: proposals for changes
Milestone

Comments

@ogoffart
Copy link
Member

The idea would be to have a Palette singleton in the style, similar to the StyleMetrics one.

The palette would have property for each interresting color.

Idea for picking the different color roles:

@tronical
Copy link
Member

tronical commented Nov 25, 2020

@ogoffart
Copy link
Member Author

@ogoffart ogoffart added this to Needs triage in Issue priorities via automation Feb 2, 2021
@ogoffart ogoffart moved this from Needs triage to Low priority in Issue priorities Feb 2, 2021
@ogoffart ogoffart added the enhancement New feature or request label Feb 2, 2021
@wigy-opensource-developer

You already have impl InterpolatedPropertyValue for Color for animating colors. If you could expose that as color.mix(another-color, weight) as Sass does, it would even use the same RGB colorspace Sass uses.

With that function in place, you could drastically reduce the number of colors in the Palette and calculate the rest of them, making the theming easier for the end-users.

@tronical
Copy link
Member

I think that's a very good idea. The CSS color-mix() function takes that a step further by adding a color space parameter. API wise that might be even better for future support for different color spaces. What do you think?

@wigy-opensource-developer

Although more color spaces give more flexibility to a designer, personally I would not miss them. If this color.mix function would be shipped earlier, and Sass users do not miss them, I would postpone their introduction.

At the moment the HSL space used for color.brighten and color.darken are not accessible to the .60 language either, nor the red, green, blue and alpha components of the internal representation, so in the far future I would rather have a consistent way of introducing color spaces all around the language (gradients, animations, constructing from color components, extracting color components).

@tronical
Copy link
Member

tronical commented Jun 7, 2022

Coming from #1315 I'm wondering if the palette should perhaps be a model instead of a struct, and the rows are roles.

If the palette was a struct and we'd have a per-widget palette, then that's a substantial amount of bytes spent for each widget when in most cases it would be copied from the global palette.

If the palette were a model, then it would be basically a smart pointer that defaults pointing to the global palette but can be overridden by the user.

@wigy-opensource-developer

Yes! And switching themes (dark mode - light mode - accessible mode) could also be implemented by just replacing the global palette. And as I mentioned, in many color schemes, intermediate tones are used by mixing base colors together.

That could be done either on the palette by defining role colors mixed from base colors, or on the widget itself.

@ogoffart
Copy link
Member Author

ogoffart commented Jun 7, 2022

Having the palette being of type [Color] is not a bad idea, and then we can have constants in some namespace for the indices.

But another possibility would be to just have special compiler support for this. So not every element would have a palette at runtime. in the implementation widget, one would simply do

FooWidget := Rectangle { 
   background: Colors.button-background;  
}

And when using it we can override some of the palette with

FooWidget {
    palette: { button-background: red;    }  // the other color are "inherited"
}

Where palette is a builtin property.

@tronical
Copy link
Member

tronical commented Jun 7, 2022

Ahh, interesting idea - this combines after all. We could use a model in the implementation but hide it behind the syntax you're proposing. Let me see if I understood correctly:

  1. If an element uses Colors.XXX in a binding, then this is translated to resolve to a newly materialised palette property.
  2. The newly materialised palette property is publicly visible
  3. A binding to the palette property with object assignment results in a binding that inherits unset values from the global palette.

@hunger
Copy link
Member

hunger commented Jun 20, 2022

Where is this "button-background" defined? What happens when I mistype that as "butn-background" somewhere? Is that recognized as an error or will that silently add a new color to the palette?

@ogoffart
Copy link
Member Author

It would be defined in the compiler and typo would be detected

@ogoffart ogoffart added the rfc Request for comments: proposals for changes label Nov 29, 2022
@ogoffart ogoffart added this to the 1.0.0 milestone Nov 29, 2022
@ogoffart ogoffart removed this from the 1.0.0 milestone Feb 16, 2023
@ghost
Copy link

ghost commented Apr 14, 2023

Might we get an additional choice as an interim solution? A grey color scheme with high contrast text and widget outlines would be sufficient until custom colors are implemented.

@ogoffart
Copy link
Member Author

MVP merged in #3984

Issue priorities automation moved this from Low priority to Closed Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rfc Request for comments: proposals for changes
Projects
Development

No branches or pull requests

4 participants