hugo-theme-termlite/assets/css/080_site_header.css
Eryn Wells 8a00cc6de9 Colors: Allow setting the color scheme explicitly
In addition to the color scheme changing based on the system setting, enable
setting the color scheme explicitly by adding a color-scheme="light | dark" attribute
on the <html> element.

Doing this was a bit tricky. I originally implemented the grayscale ramp by
reversing it when prefers-color-scheme: dark. This was convenient, but meant that
setting the color scheme explicitly didn't work.

Along the way I discovered the light-dark() CSS function. Deploy that as the preferred
style if the browser supports it. Otherwise, fall back on the prefers-color-scheme
media queries. This function only works if color-scheme: light dark is set on the
:root element.
2024-07-27 23:01:31 -07:00

79 lines
1.5 KiB
CSS

/*************************
# COMPONENT: SITE HEADER
*************************/
@media (prefers-color-scheme: dark) {
.site-header {
--color-nav-separator: var(--gray6);
}
}
@media (prefers-color-scheme: dark) {
.site-header {
--color-nav-separator: var(--gray4);
}
}
.site-header {
--color-nav-separator: light-dark(var(--gray6), var(--gray4));
font-family: var(--font-family-monospace);
margin-block: var(--space-m) var(--space-xl);
}
.site-header__content {
border-bottom: 2px dashed var(--color-nav-separator);
gap: var(--space-l);
grid-column: main-start / main-end;
padding-bottom: var(--space-xs);
.site-header__title {
color: var(--text-color-primary);
font-size: var(--text-m);
font-weight: normal;
letter-spacing: 0.05em;
a {
color: inherit;
}
a:hover {
text-decoration: none;
}
}
.site-header__nav {
font-size: var(--text-s);
font-weight: normal;
ul {
--spacing: 1ch;
display: flex;
gap: var(--spacing);
list-style: none;
margin: 0;
padding: 0;
li {
margin: 0;
padding: 0;
}
li:not(:first-child)::before {
color: var(--color-nav-separator);
content: ":";
font-weight: bold;
justify-content: center;
margin-inline-end: var(--spacing);
}
}
}
}
@media screen and (max-width: 480px) {
.site-header__content {
grid-column: full-start / full-end;
padding-inline: var(--gutter-width);
}
}