Skip to content

Adhoc theme#77

Open
JackHowa wants to merge 6 commits intomainfrom
adhoc-theme
Open

Adhoc theme#77
JackHowa wants to merge 6 commits intomainfrom
adhoc-theme

Conversation

@JackHowa
Copy link
Copy Markdown
Owner

@JackHowa JackHowa commented Dec 16, 2025

Goals

  • Use material design 3 inspiration
  • Have a color picker
  • Works in light and dark mode

Questions

  • Does the color picker really connote that the page is themable?

Todo

  • I don't like the material colors. I want to do something different ... have a couple of ideas
  • Check accessibility of theming and how to change theme
  • Possibly add emoji for the links
  • In light mode, moving the theme picker to the top left of all the way light makes the text unreadable
  • Could also do apple-esque liquid glass but for the office compostable office cups. Red cup would be funny as well
    cups
  • Want to try something themeable as well with plants and the border shape like a leaf for different plants and picking different photos
  • Update the favicon to the background color and foreground. Update to use first and last initial if I want to go for that

In progress

  • My new blooming orange marigold as inspiration. can find other plants around the apartment or in travels if this works. Updated the orange to more closely match this and made it so that this orange is the default
    IMG_8353

Comment thread _includes/styles.css
color-scheme: light dark;
--light-color: #ffcfb8;
--dark-color: #113134;
--md-primary: #ea6a00;
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

material design variables originally set

Comment thread _includes/styles.css
sans-serif;
top: 20px;
right: 20px;
background: var(--md-surface-container-high);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surface container higher so it's more visible https://m3.material.io/blog/tone-based-surface-color-m3

Comment thread index.njk
</main>

<script>
function hexToRgb(hex) {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

picks a hex but needs to convert to rgb in order to do math on it

Comment thread index.njk
const hsl = rgbToHsl(rgb.r, rgb.g, rgb.b);

// Generate tonal palette (MD3 approach)
const lightness = hsl.l;
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread index.njk
outlinedHover: `hsla(${hsl.h}, ${hsl.s}%, ${lightness + 40}%, 0.08)`,
// If primary lightness > 60%, uses dark text (same hue at 20% lightness)
// Otherwise uses white text
onPrimary: primaryL > 60 ? `hsl(${hsl.h}, ${hsl.s}%, 20%)` : '#ffffff'
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensure that color is still visible

Comment thread index.njk
applyTheme(colorPicker.value);

// Re-apply theme when system color scheme changes
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensure that theme is still updated

Comment thread netlify.toml
X-XSS-Protection = "1; mode=block"
X-Content-Type-Options = "nosniff"
Content-Security-Policy = "default-src 'self'; style-src 'unsafe-inline';"
Content-Security-Policy = "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline';"
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow scripts to run inline; may use a different framework so this is easier to do on the page

Comment thread index.njk

function generateColorScheme(baseColor) {
const rgb = hexToRgb(baseColor);
const hsl = rgbToHsl(rgb.r, rgb.g, rgb.b);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably more complicated (but easier if you can include a library), but OKLCH is better for lightness manipulations than HSL: https://evilmartians.com/chronicles/oklch-in-css-why-quit-rgb-hsl

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh this is helpful

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants