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

Auto color scheme generator #3169

Open
selul opened this issue Oct 25, 2021 · 6 comments
Open

Auto color scheme generator #3169

selul opened this issue Oct 25, 2021 · 6 comments
Labels
small enhancement Small feature or change

Comments

@selul
Copy link
Contributor

selul commented Oct 25, 2021

Description:

This is just for brainstorming right now but I think it's a topic that is worth exploring in order to offer more flexibility for colors with less work for site creators.

The challenge is if we can restrict this to only 4 colors and use HSL manipulation to extend to more of them but using the same baseline colors:
I.e: we would use 4 colors for Primary/Secondary/Accent and Base and each one will have automatically generated 4 shades as light, ultra-light, dark, ultra-dark as well as some transparency variations let's say 20%, 40%, 60%, 80%, and a complementary color. Basically, each one of those Individual colors will generate additionally 9 more color variants but they will be controlled from the same base color.

I.e if I use the color variant of Ultra Light - Primary somewhere and I change the Primary, the Ultra Light will change automatically too.

Let me know your thoughts @Codeinwp/design-team @abaicus

References:


Figma

@selul selul changed the title Auto color scheme generator - Auto color scheme generator Oct 25, 2021
@selul selul added the small enhancement Small feature or change label Oct 25, 2021
@lmisch
Copy link

lmisch commented Nov 16, 2021

+1 :)

@JohnPixle
Copy link

I'd start tackling this one at a later stage, but will just leave the thought here that we can take huge inspiration from the latest version of the Material Design: https://m3.material.io/styles/color/overview and how they have a tone palette for darker and lighter variants.

They seem to work this out is a similar logic as Marius suggests.

@mghenciu
Copy link

TDLR: the focus here was mainly on generating a Color Palette, using 2 different approaches (I attached the files for each example). We can extend this in future with a HUE customisable slider by users.


The idea behind this is to use HSL when generating color paletts, and the generator will act as an extension for the Color System in Neve (maybe TPC in future as a Stylekit Generator). Below a Figma prototype, how this could work in the initial version:

Screen.Recording.2023-01-25.at.11.05.25.mov

Randomly generated colors

Using this approach, the color pallets are generated (almost) randomly, with some adjustment for the range of the values - to make sure a color is always dark or light.
Files: random-HSL-v1.html.zip

Screen.Recording.2023-01-25.at.11.25.55.mov

Accent based color palette

The second example is based on this idea from a Google UI challenge, and what it does is generating 3 palettes (dark, light, dim) where the palette is generated based on the main accent color. Adjusting the HUE of the main color, will also influence the other colors in the palette.
Here's an example (more in Figma), where dark-bg: 1 (or Text Color) | site-bg: 2 | light-bg: 3
image

To test this, use this zip, and inside the dist folder use the template or index files, and press Space in browser to generate palettes.
Files:gui-challengescolor-scheme-starterslider.zip


Going forward

Personally I prefer the second approach, as it's less random.

In terms of integration, we can initially ask users if they think this is useful, and we can add this in the Color System panel (maybe later in the import wizard). It's also possible to add this as a HUE slider for the accent color, meaning that if the user changes the hue in the color picker -> the colors would adjust. But only using HUE and HSL, because otherwise the CSS formulas that create other colors, won't work as expected. Another challenge is the fact that using the whole color picker, it's challenging to generate the palette, in cases where a user chooses a #000000 button.

Contrast Ratio
Another challenge is the Contrast Ratio between the colors and text, especially between the button/primary colors.
One potential solution here (requires some lines of code), is to have function that checks the min 4.5 contrast between primary and #ffffff colors, and if the ratio is not met -> regenerate the primary color.


Let me know your thoughts, when you have some time, no rush at all.
looping in @JohnPixle

@cristian-ungureanu
Copy link
Contributor

cristian-ungureanu commented Oct 6, 2023

Hi there, @mghenciu! Thank you for all your research and for trying to give this Idea a shape.

To be honest, the idea of having this random doesn't sound too good and I would avoid it at all costs. Every user has some branding colors. Suggesting a randomly generated color wouldn't make this feature that useful.

What I would do is after the user selects "generate palette automatically" allow the user to select just the primary color of his site and generate the rest of the colors based on that, something like this: https://vertis.d.pr/v/fpz5V6

The button from your video that regenerates colors can randomly pick not the main colors but the rules that other colors are generated. We will have the base color but the secondary color will be the base color + a random luminosity between a range that we established. And every time you click regenerate, it will be another variation but from the base color.

Here's the code I've used:

:root {
	--primary-h: 100;
	--primary-s: 94%;
	--primary-l: 43%;
	
	--nv-primary-accent: hsl( var(--primary-h), var(--primary-s), var(--primary-l))!important;
	--nv-secondary-accent: hsl( var(--primary-h), var(--primary-s), calc( (var(--primary-l) * 0) + 35% ))!important;
	--nv-site-bg: hsl( var(--primary-h), var(--primary-s), calc( (var(--primary-l) * 0) + 95% ))!important;
	--nv-light-bg: hsl( var(--primary-h), var(--primary-s), calc( (var(--primary-l) * 0) + 50% ))!important;;
	--nv-dark-bg: #14171c;
	--nv-text-color: #393939;
	--nv-text-dark-bg: #ffffff;
	--nv-c-1: #77b978;
	--nv-c-2: #f37262;
}

The challenging part is to actually find a formula for secondary-accent, site-bg, light-bg, dark-bg etc.
I've tried the previous code on some starter sites and they look good. Playing a bit more with those values might produce a nice output.

Let me know your thoughts.

@mghenciu
Copy link

mghenciu commented Oct 6, 2023

Let me know your thoughts.

Yes, you are probably right @cristian-ungureanu .
It's possible that may use-case was coming from a personal need, and that was: easily generate new Color Palettes for our demos.


But in a real case, you are right - probably users have a Brand color already (or at least an idea about it).
Which means that if we add something like this, it should work something like:

  • ask user for a Brand color
  • if he doesn't want/have, we can offer a random color - autogenerated by us
  • the user clicks Generate Palette
  • the magic happens and he has a new color palette derived from his Brand color

maybe also a Regenerate option, which will try to find different palettes using the same brand color.

The Oxygen builder example, this one, Automatic CSS - are using a similar approach, where users have to choose a brand color.

Thank you 🚀

@lmisch
Copy link

lmisch commented Feb 5, 2024

I subscribed to this thread because I had a need to create color palettes for like 6 websites that need to match a corporate branding.
I did it pretty much the way @cristian-ungureanu mentioned here: #3169 (comment)
with some additional magic for shadows and elevations (google material recommendations).

IMHO this would be an awesome feature for users who are not trying to find a good look but need to comply to a branding guide.

On a sidenote and a bit off topic: While trying to set up the palettes I found that, in practice, it is difficult for me to distinguish between usage of primary and secondary color. Often there seems to be something hurtful to the eye when trying to set a secondary color that is for example on the opposite side of the hue wheel.
So in the end I mostly set primary and secondary to the same or similar color.
Hovered links don't use a defined color anyway but reduce the opacity on hover ... which to me is an... interesting approach. Just my 2 cent. Keep up the great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
small enhancement Small feature or change
Projects
None yet
Development

No branches or pull requests

6 participants