Toggle colors and stuff!
Dark theme toggle I started with, and then this other one was useful. I used some of the "safe rules" like desaturated colors instead of pure black/white. I tested having light and dark modes apart from the main palettes but certain ones just worked better either way so I combined light/dark into each. There was just too much contrast with some of them, had a glare. Honestly to be practical there should be 4 at most, but I was aiming for ROYGBIV plus white and black. Note that yellow can be hard to work with, a yellow that isn't fully saturated just looks dingy and dirty.
For the patterns, the squares came from one on here like a decade ago and evolved into that. For the stars I just took this since there's math. And from there also cubes looked good. The main page is based on an example here
I used this thing to mess with the radio buttons, I hope it works right.
I still need a way to get the whole box to be in the header or a sidebar or something.
If you're thinking about this, I'd say look at cleaner ways to do the palette. I ended up duplicating the light and dark default themes which is too annoying to do in a fresh project. In fact, although this seems clever at first, and is useful for two or three items, just look at this crap.
/* start with variables, make light default just because */
:root {
--ink: rgb(20, 20, 20);
--paper: rgb(243, 243, 243);
--bg2: rgb(240, 241, 244);
--bg1: rgb(220, 225, 238);
--border1: rgb(150, 186, 219);
--border2: rgb(0, 192, 0);
/* I added in stuff from another file and didn't notice it was HSL instead of RGB. Oops! */
--banner: hsl(165, 100%, 72%);
--border3: hsl(39, 100%, 70%);
--font-sans: Cantarell, 'Noto Sans', 'Open Sans', sans-serif;
/* I can never settle on a sans font */
--font-serif: 'Source Serif 4', serif;
--font-mono: 'Fira Code', monospace;
--font-script: 'calligraffitiregular', script;
--percent1: 12.5%;
--percent2: 25%;
--size: 32px;
}
@media (prefers-color-scheme: dark) {
:root {
--ink: rgb(245, 244, 244);
--paper: rgb(24, 20, 20);
--bg1: rgb(20, 17, 17);
--bg2: rgb(30, 28, 28);
--border1: rgb(38, 38, 59);
--border2: rgb(74, 139, 74);
--banner: hsl(166, 100%, 6%);
--border3: hsl(39, 74%, 72%);
}
}
:root:has(#light:checked) {
color-scheme: light;
--ink: rgb(20, 20, 20);
--paper: rgb(243, 247, 248);
--bg2: rgb(240, 240, 248);
--bg1: rgb(220, 226, 228);
--border1: rgb(155, 186, 219);
--border2: rgb(0, 192, 0);
--banner: hsl(165, 100%, 72%);
--border3: hsl(39, 100%, 70%);
/* this is just the default light scheme lol */
}
:root:has(#fire:checked) {
color-scheme: light;
--ink: rgb(20, 20, 20);
--paper: rgb(243, 243, 243);
--bg1: rgb(255, 61, 47);
--bg2: rgb(253, 116, 53);
--border1: rgb(241, 173, 44);
--border2: rgb(119, 207, 79);
}
:root:has(#sage:checked) {
color-scheme: light;
--ink: rgb(20, 20, 20);
--paper: rgb(243, 243, 243);
--bg1: rgb(159, 197, 159);
--bg2: rgb(192, 214, 194);
--border1: rgb(191, 233, 182);
--border2: rgb(39, 172, 94);
}
:root:has(#sky:checked) {
color-scheme: light;
--ink: rgb(20, 20, 20);
--paper: rgb(243, 243, 243);
--bg1: rgb(54, 131, 185);
--bg2: rgb(153, 191, 224);
--border1: rgb(108, 190, 253);
--border2: rgb(24, 206, 78);
}
:root:has(#amethyst:checked) {
color-scheme: dark;
--ink: rgb(245, 244, 244);
--paper: rgb(22, 13, 22);
--bg1: rgb(48, 22, 58);
--bg2: rgb(80, 27, 95);
--border1: rgb(120, 37, 156);
--border2: rgb(74, 139, 74);
}
:root:has(#obsidian:checked) {
color-scheme: dark;
--ink: rgb(245, 244, 244);
--paper: rgb(24, 20, 20);
--bg1: rgb(20, 17, 17);
--bg2: rgb(30, 28, 28);
--border1: rgb(38, 38, 59);
--border2: rgb(74, 139, 74);
}
/*
* I thought having about 7 color themes was high, but should be managable, with a simple palette-
* BUT looking at, I didn't factor in things like using color functions like color-mix()
* Perhaps using HSL instead of RGB (there's too many new ones) might be useful.
*/
:root:has(#pa:checked) {
--percent1: 12.5%;
--percent2: 25%;
}
:root:has(#pb:checked) {
--percent1: 6.25%;
--percent2: 12.5%;
}
:root:has(#pc:checked) {
--percent1: 3%;
--percent2: 6.25%;
}
/* Here is where it needs a programmatic solution like JS/TS, not typing all this crap out manually */
:root:has(#size8:checked) {
--size: 8px;
}
:root:has(#size16:checked) {
--size: 16px;
}
:root:has(#size32:checked) {
--size: 32px;
}
:root:has(#size48:checked) {
--size: 48px;
}
:root:has(#size64:checked) {
--size: 64px;
}
:root:has(#size98:checked) {
--size: 98px;
}
/*
* That was absurd! All those lines of code just to iterate over some variables!
* Instead of stealing that code, go find some that's better.
*/
Here's the different patterns.
.checkers {
background-image:
linear-gradient(90deg, var(--bg2) 50%, transparent 50%),
linear-gradient(var(--bg2) 50%, transparent 50%);
background-size: var(--size) var(--size);
}
/*
So yes I liked that one at a certain size and didn't want to fool around with adding the size controls,
even if all I had to do is copypaste.
But now I worry about being inconsistent with design.
*/
.checkersmall {
background-image:
linear-gradient(90deg, var(--bg2) 50%, transparent 50%),
linear-gradient(var(--bg2) 50%, transparent 50%);
background-size: 8px 8px;
}
.kaleido {
background-image:
repeating-conic-gradient(var(--bg1) 0 var(--percent1), var(--bg2) 0 var(--percent2));
background-size: var(--size) var(--size);
}
/* The others I made playing around with tutorials but this one I yanked from css-pattern.com to edit */
.stars {
--d: calc(var(--size)/10); /* control the gap between stars */
--_g: var(--bg2) 36deg, #0000 0;
background:
conic-gradient(from 162deg at calc(var(--size) * .5) calc(var(--size) * .68), var(--_g)),
conic-gradient(from 18deg at calc(var(--size) * .19) calc(var(--size) * .59), var(--_g)),
conic-gradient(from 306deg at calc(var(--size) * .81) calc(var(--size) * .59), var(--_g)),
var(--bg1);
background-position: 0 calc(var(--size) * 0.35);
background-size: calc(var(--size) + var(--d)) calc(var(--size) + var(--d));
}
/* I finally used my art brain and noticed the light theme doesn't match the lighting direction of the rest. */
.cubes {
background:
repeating-conic-gradient(from 30deg,#0000 0 120deg,var(--bg2) 0 50%) calc(var(--size)/2) calc(var(--size)*tan(30deg)/2),
repeating-conic-gradient(from 30deg,var(--bg1) 0 60deg,var(--border1) 0 120deg,var(--bg2) 0 50%);
background-size: var(--size) calc(var(--size)*tan(30deg));
}