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

Post: picking colors for the new site #99

Open
gadenbuie opened this issue Jan 19, 2022 · 0 comments
Open

Post: picking colors for the new site #99

gadenbuie opened this issue Jan 19, 2022 · 0 comments

Comments

@gadenbuie
Copy link
Owner

The short answer is that I used a neat tool I discovered at https://accessiblepalette.com. Here are the settings for the colors I used in my theme (the URL lets you bookmark your colors).

I'd recommend starting with one or two colors and add new shades until you have enough colors for what you need. You probably don't need as many colors as I picked. I went a little crazy and created a matching syntax highlighting style, so I needed more than a few colors.

Getting the colors out of the tool is a bit complicated. I ended up writing a little javascript to extract the colors from the page as JSON and then a little R to turn it into the CSS variables in assets/garrick-hex.scss. I should add those scripts (if I find them) to the post.

My biggest recommendation would be to pick one accent color and one text shade color. Use those base colors and their shades and tints (darker and lighter versions) throughout. Maaaaaybe add a second accent color.

In terms of implementation, I highly recommend using CSS variables to store the colors rather than SCSS variables. You can pass the CSS variables to the SCSS variables, so I went all the way and created CSS variables that correspond to the SCSS variables created by the Apero theme.

--slate-00: #0e181e;
--textColorCustom: var(--slate-00);
$textColorCustom: var(--textColorCustom);

This makes it possible to reference var(--slate-00) or var(--textColorCustom) anywhere throughout your site if you want to use those variables later. You can't do that with SCSS variables since they're compiled away and aren't available to your individual pages.

The other thing this makes possible is automatic dark and light mode using CSS variables. I need to look up the link where I learned about this and it's probably not the absolute best approach because there isn't a button on the page to toggle dark light. By using @media (prefers-color-scheme: dark) (MDN) you can override the CSS variables for the theme properties so they change on the fly when the user's operating system (or their settings) declare that they want dark or light mode.

I approached this by creating CSS variables for theme properties that are then used to set the theme's SCSS variables. Note that this literally sets the SCSS variable to the CSS variable, so that later I can change the CSS variable values for dark mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant