Header Announcement
A site header with a strip of news on top: messages roll and pause on hover or focus; the cross folds the strip, the header slides up without a jump, and it stays closed. Below 900 px, a shutter menu.
View codeA site header with a logo, links and one button: a line glides under the links, front edge first, and returns under the current page; below 900 px the links become a shutter menu.
With your AI
Say it to your AI. It gets the exact code below, not its best guess, and knows where it goes.
Add the Kodza Header Classic to my page.
claude mcp add -t http kodza https://kodza.dev/api/mcp
<header class="kodza-header-classic">
<div class="kodza-header-classic__row">
<a class="kodza-header-classic__logo" href="#" aria-label="Pier, home"><svg viewBox="0 0 24 22" width="22" height="20" aria-hidden="true"><path d="M1 6h22v3.5H1z"/><path d="M3.5 11.5h3V21h-3zM10.5 11.5h3V21h-3zM17.5 11.5h3V21h-3z"/></svg><span>pier</span></a>
<nav class="kodza-header-classic__menu" aria-label="Main">
<ul class="kodza-header-classic__links">
<li><a class="kodza-header-classic__link" href="#" aria-current="page">Work</a></li>
<li><a class="kodza-header-classic__link" href="#">Services</a></li>
<li><a class="kodza-header-classic__link" href="#">Studio</a></li>
<li><a class="kodza-header-classic__link" href="#">Journal</a></li>
<li><a class="kodza-header-classic__link" href="#">Contact</a></li>
</ul>
<span class="kodza-header-classic__line" aria-hidden="true"></span>
</nav>
<div class="kodza-header-classic__end">
<a class="kodza-header-classic__cta" href="#">Start a project</a>
<button class="kodza-header-classic__toggle" type="button" aria-expanded="false"><span class="kodza-header-classic__lines" aria-hidden="true"></span><span class="kodza-header-classic__label"><span class="kodza-header-classic__say">Menu</span><span class="kodza-header-classic__say" aria-hidden="true">Close</span></span></button>
<div class="kodza-header-classic__panel" popover aria-label="Menu">
<nav class="kodza-header-classic__list" aria-label="Main"></nav>
<div class="kodza-header-classic__info">
<p class="kodza-header-classic__more"><a class="kodza-header-classic__action" href="#">Start a project</a></p>
<p class="kodza-header-classic__socials"><a href="#">GitHub</a><a href="#">X</a><a href="#">RSS</a></p>
</div>
</div>
</div>
</div>
</header>
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Header Classic
The header you paste everywhere: logo on the left, links in the middle, a pill on the right.
One line glides under the links, its front edge first and the back one catching up, and goes
back to the page you are on when the pointer leaves. Below 900 px the links give way to a Menu
button and a shutter that comes down under the header, written from the same links.
Everything is tuned with the --kz-header-classic-* variables (--kz-header-classic-menu-* for
the shutter). */
.kodza-header-classic {
--kz-header-classic-bg: transparent;
--kz-header-classic-fg: #0a0a0a;
--kz-header-classic-muted: rgba(10, 10, 10, 0.62);
--kz-header-classic-soft: rgba(10, 10, 10, 0.06); /* the Menu button */
--kz-header-classic-ink: #0a0a0a; /* the call to action */
--kz-header-classic-on-ink: #ffffff;
--kz-header-classic-height: 72px;
--kz-header-classic-width: 1200px; /* the row, centred */
--kz-header-classic-pad: 24px;
--kz-header-classic-duration: 0.42s; /* the line gliding */
--kz-header-classic-lag: 0.08s; /* how long its back edge waits */
--kz-header-classic-ease: cubic-bezier(0.22, 1, 0.36, 1);
--kz-header-classic-menu-bg: #0a0a0a; /* the shutter, below 900 px */
--kz-header-classic-menu-fg: #f2f2f0;
--kz-header-classic-menu-muted: rgba(242, 242, 240, 0.62);
--kz-header-classic-menu-line: rgba(242, 242, 240, 0.16);
--kz-header-classic-menu-top: auto; /* where the shutter starts; auto = the bottom of the header */
--kz-header-classic-menu-side: 24px;
--kz-header-classic-menu-size: clamp(34px, min(10cqw, calc((100cqh - 240px) / 6)), 96px);
--kz-header-classic-menu-duration: 0.8s;
--kz-header-classic-menu-ease: cubic-bezier(0.76, 0, 0.24, 1);
position: relative;
z-index: 60;
display: block;
box-sizing: border-box;
width: 100%;
margin: 0;
padding: 0;
background: var(--kz-header-classic-bg);
color: var(--kz-header-classic-fg);
font-size: 15px;
line-height: 1.4;
text-align: left;
container-type: inline-size;
}
/* Three columns, the middle one as wide as the links: they sit in the true centre, whatever the
width of the logo and of the button */
.kodza-header-classic__row {
display: grid;
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
align-items: center;
gap: 16px;
box-sizing: border-box;
max-width: var(--kz-header-classic-width);
height: var(--kz-header-classic-height);
margin: 0 auto;
padding: 0 var(--kz-header-classic-pad);
}
.kodza-header-classic__logo {
display: inline-flex;
align-items: center;
justify-self: start;
gap: 8px;
height: 40px;
margin: 0;
border-radius: 6px;
color: inherit;
font-size: 18px;
font-weight: 600;
line-height: 1;
letter-spacing: -0.04em;
text-decoration: none;
}
.kodza-header-classic__logo svg {
display: block;
flex: none;
fill: currentColor;
}
.kodza-header-classic__menu {
position: relative;
display: block;
margin: 0;
padding: 0;
}
.kodza-header-classic__links {
display: flex;
align-items: center;
gap: 2px;
margin: 0;
padding: 0;
list-style: none;
}
.kodza-header-classic__links > li {
display: block;
margin: 0;
padding: 0;
list-style: none;
}
.kodza-header-classic__link {
display: inline-flex;
align-items: center;
box-sizing: border-box;
height: 40px;
margin: 0;
padding: 0 14px;
border-radius: 8px;
color: var(--kz-header-classic-muted);
font-size: 15px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.01em;
text-decoration: none;
white-space: nowrap;
transition: color 0.2s;
}
.kodza-header-classic__link:hover,
.kodza-header-classic__link:focus-visible,
.kodza-header-classic__link[aria-current="page"] {
color: var(--kz-header-classic-fg);
}
.kodza-header-classic__link:focus-visible,
.kodza-header-classic__logo:focus-visible {
outline: 2px solid var(--kz-header-classic-fg);
outline-offset: 2px;
}
/* The one line under the links. The script sets its two ends; each end has its own transition,
so the end in front leaves first and the other catches up */
/* The line spans the nav; each edge is its own clip, so the back one can wait for the front.
The script writes where the edges go */
.kodza-header-classic__line {
position: absolute;
bottom: 8px;
left: 0;
right: 0;
height: 1.5px;
clip-path: inset(0 0 0 var(--kz-header-classic-line-left, 0px));
pointer-events: none;
}
.kodza-header-classic__line::after {
content: "";
position: absolute;
inset: 0;
border-radius: 1px;
background: var(--kz-header-classic-fg);
clip-path: inset(0 var(--kz-header-classic-line-right, 100%) 0 0);
}
.kodza-header-classic.is-ready .kodza-header-classic__line,
.kodza-header-classic.is-ready .kodza-header-classic__line::after {
transition: clip-path var(--kz-header-classic-duration) var(--kz-header-classic-ease);
}
.kodza-header-classic.is-ready .kodza-header-classic__line.is-rightward,
.kodza-header-classic.is-ready .kodza-header-classic__line.is-leftward::after {
transition-delay: var(--kz-header-classic-lag);
}
.kodza-header-classic.is-ready .kodza-header-classic__line.is-instant,
.kodza-header-classic.is-ready .kodza-header-classic__line.is-instant::after {
transition: none;
}
.kodza-header-classic__end {
display: flex;
grid-column: 3;
align-items: center;
justify-self: end;
gap: 8px;
margin: 0;
}
.kodza-header-classic__cta {
display: inline-flex;
align-items: center;
box-sizing: border-box;
height: 40px;
margin: 0;
padding: 0 18px;
border-radius: 999px;
background: var(--kz-header-classic-ink);
color: var(--kz-header-classic-on-ink);
font-size: 15px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.01em;
text-decoration: none;
white-space: nowrap;
transition: background-color 0.2s;
}
@media (hover: hover) {
.kodza-header-classic__cta:hover {
background: color-mix(in srgb, var(--kz-header-classic-ink) 84%, transparent);
}
}
.kodza-header-classic__cta:focus-visible {
outline: 2px solid var(--kz-header-classic-ink);
outline-offset: 3px;
}
/* The Menu button: two lines meet, then cross; the label rolls without changing the width */
.kodza-header-classic__toggle {
display: inline-flex;
align-items: center;
gap: 10px;
box-sizing: border-box;
height: 40px;
margin: 0;
padding: 0 18px 0 16px;
border: 0;
border-radius: 999px;
background: var(--kz-header-classic-soft);
color: var(--kz-header-classic-fg);
font: inherit;
font-size: 15px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.01em;
white-space: nowrap;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.kodza-header-classic__toggle:focus-visible {
outline: 2px solid var(--kz-header-classic-fg);
outline-offset: 3px;
}
.kodza-header-classic__lines {
position: relative;
flex: none;
width: 14px;
height: 8px;
}
.kodza-header-classic__lines::before,
.kodza-header-classic__lines::after {
content: "";
position: absolute;
left: 0;
width: 100%;
height: 1.5px;
border-radius: 1px;
background: currentColor;
/* On its own layer: drawn the same way at rest and while turning, so no snap at the end */
will-change: transform;
/* Closing: they uncross first, then part */
transition:
rotate 0.22s cubic-bezier(0.65, 0, 0.35, 1),
translate 0.22s cubic-bezier(0.65, 0, 0.35, 1) 0.18s,
clip-path 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.kodza-header-classic__lines::before {
top: 0;
}
.kodza-header-classic__lines::after {
top: 6px; /* whole pixels: both lines sit on the pixel grid the same way */
}
/* Whole at rest, as an inset: the pointer slides it to a shorter one (from none it would jump) */
.kodza-header-classic__lines::after {
clip-path: inset(0 0 0 0);
}
.kodza-header-classic__toggle:hover .kodza-header-classic__lines::after {
clip-path: inset(0 45% 0 0);
}
.kodza-header-classic__toggle[aria-expanded="true"] .kodza-header-classic__lines::before,
.kodza-header-classic__toggle[aria-expanded="true"] .kodza-header-classic__lines::after {
clip-path: inset(0 0 0 0);
transition:
translate 0.2s cubic-bezier(0.65, 0, 0.35, 1),
rotate 0.3s cubic-bezier(0.22, 1, 0.36, 1) 0.17s,
clip-path 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.kodza-header-classic__toggle[aria-expanded="true"] .kodza-header-classic__lines::before {
translate: 0 3px;
rotate: 45deg;
}
.kodza-header-classic__toggle[aria-expanded="true"] .kodza-header-classic__lines::after {
translate: 0 -3px;
rotate: -45deg;
}
.kodza-header-classic__label {
display: grid;
margin: -3px 0;
padding: 3px 0;
overflow: hidden;
}
/* The script rolls the words both ways: the old one goes up, the new one comes up from below */
.kodza-header-classic__say {
grid-area: 1 / 1;
}
.kodza-header-classic__say + .kodza-header-classic__say {
translate: 0 115%;
}
.kodza-header-classic__toggle[aria-expanded="true"] .kodza-header-classic__say {
translate: 0 -115%;
}
.kodza-header-classic__toggle[aria-expanded="true"] .kodza-header-classic__say + .kodza-header-classic__say {
translate: 0 0;
}
/* The shutter: from the bottom of the header to the bottom of the screen, rolled up until it
opens. A native popover, so Escape, a click outside and the focus going back to Menu are the
browser's own */
.kodza-header-classic__panel {
position: fixed;
inset: var(--kz-header-classic-from, 0px) 0 0 0;
box-sizing: border-box;
width: 100%;
height: auto;
max-width: none;
max-height: none;
margin: 0;
padding: 0 var(--kz-header-classic-menu-side);
border: 0;
overflow: hidden auto;
overscroll-behavior: contain;
background: var(--kz-header-classic-menu-bg);
color: var(--kz-header-classic-menu-fg);
font: inherit;
font-size: 15px;
line-height: 1.4;
text-align: left;
container-type: size;
z-index: 99990;
/* Here and not on the open state: the panel keeps its rows while it rolls back up */
grid-template-rows: 1fr auto;
-webkit-font-smoothing: antialiased;
clip-path: inset(0 0 100% 0);
/* Closing: quicker than it came down */
transition:
clip-path calc(var(--kz-header-classic-menu-duration) * 0.7) var(--kz-header-classic-menu-ease),
display calc(var(--kz-header-classic-menu-duration) * 0.7) allow-discrete,
overlay calc(var(--kz-header-classic-menu-duration) * 0.7) allow-discrete;
}
.kodza-header-classic__panel:popover-open {
display: grid;
clip-path: inset(0 0 0 0);
transition:
clip-path var(--kz-header-classic-menu-duration) var(--kz-header-classic-menu-ease),
display var(--kz-header-classic-menu-duration) allow-discrete,
overlay var(--kz-header-classic-menu-duration) allow-discrete;
}
@starting-style {
.kodza-header-classic__panel:popover-open {
clip-path: inset(0 0 100% 0);
}
}
.kodza-header-classic__list {
align-self: center;
display: grid;
margin: 0;
padding: 28px 0;
}
/* Each row: its hairline draws in, then the word rises from its mask */
.kodza-header-classic__item {
position: relative;
display: grid;
grid-template-columns: clamp(44px, 9cqw, 132px) minmax(0, 1fr);
align-items: start;
margin: 0;
padding: 14px 0 10px;
color: inherit;
text-decoration: none;
outline: none;
}
.kodza-header-classic__item::before {
content: "";
position: absolute;
inset: 0 0 auto;
height: 1px;
background: var(--kz-header-classic-menu-line);
scale: 0 1;
transform-origin: left center;
transition: scale 0.3s cubic-bezier(0.65, 0, 0.35, 1);
}
.kodza-header-classic__index {
display: flex;
align-items: center;
gap: 8px;
padding-top: 0.4em;
font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
font-size: 12px;
line-height: 1.4;
color: var(--kz-header-classic-menu-muted);
opacity: 0;
transition: opacity 0.2s, color 0.25s;
}
/* The page you are on: its number lights up, with a dot */
.kodza-header-classic__item[aria-current="page"] .kodza-header-classic__index {
color: var(--kz-header-classic-menu-fg);
}
.kodza-header-classic__item[aria-current="page"] .kodza-header-classic__index::after {
content: "";
flex: none;
width: 5px;
height: 5px;
border-radius: 50%;
background: currentColor;
}
/* The mask has the size of its word, so its room for descenders (g, j, p, q, y) and its step
aside are measured on the word */
.kodza-header-classic__mask {
display: block;
margin: -0.06em 0 -0.24em;
padding: 0.06em 0 0.24em;
overflow: hidden;
font-size: var(--kz-header-classic-menu-size);
transition: translate 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.kodza-header-classic__word {
display: block;
font-size: var(--kz-header-classic-menu-size);
font-weight: 500;
line-height: 0.95;
letter-spacing: -0.045em;
translate: 0 135%;
/* Closing: the words drop back into their masks while the shutter rolls up */
transition: translate 0.32s cubic-bezier(0.65, 0, 0.35, 1);
}
.kodza-header-classic__info {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 12px 24px;
padding: 16px 0 22px;
border-top: 1px solid var(--kz-header-classic-menu-line);
opacity: 0;
translate: 0 8px;
transition: opacity 0.2s, translate 0.3s cubic-bezier(0.65, 0, 0.35, 1);
}
.kodza-header-classic__info p {
margin: 0;
}
.kodza-header-classic__action {
display: inline-flex;
align-items: center;
box-sizing: border-box;
height: 40px;
padding: 0 18px;
border-radius: 999px;
background: var(--kz-header-classic-menu-fg);
color: var(--kz-header-classic-menu-bg);
font-size: 15px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.01em;
text-decoration: none;
white-space: nowrap;
}
.kodza-header-classic__action:focus-visible {
outline: 2px solid var(--kz-header-classic-menu-fg);
outline-offset: 3px;
}
.kodza-header-classic__socials {
display: flex;
gap: 20px;
font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
font-size: 12px;
line-height: 1.4;
color: var(--kz-header-classic-menu-muted);
}
.kodza-header-classic__socials a {
color: inherit;
text-decoration: none;
transition: color 0.2s;
}
/* Open: each part starts when the edge reaches it (the script sets --kz-header-classic-delay) */
.kodza-header-classic__panel.is-open .kodza-header-classic__item::before {
scale: 1 1;
transition: scale 0.9s cubic-bezier(0.22, 1, 0.36, 1) var(--kz-header-classic-delay, 0s);
}
.kodza-header-classic__panel.is-open .kodza-header-classic__index {
opacity: 1;
transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--kz-header-classic-delay, 0s) + 0.12s), color 0.25s;
}
.kodza-header-classic__panel.is-open .kodza-header-classic__word {
translate: 0 0;
transition: translate 0.75s cubic-bezier(0.22, 1, 0.36, 1) var(--kz-header-classic-delay, 0s);
}
.kodza-header-classic__panel.is-open .kodza-header-classic__info {
opacity: 1;
translate: 0 0;
transition:
opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1) var(--kz-header-classic-delay, 0s),
translate 0.7s cubic-bezier(0.22, 1, 0.36, 1) var(--kz-header-classic-delay, 0s);
}
/* Pointed at: the word steps aside and its number lights up */
.kodza-header-classic__item:hover .kodza-header-classic__mask,
.kodza-header-classic__item:focus-visible .kodza-header-classic__mask {
translate: 0.14em 0;
}
.kodza-header-classic__item:hover .kodza-header-classic__index,
.kodza-header-classic__item:focus-visible .kodza-header-classic__index,
.kodza-header-classic__socials a:hover {
color: var(--kz-header-classic-menu-fg);
}
.kodza-header-classic__item:focus-visible .kodza-header-classic__word {
text-decoration: underline;
text-decoration-thickness: 2px;
text-underline-offset: 0.12em;
}
.kodza-header-classic__socials a:focus-visible {
outline: 2px solid var(--kz-header-classic-menu-fg);
outline-offset: 4px;
}
/* Below 900 px the links give way to the Menu button; below 520 px only Menu stays */
@container (max-width: 899px) {
.kodza-header-classic__menu {
display: none;
}
}
@container (min-width: 900px) {
.kodza-header-classic__toggle {
display: none;
}
}
@container (max-width: 519px) {
.kodza-header-classic__row {
padding: 0 16px;
}
.kodza-header-classic__cta {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-header-classic.is-ready .kodza-header-classic__line,
.kodza-header-classic.is-ready .kodza-header-classic__line::after,
.kodza-header-classic__panel,
.kodza-header-classic__panel *,
.kodza-header-classic__panel *::before,
.kodza-header-classic__toggle *,
.kodza-header-classic__toggle *::before,
.kodza-header-classic__toggle *::after {
transition-duration: 0.01ms !important;
transition-delay: 0s !important;
}
}
/* kodza-guard 1767508bac35 — generated by Kodza, do not edit.
Theme guard: keeps a site's own CSS (WordPress themes, Bootstrap, CSS resets…) off this
component. :not(#_) is always true and weighs as much as an id, so these lines win over
theme rules made of classes and tags. Customise the component through its --kz-* variables. */
/* What the browser gives, where the component sets it only in some states: at the lowest weight, so its own rules below put it back */
:where(.kodza-header-classic__logo):not(#_),
:where(.kodza-header-classic__link):not(#_),
:where(.kodza-header-classic__cta):not(#_),
:where(.kodza-header-classic__toggle):not(#_),
:where(.kodza-header-classic__socials a:where(:not([class*="kodza-"]))):not(#_) {
outline: revert;
outline-offset: revert;
}
:where(.kodza-header-classic__list):not(#_),
:where(.kodza-header-classic__item):not(#_),
:where(.kodza-header-classic__more):not(#_),
:where(.kodza-header-classic__socials):not(#_) {
transition-duration: revert;
transition-delay: revert;
}
:where(.kodza-header-classic__action):not(#_) {
outline: revert;
outline-offset: revert;
transition-duration: revert;
transition-delay: revert;
}
/* What the browser gives, on everything the component leaves to it */
.kodza-header-classic:not(#_) {
border: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
transition: revert;
list-style: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-height: revert;
font-family: revert;
font-weight: revert;
font-style: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-header-classic__logo:not(#_) {
border: revert;
padding: revert;
transition: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-family: revert;
font-style: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-header-classic__menu:not(#_) {
border: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
transition: revert;
list-style: revert;
box-sizing: revert;
float: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-header-classic__links:not(#_),
.kodza-header-classic__links li:where(:not([class*="kodza-"]):not(.kodza-header-classic__links [class*="kodza-"] *)):not(#_) {
border: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
transition: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-header-classic__link:not(#_) {
border: revert;
list-style: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-family: revert;
font-style: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-header-classic__line:not(#_),
.kodza-header-classic__end:not(#_),
.kodza-header-classic__lines:not(#_),
.kodza-header-classic__label:not(#_),
.kodza-header-classic__say:not(#_),
.kodza-header-classic__index:not(#_),
.kodza-header-classic__mask:not(#_),
.kodza-header-classic__word:not(#_),
.kodza-header-classic__info:not(#_),
.kodza-header-classic__logo span:where(:not([class*="kodza-"])):not(#_) {
box-sizing: revert;
}
.kodza-header-classic__cta:not(#_) {
border: revert;
list-style: revert;
float: revert;
position: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-family: revert;
font-style: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-header-classic__toggle:not(#_) {
text-decoration: revert;
transition: revert;
list-style: revert;
float: revert;
position: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-height: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
min-height: revert;
}
.kodza-header-classic__list:not(#_) {
border: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
}
.kodza-header-classic__item:not(#_) {
border: revert;
border-radius: revert;
list-style: revert;
box-sizing: revert;
float: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
}
.kodza-header-classic__more:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
}
.kodza-header-classic__action:not(#_) {
border: revert;
margin: revert;
list-style: revert;
float: revert;
position: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-family: revert;
font-style: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
}
.kodza-header-classic__socials:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-weight: revert;
font-style: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
}
.kodza-header-classic__logo svg:where(:not([class*="kodza-"])):not(#_) {
border: revert;
margin: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
transition: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-header-classic__socials a:where(:not([class*="kodza-"])):not(#_) {
border: revert;
margin: revert;
padding: revert;
border-radius: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-header-classic__more:not(#_):where(:not([hidden])),
.kodza-header-classic__socials a:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])) {
display: revert;
}
.kodza-header-classic__more:not(#_):where([hidden]),
.kodza-header-classic__socials a:where(:not([class*="kodza-"])):not(#_):where([hidden]) {
display: none;
}
.kodza-header-classic__line:not(#_)::after,
.kodza-header-classic__lines:not(#_)::before,
.kodza-header-classic__lines:not(#_)::after,
.kodza-header-classic__item:not(#_)::before,
.kodza-header-classic__index:not(#_)::after {
box-sizing: revert;
}
/* The component's own rules, one step stronger: real buttons and fields, what it sets on tags themes style (links, lists, headings, images…), and the root width (a theme may narrow it, never widen it) */
.kodza-header-classic:not(#_) {
position: relative;
display: block;
box-sizing: border-box;
padding: 0;
background: var(--kz-header-classic-bg);
color: var(--kz-header-classic-fg);
font-size: 15px;
line-height: 1.4;
text-align: left;
}
.kodza-header-classic__logo:not(#_) {
display: inline-flex;
margin: 0;
border-radius: 6px;
color: inherit;
font-size: 18px;
font-weight: 600;
line-height: 1;
letter-spacing: -0.04em;
text-decoration: none;
}
.kodza-header-classic__logo svg:not(#_) {
display: block;
}
.kodza-header-classic__menu:not(#_) {
position: relative;
display: block;
margin: 0;
padding: 0;
}
.kodza-header-classic__links:not(#_) {
display: flex;
margin: 0;
padding: 0;
list-style: none;
}
.kodza-header-classic__links > li:not(#_) {
display: block;
margin: 0;
padding: 0;
list-style: none;
}
.kodza-header-classic__link:not(#_) {
display: inline-flex;
box-sizing: border-box;
margin: 0;
padding: 0 14px;
border-radius: 8px;
color: var(--kz-header-classic-muted);
font-size: 15px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.01em;
text-decoration: none;
transition: color 0.2s;
}
.kodza-header-classic__link:hover:not(#_),
.kodza-header-classic__link:focus-visible:not(#_),
.kodza-header-classic__link[aria-current="page"]:not(#_) {
color: var(--kz-header-classic-fg);
}
.kodza-header-classic__link:focus-visible:not(#_),
.kodza-header-classic__logo:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-classic-fg);
outline-offset: 2px;
}
.kodza-header-classic__cta:not(#_) {
display: inline-flex;
box-sizing: border-box;
margin: 0;
padding: 0 18px;
border-radius: 999px;
background: var(--kz-header-classic-ink);
color: var(--kz-header-classic-on-ink);
font-size: 15px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.01em;
text-decoration: none;
transition: background-color 0.2s;
}
@media (hover: hover) {
.kodza-header-classic__cta:hover:not(#_) {
background: color-mix(in srgb, var(--kz-header-classic-ink) 84%, transparent);
}
}
.kodza-header-classic__cta:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-classic-ink);
outline-offset: 3px;
}
.kodza-header-classic__toggle:not(#_) {
display: inline-flex;
align-items: center;
gap: 10px;
box-sizing: border-box;
height: 40px;
margin: 0;
padding: 0 18px 0 16px;
border: 0;
border-radius: 999px;
background: var(--kz-header-classic-soft);
color: var(--kz-header-classic-fg);
font: inherit;
font-size: 15px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.01em;
white-space: nowrap;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.kodza-header-classic__toggle:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-classic-fg);
outline-offset: 3px;
}
.kodza-header-classic__list:not(#_) {
display: grid;
margin: 0;
padding: 28px 0;
}
.kodza-header-classic__item:not(#_) {
position: relative;
display: grid;
margin: 0;
padding: 14px 0 10px;
color: inherit;
text-decoration: none;
outline: none;
}
.kodza-header-classic__info p:not(#_) {
margin: 0;
}
.kodza-header-classic__action:not(#_) {
display: inline-flex;
box-sizing: border-box;
padding: 0 18px;
border-radius: 999px;
background: var(--kz-header-classic-menu-fg);
color: var(--kz-header-classic-menu-bg);
font-size: 15px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.01em;
text-decoration: none;
}
.kodza-header-classic__action:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-classic-menu-fg);
outline-offset: 3px;
}
.kodza-header-classic__socials:not(#_) {
display: flex;
font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
font-size: 12px;
line-height: 1.4;
color: var(--kz-header-classic-menu-muted);
}
.kodza-header-classic__socials a:not(#_) {
color: inherit;
text-decoration: none;
transition: color 0.2s;
}
.kodza-header-classic__socials a:hover:not(#_) {
color: var(--kz-header-classic-menu-fg);
}
.kodza-header-classic__socials a:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-classic-menu-fg);
outline-offset: 4px;
}
@container (max-width: 899px) {
.kodza-header-classic__menu:not(#_) {
display: none;
}
}
@container (min-width: 900px) {
.kodza-header-classic__toggle:not(#_) {
display: none;
}
}
@container (max-width: 519px) {
.kodza-header-classic__cta:not(#_) {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-header-classic__panel *:where(nav, a, p):not(#_) {
transition-duration: 0.01ms !important;
transition-delay: 0s !important;
}
}
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Kodza — Header Classic
// One line under the links: it glides to the link you point at, its front edge first and the
// back one catching up, and goes back under the page you are on (aria-current="page") when the
// pointer leaves. Below 900 px the links give way to a Menu button: the shutter (a native
// popover) comes down under the header, written by the script from the same links, so a menu
// changed in the CMS changes both.
(() => {
const SELECTOR = '.kodza-header-classic';
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const c = (name) => `.kodza-header-classic__${name}`;
// When (0 to 1 of the duration) a cubic-bezier curve gets to the progress p
const timeAt = ([x1, y1, x2, y2], p) => {
const at = (a, b, s) => 3 * a * s * (1 - s) ** 2 + 3 * b * s * s * (1 - s) + s ** 3;
let lo = 0;
let hi = 1;
for (let i = 0; i < 24; i++) {
const mid = (lo + hi) / 2;
if (at(y1, y2, mid) < p) lo = mid;
else hi = mid;
}
return at(x1, x2, (lo + hi) / 2);
};
// A wheel or a swipe only scrolls what can scroll in the panel, under the pointer
const scrollsInside = (panel, target, x, y, dy) => {
for (let el = target; el instanceof Element && panel.contains(el); el = el.parentElement) {
const box = el.getBoundingClientRect();
if (x < box.left || x > box.right || y < box.top || y > box.bottom) continue;
if (!/(auto|scroll)/.test(getComputedStyle(el).overflowY) || el.scrollHeight <= el.clientHeight + 1) continue;
if (dy > 0 ? el.scrollTop + el.clientHeight < el.scrollHeight - 1 : el.scrollTop > 0) return true;
}
return false;
};
// One instance, with its own state: two copies on a page never interfere. Everything it
// starts is tied to `signal`, so kodza:destroy stops it all.
function mount(root, signal) {
const nav = root.querySelector(c('menu'));
const line = root.querySelector(c('line'));
const links = [...root.querySelectorAll(c('link'))];
// ---------- The line ----------
let at = null; // the link the line is under
let over = null; // the link under the pointer or the focus
const current = () => links.find((link) => link.getAttribute('aria-current') === 'page') || null;
// A link's word in the nav's own pixels: a parent scaled by transform does not shift it
const span = (link) => {
const n = nav.getBoundingClientRect();
const scale = n.width / nav.offsetWidth || 1;
const b = link.getBoundingClientRect();
const pad = parseFloat(getComputedStyle(link).paddingLeft) || 0;
return { left: (b.left - n.left) / scale + pad, right: (n.right - b.right) / scale + pad };
};
const set = ({ left, right }) => {
line.style.setProperty('--kz-header-classic-line-left', `${left}px`);
line.style.setProperty('--kz-header-classic-line-right', `${right}px`);
};
// A line with no length, in the middle of a link's word
const dot = (link) => {
const s = span(link);
const mid = (s.left + nav.offsetWidth - s.right) / 2;
return { left: mid, right: nav.offsetWidth - mid };
};
const instantly = (fn) => {
line.classList.add('is-instant');
fn();
getComputedStyle(line, '::after').clipPath; // both edges settle before the transitions come back
void line.offsetWidth;
line.classList.remove('is-instant');
};
const go = (link, instant) => {
if (!line || !nav.offsetWidth) return; // the links are hidden below 900 px
if (instant) {
instantly(() => set(link ? span(link) : { left: 0, right: nav.offsetWidth }));
} else if (link && !at) {
// From nowhere: it grows out of the middle of the word
line.classList.remove('is-rightward', 'is-leftward');
instantly(() => set(dot(link)));
set(span(link));
} else if (link) {
// From a link to the next: the edge in front leaves first
if (link !== at) {
const rightward = links.indexOf(link) > links.indexOf(at);
line.classList.toggle('is-rightward', rightward);
line.classList.toggle('is-leftward', !rightward);
}
set(span(link));
} else if (at) {
// Back to nowhere: it shrinks into the middle of the last word
line.classList.remove('is-rightward', 'is-leftward');
set(dot(at));
}
at = link;
};
if (nav && line) {
nav.addEventListener('pointerover', (event) => {
const link = event.target.closest?.(c('link'));
if (!link || link === over) return;
over = link;
go(link);
}, { signal });
nav.addEventListener('pointerleave', () => {
over = null;
go(current());
}, { signal });
nav.addEventListener('focusin', (event) => {
const link = event.target.closest?.(c('link'));
if (!link) return;
over = link;
go(link);
}, { signal });
nav.addEventListener('focusout', (event) => {
if (nav.contains(event.relatedTarget)) return;
over = null;
go(current());
}, { signal });
// The links change size (fonts, the window, the 900 px step): the line follows at once
const fit = () => {
at = over || current();
go(at, true);
};
const watch = new ResizeObserver(fit);
watch.observe(nav);
signal.addEventListener('abort', () => watch.disconnect());
document.fonts?.ready.then(() => !signal.aborted && fit());
fit();
}
// ---------- The shutter, below 900 px ----------
const toggle = root.querySelector(c('toggle'));
const panel = root.querySelector(c('panel'));
const list = root.querySelector(c('list'));
if (!toggle || !panel || !list || !('popover' in panel)) return;
toggle.popoverTargetElement = panel;
// The menu is written from the links of the bar: one source for both
links.forEach((link, i) => {
const item = document.createElement('a');
item.className = 'kodza-header-classic__item';
['href', 'target', 'rel', 'aria-current'].forEach((name) => {
if (link.hasAttribute(name)) item.setAttribute(name, link.getAttribute(name));
});
const index = document.createElement('span');
index.className = 'kodza-header-classic__index';
index.setAttribute('aria-hidden', 'true');
index.textContent = String(i + 1).padStart(2, '0');
const mask = document.createElement('span');
mask.className = 'kodza-header-classic__mask';
const word = document.createElement('span');
word.className = 'kodza-header-classic__word';
word.textContent = link.textContent.trim();
mask.append(word);
item.append(index, mask);
list.append(item);
});
const words = [...toggle.querySelectorAll(c('say'))];
const parts = [...panel.querySelectorAll(`${c('item')}, ${c('info')}`)];
let open = false;
let started = 0;
let held = null;
const rolls = new Map();
// The shutter starts under the header (or at --kz-header-classic-menu-top)
const place = () => {
const top = getComputedStyle(root).getPropertyValue('--kz-header-classic-menu-top').trim();
if (top && top !== 'auto') {
panel.style.setProperty('--kz-header-classic-from', top);
return;
}
const edge = Math.max(root.getBoundingClientRect().bottom, toggle.getBoundingClientRect().bottom);
panel.style.setProperty('--kz-header-classic-from', `${Math.max(0, Math.round(edge))}px`);
};
// Each row starts when the edge of the shutter gets to it
const time = () => {
const style = getComputedStyle(root);
const raw = style.getPropertyValue('--kz-header-classic-menu-duration').trim();
const duration = reduceMotion ? 0 : parseFloat(raw) * (/ms$/.test(raw) ? 1 : 1000) || 800;
const match = style.getPropertyValue('--kz-header-classic-menu-ease').match(/cubic-bezier\(([^)]+)\)/);
const curve = match ? match[1].split(',').map(Number) : [0.76, 0, 0.24, 1];
const box = panel.getBoundingClientRect();
const late = performance.now() - started;
parts.forEach((part) => {
const p = Math.min(1, Math.max(0, (part.getBoundingClientRect().top - box.top) / (box.height || 1)));
const delay = Math.max(0, duration * timeAt(curve, p) - late - 40);
part.style.setProperty('--kz-header-classic-delay', `${Math.round(delay)}ms`);
});
};
// Menu rolls to Close and back the same way: the old word goes up, the new one comes from below.
// A click during the roll turns it back from where the words are
const roll = () => {
if (reduceMotion || words.length < 2) return;
words.forEach((word, i) => {
const coming = i === Number(open);
const from = rolls.has(word) ? getComputedStyle(word).translate : coming ? '0 115%' : '0 0';
rolls.get(word)?.cancel();
const run = word.animate(
{ translate: [from, coming ? '0 0' : '0 -115%'] },
{ duration: 500, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' },
);
rolls.set(word, run);
run.finished.then(() => rolls.get(word) === run && rolls.delete(word), () => {});
});
};
// While it is open the page stays where it is
const hold = () => {
held = new AbortController();
const s = held.signal;
const spot = [scrollX, scrollY];
let last = 0;
document.addEventListener('wheel', (event) => {
if (!scrollsInside(panel, event.target, event.clientX, event.clientY, event.deltaY)) event.preventDefault();
}, { passive: false, signal: s });
document.addEventListener('touchstart', (event) => (last = event.touches[0].clientY), { passive: true, signal: s });
document.addEventListener('touchmove', (event) => {
const touch = event.touches[0];
const dy = last - touch.clientY;
last = touch.clientY;
if (!scrollsInside(panel, event.target, touch.clientX, touch.clientY, dy)) event.preventDefault();
}, { passive: false, signal: s });
// A scrollbar dragged anyway: the page goes back to where it was
window.addEventListener('scroll', () => {
if (scrollX !== spot[0] || scrollY !== spot[1]) window.scrollTo({ left: spot[0], top: spot[1], behavior: 'instant' });
}, { signal: s });
// Wide enough for the links again: the shutter has no button left, it goes
window.addEventListener('resize', () => {
if (!toggle.getClientRects().length) panel.hidePopover();
else place();
}, { signal: s });
};
const release = () => {
held?.abort();
held = null;
};
panel.addEventListener('beforetoggle', (event) => {
open = event.newState === 'open';
toggle.setAttribute('aria-expanded', String(open));
words.forEach((word, i) => (i === Number(open) ? word.removeAttribute('aria-hidden') : word.setAttribute('aria-hidden', 'true')));
roll();
if (open) {
started = performance.now();
place();
hold();
} else {
panel.classList.remove('is-open');
release();
}
}, { signal });
panel.addEventListener('toggle', (event) => {
if (event.newState !== 'open' || !open) return;
time();
panel.classList.add('is-open');
}, { signal });
// Tab past the last link, or a link followed: the shutter rolls back up
panel.addEventListener('focusout', (event) => {
const next = event.relatedTarget;
if (open && next && !panel.contains(next) && next !== toggle) panel.hidePopover();
}, { signal });
panel.addEventListener('click', (event) => {
if (open && event.target.closest('a[href]')) panel.hidePopover();
}, { signal });
signal.addEventListener('abort', () => {
rolls.forEach((run) => run.cancel());
release();
if (open) panel.hidePopover();
});
}
// Kodza lifecycle, the same in every component: `kodza:init` starts the instances inside
// event.detail.root (the whole page by default), `kodza:destroy` stops them and puts their
// markup back. For themes and apps that swap content without a page load. Each running root
// keeps its markup as written under KODZA, shared by every Kodza script on the page: a Kodza
// component inside another one is saved as written, not half-started, and stopped with it.
const KODZA = Symbol.for('kodza');
const instances = new WeakMap();
const find = (scope = document) => [scope, ...scope.querySelectorAll(SELECTOR)].filter((el) => el.matches?.(SELECTOR));
const attrsOf = (el) => [...el.attributes].map((a) => [a.name, a.value]);
const put = (el, saved) => {
[...el.attributes].forEach((a) => el.removeAttribute(a.name));
saved.attrs.forEach(([name, value]) => el.setAttribute(name, value));
el.innerHTML = saved.html;
};
// The markup inside a root as written: Kodza components already running in it give back their own
const written = (root) => {
const all = [...root.querySelectorAll('*')];
if (!all.some((el) => el[KODZA])) return root.innerHTML;
const copy = root.cloneNode(true);
const twins = copy.querySelectorAll('*');
let last = null;
all.forEach((el, i) => {
if (!el[KODZA] || last?.contains(el)) return;
last = el;
put(twins[i], el[KODZA]);
});
return copy.innerHTML;
};
const init = (scope) => find(scope).forEach((root) => {
if (root.classList.contains('is-ready')) return; // already running, maybe from another copy of this script
const controller = new AbortController();
const saved = { html: written(root), attrs: attrsOf(root), stop: () => destroy(root) };
instances.set(root, { controller, saved });
root[KODZA] = saved;
mount(root, controller.signal);
root.classList.add('is-ready');
});
const destroy = (scope) => find(scope).forEach((root) => {
const instance = instances.get(root);
if (!instance) return;
instances.delete(root);
// The Kodza components running inside it stop first: once its markup is put back, their own
// script could not find them any more
root.querySelectorAll('*').forEach((el) => el[KODZA]?.stop());
instance.controller.abort();
delete root[KODZA];
put(root, instance.saved);
});
document.addEventListener('kodza:init', (event) => init(event.detail?.root));
document.addEventListener('kodza:destroy', (event) => destroy(event.detail?.root));
init();
// Loaded in <head>, the script runs before the markup exists: once more when it is parsed
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => init(), { once: true });
})();
'use client';
// Kodza — Header Classic, for React. From https://kodza.dev/components/header-classic/
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Next to this file: header-classic.css and header-classic.js, the component's CSS and JS from Kodza, as they are.
// Yours to edit: the markup is plain JSX below.
// The script changes this markup once React has rendered it (it adds layers, splits text, moves
// nodes), so React must not patch it afterwards. When a prop changes, the key gives React a fresh
// element: kodza:destroy stops the script on the old one, kodza:init starts it on the new one.
// Built from your data (tabs, rows, options)? Put what the markup is made of in the key, as plain
// values (ids, text, numbers): a change starts the script again on fresh markup. What the visitor
// changes (the open tab, the sort, what they type) is the script's: keep it out of the key, follow
// it with onClick or onInput on the root, and change it from your code as a visitor would (click
// the tab; set the field's value, then dispatch a bubbling input event).
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './header-classic.css';
export type HeaderClassicProps = Omit<ComponentPropsWithoutRef<'header'>, "children" | "vars"> & {
/** Settings, as CSS variables on the root */
vars?: {
/** default: transparent */
"--kz-header-classic-bg"?: string | number;
/** default: #0a0a0a */
"--kz-header-classic-fg"?: string | number;
/** default: rgba(10, 10, 10, 0.62) */
"--kz-header-classic-muted"?: string | number;
/** the Menu button — default: rgba(10, 10, 10, 0.06) */
"--kz-header-classic-soft"?: string | number;
/** the call to action — default: #0a0a0a */
"--kz-header-classic-ink"?: string | number;
/** default: #ffffff */
"--kz-header-classic-on-ink"?: string | number;
/** default: 72px */
"--kz-header-classic-height"?: string | number;
/** the row, centred — default: 1200px */
"--kz-header-classic-width"?: string | number;
/** default: 24px */
"--kz-header-classic-pad"?: string | number;
/** the line gliding — default: 0.42s */
"--kz-header-classic-duration"?: string | number;
/** how long its back edge waits — default: 0.08s */
"--kz-header-classic-lag"?: string | number;
/** default: cubic-bezier(0.22, 1, 0.36, 1) */
"--kz-header-classic-ease"?: string | number;
/** the shutter, below 900 px — default: #0a0a0a */
"--kz-header-classic-menu-bg"?: string | number;
/** default: #f2f2f0 */
"--kz-header-classic-menu-fg"?: string | number;
/** default: rgba(242, 242, 240, 0.62) */
"--kz-header-classic-menu-muted"?: string | number;
/** default: rgba(242, 242, 240, 0.16) */
"--kz-header-classic-menu-line"?: string | number;
/** where the shutter starts; auto = the bottom of the header — default: auto */
"--kz-header-classic-menu-top"?: string | number;
/** default: 24px */
"--kz-header-classic-menu-side"?: string | number;
/** default: clamp(34px, min(10cqw, calc((100cqh - 240px) / 6)), 96px) */
"--kz-header-classic-menu-size"?: string | number;
/** default: 0.8s */
"--kz-header-classic-menu-duration"?: string | number;
/** default: cubic-bezier(0.76, 0, 0.24, 1) */
"--kz-header-classic-menu-ease"?: string | number;
};
className?: string;
};
export function HeaderClassic({ vars, className, style, ...rest }: HeaderClassicProps) {
const ref = useRef<ComponentRef<'header'>>(null);
const classes = ["kodza-header-classic", className].filter(Boolean).join(' ');
// Everything the markup is made of: when it changes, React gets a fresh element (see the top)
const key = JSON.stringify([classes, vars, style, rest]);
// Starts the script on this element once React has rendered it, stops it when it goes
useEffect(() => {
const root = ref.current;
let live = true;
// @ts-ignore: a plain script, no types to find
import('./header-classic.js').then(() => {
if (live) document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root } }));
});
return () => {
live = false;
document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } }));
};
}, [key]);
return (
<header key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
<div className="kodza-header-classic__row">
<a className="kodza-header-classic__logo" href="#" aria-label="Pier, home">
<svg viewBox="0 0 24 22" width="22" height="20" aria-hidden="true">
<path d="M1 6h22v3.5H1z" />
<path d="M3.5 11.5h3V21h-3zM10.5 11.5h3V21h-3zM17.5 11.5h3V21h-3z" />
</svg>
<span>pier</span>
</a>
<nav className="kodza-header-classic__menu" aria-label="Main">
<ul className="kodza-header-classic__links">
<li>
<a className="kodza-header-classic__link" href="#" aria-current="page">Work</a>
</li>
<li>
<a className="kodza-header-classic__link" href="#">Services</a>
</li>
<li>
<a className="kodza-header-classic__link" href="#">Studio</a>
</li>
<li>
<a className="kodza-header-classic__link" href="#">Journal</a>
</li>
<li>
<a className="kodza-header-classic__link" href="#">Contact</a>
</li>
</ul>
<span className="kodza-header-classic__line" aria-hidden="true" />
</nav>
<div className="kodza-header-classic__end">
<a className="kodza-header-classic__cta" href="#">Start a project</a>
{' '}
<button className="kodza-header-classic__toggle" type="button" aria-expanded="false">
<span className="kodza-header-classic__lines" aria-hidden="true" />
<span className="kodza-header-classic__label">
<span className="kodza-header-classic__say">Menu</span>
<span className="kodza-header-classic__say" aria-hidden="true">Close</span>
</span>
</button>
<div className="kodza-header-classic__panel" popover="" aria-label="Menu">
<nav className="kodza-header-classic__list" aria-label="Main" />
<div className="kodza-header-classic__info">
<p className="kodza-header-classic__more">
<a className="kodza-header-classic__action" href="#">Start a project</a>
</p>
<p className="kodza-header-classic__socials">
<a href="#">GitHub</a>
<a href="#">X</a>
<a href="#">RSS</a>
</p>
</div>
</div>
</div>
</div>
</header>
);
}
Checked
Robots poked at it before you did. Every component goes through the same checks, and again each time it changes.