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 shop header: the name, the categories, a search that opens over them, the account and a bag whose count rolls when something is added. Below 900 px, a menu the page steps aside for.
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 Shop to my page.
claude mcp add -t http kodza https://kodza.dev/api/mcp
<header class="kodza-header-shop">
<div class="kodza-header-shop__row">
<a class="kodza-header-shop__logo" href="/" aria-label="Galet, home">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12.5C3 7 7.5 3 13 3s8 3.4 8 7.6C21 15.6 16.6 18 11.4 18 6.4 18 3 16.2 3 12.5z" /></svg>
<span>galet</span>
</a>
<nav class="kodza-header-shop__menu" aria-label="Shop">
<ul class="kodza-header-shop__links">
<li><a class="kodza-header-shop__item" href="#" aria-current="page">New in</a></li>
<li><a class="kodza-header-shop__item" href="#">Kitchen</a></li>
<li><a class="kodza-header-shop__item" href="#">Table</a></li>
<li><a class="kodza-header-shop__item" href="#">Bath</a></li>
<li><a class="kodza-header-shop__item" href="#">Linen</a></li>
<li><a class="kodza-header-shop__item" href="#">Sale</a></li>
</ul>
</nav>
<form class="kodza-header-shop__search" role="search" action="/">
<div class="kodza-header-shop__field">
<input class="kodza-header-shop__input" type="search" name="s" placeholder="Search Galet" aria-label="Search the shop">
<input type="hidden" name="post_type" value="product">
</div>
<button class="kodza-header-shop__find" type="button" aria-label="Search" aria-expanded="false" data-close="Close search">
<svg class="kodza-header-shop__glass" viewBox="0 0 24 24" aria-hidden="true"><circle cx="10.8" cy="10.8" r="6.2" /><path d="m15.4 15.4 4.6 4.6" /></svg>
<span class="kodza-header-shop__x" aria-hidden="true"></span>
</button>
</form>
<div class="kodza-header-shop__end">
<a class="kodza-header-shop__account" href="/account/" aria-label="Account">
<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="8.2" r="3.6" /><path d="M4.8 20.2c.9-3.6 3.7-5.6 7.2-5.6s6.3 2 7.2 5.6" /></svg>
</a>
<a class="kodza-header-shop__cart" href="/cart/" aria-label="Bag, 2 items" data-count="2">
<svg class="kodza-header-shop__bag" viewBox="0 0 24 24" aria-hidden="true"><path d="M5.2 8.2h13.6l-1 11a2 2 0 0 1-2 1.8H8.2a2 2 0 0 1-2-1.8z" /><path d="M9 8.2V6.8a3 3 0 0 1 6 0v1.4" /></svg>
<span class="kodza-header-shop__count" aria-hidden="true">2</span>
</a>
<button class="kodza-header-shop__toggle" type="button" aria-haspopup="dialog" aria-expanded="false"><span class="kodza-header-shop__lines" aria-hidden="true"></span>Menu</button>
</div>
</div>
<div class="kodza-header-shop__panel" role="dialog" aria-modal="true" aria-label="Menu" tabindex="-1" hidden>
<span class="kodza-header-shop__ground" aria-hidden="true"></span>
<span class="kodza-header-shop__card" aria-hidden="true"></span>
<span class="kodza-header-shop__shade" aria-hidden="true"></span>
<div class="kodza-header-shop__side">
<div class="kodza-header-shop__bar">
<p class="kodza-header-shop__label">Your bag stays put.</p>
<button class="kodza-header-shop__close" type="button"><span class="kodza-header-shop__cross" aria-hidden="true"></span><span class="kodza-header-shop__say"><span>Close</span></span></button>
</div>
<!-- Written from the categories in the bar, unless you put your own links here -->
<nav class="kodza-header-shop__nav" aria-label="Shop, menu"></nav>
<div class="kodza-header-shop__info">
<div class="kodza-header-shop__group">
<p class="kodza-header-shop__small">Your account</p>
<p class="kodza-header-shop__pair"><a href="/account/">Sign in</a><a href="/account/orders/">Your orders</a></p>
</div>
<div class="kodza-header-shop__group">
<p class="kodza-header-shop__small">Help</p>
<p class="kodza-header-shop__pair"><a href="mailto:hello@galet.example">hello@galet.example</a><span>Free returns, 30 days</span></p>
</div>
<p class="kodza-header-shop__small">Esc, or click the page.</p>
</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 Shop
A shop's header: the name on the left, the departments next to it, then search, your account
and the bag on the right. The magnifier rolls the search field out across the departments,
which slide away under it, and turns into the close button; Esc or a click elsewhere rolls it
back. The bag counts what's in it: change data-count and the figures roll, the bag gives a
little bounce. Below 900 px the departments wait behind a Menu button: the page slides aside
and scales back, and the menu is revealed underneath it, on the right (Side Reveal Menu),
written from the same links. The bag stays in the bar.
Mark the wrapper of your site with data-header-shop-page, or name it with data-page="…" (the
wrapper of most WordPress themes is found on its own).
Everything is tuned with the --kz-header-shop-* variables (--kz-header-shop-menu-* for the
menu). */
.kodza-header-shop {
--kz-header-shop-bg: #f2f2f0;
--kz-header-shop-fg: #0a0a0a;
--kz-header-shop-muted: rgba(10, 10, 10, 0.62);
--kz-header-shop-soft: rgba(10, 10, 10, 0.06); /* the round buttons under the pointer, the Menu button */
--kz-header-shop-rule: rgba(10, 10, 10, 0.1);
--kz-header-shop-field: color-mix(in srgb, var(--kz-header-shop-fg) 6%, var(--kz-header-shop-bg)); /* the search field */
--kz-header-shop-top: var(--wp-admin--admin-bar--height, 0px); /* below the WordPress admin bar */
--kz-header-shop-height: 72px;
--kz-header-shop-width: 1200px; /* the row, centred */
--kz-header-shop-pad: 24px;
--kz-header-shop-search-duration: 0.6s;
--kz-header-shop-search-ease: cubic-bezier(0.76, 0, 0.24, 1);
/* The menu, below 900 px */
--kz-header-shop-menu-bg: #0a0a0a;
--kz-header-shop-menu-fg: #f2f2f0;
--kz-header-shop-menu-muted: rgba(242, 242, 240, 0.62);
--kz-header-shop-menu-top: calc(var(--wp-admin--admin-bar--height, 0px) + 20px); /* Close lands on Menu on its own; this is where it goes if Menu is somewhere else */
--kz-header-shop-menu-side: 24px;
--kz-header-shop-menu-width: min(clamp(340px, 40cqw, 560px), calc(100cqw - 56px));
--kz-header-shop-menu-size: clamp(36px, min(4.6cqw + 8px, calc((100cqh - 300px) / 6.6)), 72px);
--kz-header-shop-menu-depth: 0.88; /* the page's size once it has stepped aside */
--kz-header-shop-menu-shadow: 0 32px 80px -24px rgba(0, 0, 0, 0.45);
--kz-header-shop-menu-shade: 0.5; /* how dark the page gets when the menu slides over it */
--kz-header-shop-menu-duration: 1s;
--kz-header-shop-menu-ease: cubic-bezier(0.76, 0, 0.24, 1);
--kz-header-shop-page: auto; /* the page colour while it steps aside; auto = the first background above it */
position: sticky;
top: var(--kz-header-shop-top);
z-index: 50;
display: block;
box-sizing: border-box;
width: 100%;
margin: 0;
padding: 0;
background: var(--kz-header-shop-bg);
box-shadow: inset 0 -1px 0 var(--kz-header-shop-rule);
color: var(--kz-header-shop-fg);
font-size: 15px;
line-height: 1.4;
text-align: left;
container-type: inline-size;
-webkit-font-smoothing: antialiased;
}
.kodza-header-shop__row {
display: grid;
grid-template-columns: auto minmax(0, 1fr) auto;
align-items: center;
gap: 0 24px;
box-sizing: border-box;
max-width: var(--kz-header-shop-width);
height: var(--kz-header-shop-height);
/* Centred like margin: auto, but spelled out: Chrome can report a stale 0 for an auto margin */
margin: 0 max(0px, calc((100% - var(--kz-header-shop-width)) / 2));
padding: 0 var(--kz-header-shop-pad);
}
.kodza-header-shop__logo {
display: inline-flex;
grid-column: 1;
grid-row: 1;
align-items: center;
gap: 8px;
height: 40px;
margin: 0;
padding: 0 4px;
border-radius: 6px;
color: var(--kz-header-shop-fg);
font-size: 21px;
font-weight: 600;
line-height: 1;
letter-spacing: -0.045em;
text-decoration: none;
white-space: nowrap;
transition: translate var(--kz-header-shop-search-duration) var(--kz-header-shop-search-ease), opacity 0.3s;
}
.kodza-header-shop__logo svg {
display: block;
flex: none;
width: 22px;
height: 22px;
fill: currentColor;
}
.kodza-header-shop__logo:focus-visible {
outline: 2px solid var(--kz-header-shop-fg);
outline-offset: 2px;
}
/* The departments: they fade out as the search field rolls out over them, and come back as it
rolls away */
.kodza-header-shop__menu {
grid-column: 2;
grid-row: 1;
min-width: 0;
margin: -4px 44px -4px -4px; /* room for the focus rings; the magnifier sits on the right */
padding: 4px;
overflow: clip;
}
.kodza-header-shop__links {
display: flex;
align-items: center;
gap: 2px;
width: max-content;
margin: 0;
padding: 0;
list-style: none;
transition: opacity 0.35s calc(var(--kz-header-shop-search-duration) * 0.3);
}
.kodza-header-shop__links > li {
display: block;
margin: 0;
padding: 0;
list-style: none;
}
/* A line draws itself under the link pointed at, from the left, and leaves to the right */
.kodza-header-shop__item {
position: relative;
display: inline-flex;
align-items: center;
box-sizing: border-box;
height: 40px;
margin: 0;
padding: 0 14px;
border-radius: 8px;
color: var(--kz-header-shop-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-shop__item::after {
content: "";
position: absolute;
left: 14px;
right: 14px;
bottom: 9px;
height: 1.5px;
border-radius: 1px;
background: currentColor;
transform: scaleX(0);
transform-origin: 100% 50%;
transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.kodza-header-shop__item[aria-current="page"],
.kodza-header-shop__item:focus-visible {
color: var(--kz-header-shop-fg);
}
.kodza-header-shop__item:focus-visible {
outline: 2px solid var(--kz-header-shop-fg);
outline-offset: 2px;
}
@media (hover: hover) {
.kodza-header-shop__item:hover {
color: var(--kz-header-shop-fg);
}
.kodza-header-shop__item:hover::after {
transform: scaleX(1);
transform-origin: 0% 50%;
}
}
.kodza-header-shop__item[aria-current="page"]::after {
transform: scaleX(1);
}
.kodza-header-shop.is-searching .kodza-header-shop__links {
opacity: 0;
transition: opacity 0.3s;
}
/* Search: the field rolls out from the magnifier, leftwards, over the departments; the
magnifier rides its edge, and Close is left where it was */
.kodza-header-shop__search {
position: relative;
display: flex;
grid-column: 2;
grid-row: 1;
justify-content: flex-end;
align-items: center;
height: 40px;
margin: 0;
padding: 0;
pointer-events: none;
}
/* The field grows from the button's own circle, its outline whole all the way, and melts back
into it on the way home */
.kodza-header-shop__field {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 40px;
border-radius: 20px;
background: var(--kz-header-shop-field);
box-shadow: inset 0 0 0 1px var(--kz-header-shop-rule);
opacity: 0;
visibility: hidden;
transition:
width var(--kz-header-shop-search-duration) var(--kz-header-shop-search-ease),
box-shadow 0.2s,
opacity 0.2s calc(var(--kz-header-shop-search-duration) * 0.8),
visibility 0s linear calc(var(--kz-header-shop-search-duration) * 0.8 + 0.2s);
}
.kodza-header-shop__search.is-open .kodza-header-shop__field {
width: 100%;
opacity: 1;
visibility: visible;
pointer-events: auto;
transition:
width var(--kz-header-shop-search-duration) var(--kz-header-shop-search-ease),
box-shadow 0.2s,
opacity 0s,
visibility 0s;
}
.kodza-header-shop__field:focus-within {
box-shadow: inset 0 0 0 1.5px var(--kz-header-shop-fg);
}
.kodza-header-shop__input {
display: block;
box-sizing: border-box;
width: 100%;
min-width: 0;
height: 100%;
margin: 0;
padding: 0 44px;
border: 0;
border-radius: 20px;
background: transparent;
box-shadow: none;
outline: none;
color: var(--kz-header-shop-fg);
font: inherit;
font-size: 15px;
font-weight: 400;
line-height: normal;
letter-spacing: -0.01em;
caret-color: transparent;
-webkit-appearance: none;
appearance: none;
transition: color 0.12s, caret-color 0.01s;
}
.kodza-header-shop__search.is-open .kodza-header-shop__input {
caret-color: var(--kz-header-shop-fg);
transition: color 0.3s calc(var(--kz-header-shop-search-duration) * 0.9), caret-color 0.01s calc(var(--kz-header-shop-search-duration) * 0.9);
}
.kodza-header-shop__search:not(.is-open) .kodza-header-shop__input {
color: transparent;
}
/* The hint waits for the magnifier to land, so the two never cross */
.kodza-header-shop__input::placeholder {
color: transparent;
opacity: 1;
transition: color 0.12s;
}
.kodza-header-shop__search.is-open .kodza-header-shop__input::placeholder {
color: var(--kz-header-shop-muted);
transition: color 0.3s calc(var(--kz-header-shop-search-duration) * 0.9);
}
.kodza-header-shop__input::-webkit-search-cancel-button,
.kodza-header-shop__input::-webkit-search-decoration {
-webkit-appearance: none;
appearance: none;
}
/* The round buttons: search, account, bag */
.kodza-header-shop__find,
.kodza-header-shop__account,
.kodza-header-shop__cart {
position: relative;
display: inline-grid;
flex: none;
place-items: center;
box-sizing: border-box;
width: 40px;
height: 40px;
margin: 0;
padding: 0;
border: 0;
border-radius: 999px;
background: transparent;
color: var(--kz-header-shop-fg);
font: inherit;
text-decoration: none;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
transition: background-color 0.2s;
}
.kodza-header-shop__find {
pointer-events: auto;
}
@media (hover: hover) {
.kodza-header-shop__account:hover,
.kodza-header-shop__cart:hover {
background: var(--kz-header-shop-soft);
}
}
/* The search button's disc sits on its own layer: open, the field is the circle, so the disc
steps out at once, and on the way home it waits for the field to melt into it */
.kodza-header-shop__find {
isolation: isolate;
}
.kodza-header-shop__find::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background: transparent;
transition: background-color 0.2s, opacity 0.2s calc(var(--kz-header-shop-search-duration) * 0.8);
}
@media (hover: hover) {
.kodza-header-shop__find:hover::before {
background: var(--kz-header-shop-soft);
}
}
.kodza-header-shop__search.is-open .kodza-header-shop__find::before {
opacity: 0;
transition: background-color 0.2s, opacity 0.15s;
}
.kodza-header-shop__find:focus-visible,
.kodza-header-shop__account:focus-visible,
.kodza-header-shop__cart:focus-visible {
outline: 2px solid var(--kz-header-shop-fg);
outline-offset: 2px;
}
.kodza-header-shop__find svg,
.kodza-header-shop__account svg,
.kodza-header-shop__bag {
display: block;
grid-area: 1 / 1;
width: 21px;
height: 21px;
overflow: visible;
fill: none;
stroke: currentColor;
stroke-width: 1.6;
stroke-linecap: round;
stroke-linejoin: round;
}
.kodza-header-shop__bag {
width: 22px;
height: 22px;
transform-origin: 50% 85%;
}
/* The magnifier leaves the button for the far end of the field; a cross turns into its place */
.kodza-header-shop__glass {
transition: translate var(--kz-header-shop-search-duration) var(--kz-header-shop-search-ease);
}
.kodza-header-shop__search.is-open .kodza-header-shop__glass {
translate: calc(-1 * var(--kz-header-shop-run, 0px)) 0;
pointer-events: none;
}
.kodza-header-shop__x {
position: relative;
grid-area: 1 / 1;
width: 14px;
height: 14px;
opacity: 0;
scale: 0.6;
rotate: -45deg;
transition:
opacity 0.2s,
scale 0.3s cubic-bezier(0.22, 1, 0.36, 1),
rotate 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.kodza-header-shop__search.is-open .kodza-header-shop__x {
opacity: 1;
scale: 1;
rotate: 0deg;
transition:
opacity 0.25s calc(var(--kz-header-shop-search-duration) * 0.45),
scale 0.45s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--kz-header-shop-search-duration) * 0.45),
rotate 0.45s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--kz-header-shop-search-duration) * 0.45);
}
.kodza-header-shop__x::before,
.kodza-header-shop__x::after {
content: "";
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 1.6px;
margin-top: -0.8px;
border-radius: 1px;
background: currentColor;
rotate: 45deg;
}
.kodza-header-shop__x::after {
rotate: -45deg;
}
.kodza-header-shop__end {
display: flex;
grid-column: 3;
grid-row: 1;
align-items: center;
justify-self: end;
gap: 4px;
margin: 0;
}
/* The bag's count: the figures roll when it changes, and the bag bounces */
.kodza-header-shop__count {
position: absolute;
top: 2px;
left: calc(50% + 2px);
display: inline-flex;
justify-content: center;
box-sizing: border-box;
min-width: 18px;
height: 18px;
padding: 0 5px;
overflow: hidden;
border-radius: 999px;
background: var(--kz-header-shop-fg);
box-shadow: 0 0 0 2px var(--kz-header-shop-bg);
color: var(--kz-header-shop-bg);
font-size: 11px;
font-weight: 600;
line-height: 18px;
letter-spacing: 0;
font-variant-numeric: tabular-nums;
pointer-events: none;
transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
}
.kodza-header-shop__cart[data-count="0"] .kodza-header-shop__count,
.kodza-header-shop__cart:not([data-count]) .kodza-header-shop__count {
opacity: 0;
transform: scale(0.3);
transition: transform 0.25s cubic-bezier(0.65, 0, 0.35, 1), opacity 0.2s 0.05s;
}
.kodza-header-shop__digit {
position: relative;
display: block;
height: 18px;
overflow: hidden;
}
.kodza-header-shop__digit > span {
display: block;
}
.kodza-header-shop__digit > span + span {
position: absolute;
top: 0;
left: 0;
}
/* The Menu button, and Close in the menu */
.kodza-header-shop__toggle,
.kodza-header-shop__close {
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;
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-shop__toggle {
margin-left: 4px;
background: var(--kz-header-shop-soft);
color: var(--kz-header-shop-fg);
}
.kodza-header-shop__close {
background: var(--kz-header-shop-menu-fg);
color: var(--kz-header-shop-menu-bg);
}
.kodza-header-shop__toggle:focus-visible {
outline: 2px solid var(--kz-header-shop-fg);
outline-offset: 3px;
}
.kodza-header-shop__close:focus-visible,
.kodza-header-shop__info a:focus-visible {
outline: 2px solid var(--kz-header-shop-menu-fg);
outline-offset: 4px;
}
.kodza-header-shop__link:focus-visible {
outline: none;
}
/* Two lines on the button: they meet and cross as the page leaves, and Close is uncovered with
them crossed, in the same place */
.kodza-header-shop__lines,
.kodza-header-shop__cross {
position: relative;
flex: none;
width: 14px;
height: 8px;
}
.kodza-header-shop__lines::before,
.kodza-header-shop__lines::after,
.kodza-header-shop__cross::before,
.kodza-header-shop__cross::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;
}
.kodza-header-shop__lines::before,
.kodza-header-shop__cross::before {
top: 0;
}
.kodza-header-shop__lines::after,
.kodza-header-shop__cross::after {
top: 6px; /* whole pixels: both lines sit on the pixel grid the same way */
}
.kodza-header-shop__lines::before,
.kodza-header-shop__lines::after {
transition: clip-path 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Whole at rest, as an inset: the pointer slides it to a shorter one (from none it would jump) */
.kodza-header-shop__lines::after {
clip-path: inset(0 0 0 0);
}
.kodza-header-shop__toggle:hover .kodza-header-shop__lines::after {
clip-path: inset(0 45% 0 0);
}
.kodza-header-shop__toggle[aria-expanded="true"] .kodza-header-shop__lines::after {
clip-path: inset(0 0 0 0);
}
.kodza-header-shop__cross::before {
translate: 0 3px;
rotate: 45deg;
}
.kodza-header-shop__cross::after {
translate: 0 -3px;
rotate: -45deg;
}
/* The word rolls in from below its mask */
.kodza-header-shop__say {
display: grid;
margin: -3px 0;
padding: 3px 0;
overflow: hidden;
}
.kodza-header-shop__say > span {
display: block;
}
/* The menu: the whole screen, under the page while it is open (over it when there is none) */
.kodza-header-shop__panel {
position: fixed;
inset: 0;
z-index: 99990;
display: block;
box-sizing: border-box;
width: 100%;
height: 100%;
max-width: none;
max-height: none;
margin: 0;
padding: 0;
border: 0;
overflow: hidden;
background: transparent;
color: var(--kz-header-shop-menu-fg);
font: inherit;
font-size: 15px;
line-height: 1.4;
text-align: left;
container-type: size;
-webkit-font-smoothing: antialiased;
}
.kodza-header-shop__panel[hidden] {
display: none;
}
.kodza-header-shop__panel:focus {
outline: none;
}
.kodza-header-shop__ground,
.kodza-header-shop__shade {
position: absolute;
inset: 0;
}
.kodza-header-shop__ground {
background: var(--kz-header-shop-menu-bg);
pointer-events: none;
}
/* The card's shadow: under the page, on the same path (the script places it) */
.kodza-header-shop__card {
position: absolute;
inset: 0;
box-shadow: var(--kz-header-shop-menu-shadow);
pointer-events: none;
}
/* Without a page the menu slides in over it, and the page dims; a click on it closes */
.kodza-header-shop__shade {
display: none;
background: rgba(0, 0, 0, var(--kz-header-shop-menu-shade));
cursor: pointer;
}
.kodza-header-shop__panel.is-flat .kodza-header-shop__shade {
display: block;
}
.kodza-header-shop__panel.is-flat .kodza-header-shop__ground,
.kodza-header-shop__panel.is-flat .kodza-header-shop__card {
display: none;
}
/* The column on the right: it scrolls on its own on a short screen */
.kodza-header-shop__side {
position: absolute;
top: 0;
right: 0;
bottom: 0;
display: grid;
grid-template-rows: auto 1fr auto;
box-sizing: border-box;
width: var(--kz-header-shop-menu-width);
padding: 0 var(--kz-header-shop-menu-side) clamp(20px, 4cqh, 36px) clamp(28px, 3.4cqw, 48px);
overflow: hidden auto;
overscroll-behavior: contain;
background: var(--kz-header-shop-menu-bg);
}
.kodza-header-shop__bar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding-top: var(--kz-header-shop-menu-top);
}
.kodza-header-shop__label,
.kodza-header-shop__index,
.kodza-header-shop__small {
font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
font-size: 12px;
font-weight: 400;
line-height: 1.4;
letter-spacing: 0;
color: var(--kz-header-shop-menu-muted);
}
.kodza-header-shop__label {
margin: 0;
}
/* The links, big, in the middle of the column */
.kodza-header-shop__nav {
display: grid;
align-content: center;
justify-items: start;
padding: 32px 0;
}
.kodza-header-shop__link {
display: grid;
grid-template-columns: 36px max-content;
align-items: start;
color: inherit;
text-decoration: none;
outline: none;
}
.kodza-header-shop__index {
padding-top: calc(var(--kz-header-shop-menu-size) * 0.14);
transition: color 0.25s;
}
/* 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-shop__mask {
display: block;
margin: -0.06em 0 -0.22em;
padding: 0.06em 0 0.22em;
overflow: hidden;
font-size: var(--kz-header-shop-menu-size);
transition: translate 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.kodza-header-shop__word {
display: block;
font-size: var(--kz-header-shop-menu-size);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.045em;
white-space: nowrap;
}
/* Pointed at: the word steps aside and its number lights up. A link's focus is drawn on its
word, so it rises with it instead of waiting there as an empty box */
.kodza-header-shop__link:hover .kodza-header-shop__mask,
.kodza-header-shop__link:focus-visible .kodza-header-shop__mask {
translate: 0.14em 0;
}
.kodza-header-shop__link:hover .kodza-header-shop__index,
.kodza-header-shop__link:focus-visible .kodza-header-shop__index {
color: var(--kz-header-shop-menu-fg);
}
.kodza-header-shop__link:focus-visible .kodza-header-shop__word {
text-decoration: underline;
text-decoration-thickness: 2px;
text-underline-offset: 0.12em;
}
.kodza-header-shop__info {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 22px 16px;
}
.kodza-header-shop__info p {
margin: 0;
}
/* Two short lines in one paragraph, one under the other */
.kodza-header-shop__pair {
display: grid;
justify-items: start;
}
.kodza-header-shop__info > .kodza-header-shop__small {
grid-column: 1 / -1;
}
.kodza-header-shop__group {
display: grid;
align-content: start;
gap: 6px;
}
.kodza-header-shop__info a {
color: var(--kz-header-shop-menu-fg);
text-decoration: none;
border-radius: 2px;
}
.kodza-header-shop__info a:hover {
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
}
/* A narrow column: the contact details one under the other */
@container (max-width: 520px) {
.kodza-header-shop__info {
grid-template-columns: minmax(0, 1fr);
gap: 18px;
}
}
/* Under 900 px the departments and the account wait in the menu: the name, the magnifier, the
bag and Menu stay; the field rolls out over the name */
@container (max-width: 899px) {
.kodza-header-shop__row {
gap: 0 12px;
}
.kodza-header-shop__menu,
.kodza-header-shop__account {
display: none;
}
.kodza-header-shop__search {
grid-column: 1 / 3;
}
.kodza-header-shop.is-searching .kodza-header-shop__logo {
translate: -16px 0;
opacity: 0;
}
}
@container (min-width: 900px) {
.kodza-header-shop__toggle {
display: none;
}
}
/* A phone: a little less room on the sides */
@container (max-width: 519px) {
.kodza-header-shop__row {
--kz-header-shop-pad: 16px;
gap: 0 8px;
}
.kodza-header-shop__end {
gap: 2px;
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-header-shop__logo,
.kodza-header-shop__links,
.kodza-header-shop__item,
.kodza-header-shop__item::after,
.kodza-header-shop__field,
.kodza-header-shop__input,
.kodza-header-shop__find::before,
.kodza-header-shop__glass,
.kodza-header-shop__x,
.kodza-header-shop__input::placeholder,
.kodza-header-shop__count,
.kodza-header-shop__toggle *,
.kodza-header-shop__toggle *::before,
.kodza-header-shop__toggle *::after,
.kodza-header-shop__mask,
.kodza-header-shop__index {
transition-duration: 0.01ms !important;
transition-delay: 0s !important;
}
}
/* Dark site: the bar turns to ink, its words to paper, and the menu underneath to paper
.dark-section .kodza-header-shop {
--kz-header-shop-bg: #0a0a0a;
--kz-header-shop-fg: #f2f2f0;
--kz-header-shop-muted: rgba(242, 242, 240, 0.62);
--kz-header-shop-soft: rgba(242, 242, 240, 0.08);
--kz-header-shop-rule: rgba(242, 242, 240, 0.12);
--kz-header-shop-menu-bg: #f2f2f0;
--kz-header-shop-menu-fg: #0a0a0a;
--kz-header-shop-menu-muted: rgba(10, 10, 10, 0.62);
}
*/
/* kodza-guard e82ff539343d — 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-shop__logo):not(#_),
:where(.kodza-header-shop__item):not(#_),
:where(.kodza-header-shop__find):not(#_),
:where(.kodza-header-shop__account):not(#_),
:where(.kodza-header-shop__cart):not(#_),
:where(.kodza-header-shop__toggle):not(#_),
:where(.kodza-header-shop__close):not(#_) {
outline: revert;
outline-offset: revert;
}
:where(.kodza-header-shop__panel):not(#_) {
outline: revert;
}
:where(.kodza-header-shop__pair a:where(:not([class*="kodza-"]))):not(#_) {
outline: revert;
outline-offset: revert;
text-underline-offset: revert;
}
:where(.kodza-header-shop__menu):not(#_):where(:not([hidden])) {
display: revert;
}
:where(.kodza-header-shop__menu):not(#_):where([hidden]) {
display: none;
}
/* What the browser gives, on everything the component leaves to it */
.kodza-header-shop:not(#_) {
border: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
transition: revert;
list-style: 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-shop__logo:not(#_) {
border: 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-shop__menu:not(#_) {
border: 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-shop__links:not(#_) {
border: revert;
border-radius: revert;
outline: revert;
text-decoration: 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-shop__item:not(#_) {
border: revert;
list-style: revert;
float: 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-shop__search:not(#_),
.kodza-header-shop__field:not(#_),
.kodza-header-shop__x:not(#_),
.kodza-header-shop__end:not(#_),
.kodza-header-shop__lines:not(#_),
.kodza-header-shop__ground:not(#_),
.kodza-header-shop__card:not(#_),
.kodza-header-shop__shade:not(#_),
.kodza-header-shop__bar:not(#_),
.kodza-header-shop__cross:not(#_),
.kodza-header-shop__say:not(#_),
.kodza-header-shop__index:not(#_),
.kodza-header-shop__mask:not(#_),
.kodza-header-shop__word:not(#_),
.kodza-header-shop__info:not(#_),
.kodza-header-shop__group:not(#_),
.kodza-header-shop__logo span:where(:not([class*="kodza-"])):not(#_),
.kodza-header-shop__say span:where(:not([class*="kodza-"])):not(#_),
.kodza-header-shop__pair span:where(:not([class*="kodza-"])):not(#_) {
box-sizing: revert;
}
.kodza-header-shop__input:not(#_) {
text-decoration: revert;
list-style: revert;
float: revert;
position: revert;
outline-offset: 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;
white-space: revert;
min-height: revert;
}
.kodza-header-shop__find:not(#_) {
list-style: revert;
float: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
white-space: revert;
min-height: revert;
}
.kodza-header-shop__glass:not(#_) {
border: revert;
margin: 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;
}
.kodza-header-shop__account:not(#_),
.kodza-header-shop__cart:not(#_) {
list-style: revert;
float: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-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-shop__bag:not(#_),
.kodza-header-shop__logo svg:where(:not([class*="kodza-"])):not(#_),
.kodza-header-shop__account 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-shop__toggle:not(#_),
.kodza-header-shop__close: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-shop__panel:not(#_) {
box-shadow: revert;
outline-offset: revert;
}
.kodza-header-shop__label:not(#_),
.kodza-header-shop__small:not(#_) {
border: 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;
font-style: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-header-shop__nav:not(#_) {
border: revert;
margin: 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-shop__link:not(#_) {
border: revert;
margin: revert;
padding: revert;
border-radius: 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;
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-shop__pair:not(#_) {
border: 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-shop__links li:where(:not([class*="kodza-"]):not(.kodza-header-shop__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-shop__field input: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;
white-space: revert;
min-height: revert;
}
.kodza-header-shop__pair a:where(:not([class*="kodza-"])):not(#_) {
border: revert;
margin: 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-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-header-shop__label:not(#_):where(:not([hidden])),
.kodza-header-shop__small:not(#_):where(:not([hidden])),
.kodza-header-shop__field input:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])),
.kodza-header-shop__pair a:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])) {
display: revert;
}
.kodza-header-shop__label:not(#_):where([hidden]),
.kodza-header-shop__small:not(#_):where([hidden]),
.kodza-header-shop__field input:where(:not([class*="kodza-"])):not(#_):where([hidden]),
.kodza-header-shop__pair a:where(:not([class*="kodza-"])):not(#_):where([hidden]) {
display: none;
}
.kodza-header-shop__item:not(#_)::after,
.kodza-header-shop__find:not(#_)::before,
.kodza-header-shop__x:not(#_)::before,
.kodza-header-shop__x:not(#_)::after,
.kodza-header-shop__lines:not(#_)::before,
.kodza-header-shop__lines:not(#_)::after,
.kodza-header-shop__cross:not(#_)::before,
.kodza-header-shop__cross: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-shop:not(#_) {
position: sticky;
display: block;
box-sizing: border-box;
padding: 0;
background: var(--kz-header-shop-bg);
box-shadow: inset 0 -1px 0 var(--kz-header-shop-rule);
color: var(--kz-header-shop-fg);
font-size: 15px;
line-height: 1.4;
text-align: left;
}
.kodza-header-shop__logo:not(#_) {
display: inline-flex;
margin: 0;
padding: 0 4px;
border-radius: 6px;
color: var(--kz-header-shop-fg);
font-size: 21px;
font-weight: 600;
line-height: 1;
letter-spacing: -0.045em;
text-decoration: none;
transition: translate var(--kz-header-shop-search-duration) var(--kz-header-shop-search-ease), opacity 0.3s;
}
.kodza-header-shop__logo svg:not(#_) {
display: block;
}
.kodza-header-shop__logo:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-shop-fg);
outline-offset: 2px;
}
.kodza-header-shop__menu:not(#_) {
margin: -4px 44px -4px -4px;
padding: 4px;
}
.kodza-header-shop__links:not(#_) {
display: flex;
margin: 0;
padding: 0;
list-style: none;
transition: opacity 0.35s calc(var(--kz-header-shop-search-duration) * 0.3);
}
.kodza-header-shop__links > li:not(#_) {
display: block;
margin: 0;
padding: 0;
list-style: none;
}
.kodza-header-shop__item:not(#_) {
position: relative;
display: inline-flex;
box-sizing: border-box;
margin: 0;
padding: 0 14px;
border-radius: 8px;
color: var(--kz-header-shop-muted);
font-size: 15px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.01em;
text-decoration: none;
transition: color 0.2s;
}
.kodza-header-shop__item[aria-current="page"]:not(#_),
.kodza-header-shop__item:focus-visible:not(#_) {
color: var(--kz-header-shop-fg);
}
.kodza-header-shop__item:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-shop-fg);
outline-offset: 2px;
}
@media (hover: hover) {
.kodza-header-shop__item:hover:not(#_) {
color: var(--kz-header-shop-fg);
}
}
.kodza-header-shop.is-searching .kodza-header-shop__links:not(#_) {
transition: opacity 0.3s;
}
.kodza-header-shop__input:not(#_) {
display: block;
box-sizing: border-box;
width: 100%;
min-width: 0;
height: 100%;
margin: 0;
padding: 0 44px;
border: 0;
border-radius: 20px;
background: transparent;
box-shadow: none;
outline: none;
color: var(--kz-header-shop-fg);
font: inherit;
font-size: 15px;
font-weight: 400;
line-height: normal;
letter-spacing: -0.01em;
caret-color: transparent;
-webkit-appearance: none;
appearance: none;
transition: color 0.12s, caret-color 0.01s;
}
.kodza-header-shop__search.is-open .kodza-header-shop__input:not(#_) {
caret-color: var(--kz-header-shop-fg);
transition: color 0.3s calc(var(--kz-header-shop-search-duration) * 0.9), caret-color 0.01s calc(var(--kz-header-shop-search-duration) * 0.9);
}
.kodza-header-shop__search:not(.is-open) .kodza-header-shop__input:not(#_) {
color: transparent;
}
.kodza-header-shop__input:not(#_)::placeholder {
color: transparent;
opacity: 1;
transition: color 0.12s;
}
.kodza-header-shop__search.is-open .kodza-header-shop__input:not(#_)::placeholder {
color: var(--kz-header-shop-muted);
transition: color 0.3s calc(var(--kz-header-shop-search-duration) * 0.9);
}
.kodza-header-shop__input:not(#_)::-webkit-search-cancel-button,
.kodza-header-shop__input:not(#_)::-webkit-search-decoration {
-webkit-appearance: none;
appearance: none;
}
.kodza-header-shop__find:not(#_) {
position: relative;
display: inline-grid;
flex: none;
place-items: center;
box-sizing: border-box;
width: 40px;
height: 40px;
margin: 0;
padding: 0;
border: 0;
border-radius: 999px;
background: transparent;
color: var(--kz-header-shop-fg);
font: inherit;
text-decoration: none;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
transition: background-color 0.2s;
}
.kodza-header-shop__account:not(#_),
.kodza-header-shop__cart:not(#_) {
position: relative;
display: inline-grid;
box-sizing: border-box;
margin: 0;
padding: 0;
border: 0;
border-radius: 999px;
background: transparent;
color: var(--kz-header-shop-fg);
font: inherit;
text-decoration: none;
transition: background-color 0.2s;
}
.kodza-header-shop__find:not(#_) {
pointer-events: auto;
}
@media (hover: hover) {
.kodza-header-shop__account:hover:not(#_),
.kodza-header-shop__cart:hover:not(#_) {
background: var(--kz-header-shop-soft);
}
}
.kodza-header-shop__find:not(#_) {
isolation: isolate;
}
.kodza-header-shop__find:not(#_)::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background: transparent;
transition: background-color 0.2s, opacity 0.2s calc(var(--kz-header-shop-search-duration) * 0.8);
}
@media (hover: hover) {
.kodza-header-shop__find:hover:not(#_)::before {
background: var(--kz-header-shop-soft);
}
}
.kodza-header-shop__search.is-open .kodza-header-shop__find:not(#_)::before {
opacity: 0;
transition: background-color 0.2s, opacity 0.15s;
}
.kodza-header-shop__find:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-shop-fg);
outline-offset: 2px;
}
.kodza-header-shop__account:focus-visible:not(#_),
.kodza-header-shop__cart:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-shop-fg);
outline-offset: 2px;
}
.kodza-header-shop__find svg:not(#_),
.kodza-header-shop__account svg:not(#_),
.kodza-header-shop__bag:not(#_) {
display: block;
}
.kodza-header-shop__glass:not(#_) {
transition: translate var(--kz-header-shop-search-duration) var(--kz-header-shop-search-ease);
}
.kodza-header-shop__toggle:not(#_),
.kodza-header-shop__close: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;
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-shop__toggle:not(#_) {
margin-left: 4px;
background: var(--kz-header-shop-soft);
color: var(--kz-header-shop-fg);
}
.kodza-header-shop__close:not(#_) {
background: var(--kz-header-shop-menu-fg);
color: var(--kz-header-shop-menu-bg);
}
.kodza-header-shop__toggle:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-shop-fg);
outline-offset: 3px;
}
.kodza-header-shop__close:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-shop-menu-fg);
outline-offset: 4px;
}
.kodza-header-shop__info a:focus-visible:not(#_) {
outline: 2px solid var(--kz-header-shop-menu-fg);
outline-offset: 4px;
}
.kodza-header-shop__link:focus-visible:not(#_) {
outline: none;
}
.kodza-header-shop__panel:focus:not(#_) {
outline: none;
}
.kodza-header-shop__label:not(#_),
.kodza-header-shop__small:not(#_) {
font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
font-size: 12px;
font-weight: 400;
line-height: 1.4;
letter-spacing: 0;
color: var(--kz-header-shop-menu-muted);
}
.kodza-header-shop__label:not(#_) {
margin: 0;
}
.kodza-header-shop__nav:not(#_) {
display: grid;
padding: 32px 0;
}
.kodza-header-shop__link:not(#_) {
display: grid;
color: inherit;
text-decoration: none;
outline: none;
}
.kodza-header-shop__info p:not(#_) {
margin: 0;
}
.kodza-header-shop__pair:not(#_) {
display: grid;
}
.kodza-header-shop__info a:not(#_) {
color: var(--kz-header-shop-menu-fg);
text-decoration: none;
border-radius: 2px;
}
.kodza-header-shop__info a:hover:not(#_) {
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
}
@container (max-width: 899px) {
.kodza-header-shop__menu:not(#_),
.kodza-header-shop__account:not(#_) {
display: none;
}
}
@container (min-width: 900px) {
.kodza-header-shop__toggle:not(#_) {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-header-shop__logo:not(#_),
.kodza-header-shop__links:not(#_),
.kodza-header-shop__item:not(#_),
.kodza-header-shop__glass:not(#_) {
transition-duration: 0.01ms !important;
transition-delay: 0s !important;
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-header-shop__input:not(#_),
.kodza-header-shop__find:not(#_)::before,
.kodza-header-shop__input:not(#_)::placeholder {
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 Shop
// The shop header: the name, the categories, then a glass that opens the search over them (the
// field unrolls from the button, the glass slides to its far end, the links step out to the
// left), the account and the bag, whose count rolls digit by digit whenever data-count changes
// (as in Add to Cart, which can aim at it). Below 900 px a Menu button opens Side Reveal: the
// page steps aside to the left, the menu is under it, its links written from the categories.
(() => {
// The two lines that change from one menu of the family to the next
const NAME = 'header-shop';
const VARS = ['menu-bg', 'menu-fg', 'menu-muted', 'menu-top', 'menu-side', 'menu-size', 'menu-width', 'menu-shade', 'menu-shadow'];
// ---------- Menu engine (begin) ----------
// The same block in every burger menu of the family (Trapdoor, Fullscreen, Side Reveal...),
// copied as is. .kodza-NAME__toggle opens .kodza-NAME__panel and the menu's opening plays as
// one timeline, backwards to close, from wherever it is. While open the panel leaves the menu
// with its variables (VARS), the page stays put (wheel, swipe, keys), Tab stays inside, Escape
// closes and the focus goes back to the button. A page that takes part (data-NAME-page,
// data-page="…" on the menu, or a theme's wrapper) takes its fixed elements along and is put
// back exactly as it was. Each menu only writes how it moves: see `menu`.
const SELECTOR = `.kodza-${NAME}`;
const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
const RISE = 'cubic-bezier(0.22, 1, 0.36, 1)';
const SWING = 'cubic-bezier(0.65, 0, 0.35, 1)';
const BACK = 1.6; // closing replays the opening backwards, this much faster
const FOCUSABLE = 'a[href], button:not([disabled]), input, select, textarea, [tabindex]:not([tabindex="-1"])';
const taken = new WeakMap(); // page → how to put it back at once (one menu moves a page at a time)
const transparent = (color) => !color || color === 'transparent' || /^rgba\(.*,\s*0\)$/.test(color);
// [time, progress] pairs along a cubic-bezier(): when does the edge pass a given row?
const curve = (easing) => {
const n = (easing.match(/-?\d*\.?\d+/g) || []).map(Number);
const [x1, y1, x2, y2] = n.length === 4 ? n : [0.76, 0, 0.24, 1];
const at = (s, a, b) => 3 * (1 - s) * (1 - s) * s * a + 3 * (1 - s) * s * s * b + s * s * s;
return Array.from({ length: 101 }, (_, i) => [at(i / 100, x1, x2), at(i / 100, y1, y2)]);
};
// A transform makes the page the containing block of its fixed elements: they are found
// first, then moved back to where they were on screen (see `rideAlong`)
const fixedInside = (page) => {
const found = [];
const walker = document.createTreeWalker(page, NodeFilter.SHOW_ELEMENT, {
acceptNode: (el) => {
const style = getComputedStyle(el);
if (style.display === 'none') return NodeFilter.FILTER_REJECT;
if (style.position !== 'fixed') return NodeFilter.FILTER_SKIP;
found.push({ el, box: el.getBoundingClientRect(), shift: style.translate, inline: el.style.translate, attr: el.hasAttribute('style') });
return NodeFilter.FILTER_REJECT;
},
});
while (walker.nextNode()) {
// acceptNode collects them
}
return found;
};
const rideAlong = (fixed, k) => fixed.forEach((item) => {
const now = item.el.getBoundingClientRect();
const [x = 0, y = 0] = item.shift === 'none' ? [] : item.shift.split(' ').map(parseFloat);
item.el.style.translate = `${x + (item.box.left - now.left) / k}px ${y + (item.box.top - now.top) / k}px`;
});
const letGo = (fixed) => fixed.forEach(({ el, inline, attr }) => {
el.style.translate = inline;
if (!attr && !el.getAttribute('style')) el.removeAttribute('style');
});
// Where the page is, in screen pixels: its box, its scale (a scaled parent changes nothing
// once divided by `k`), and the part of it that is on screen
const view = (page) => {
const r = page.getBoundingClientRect();
const { clientWidth: vw, clientHeight: vh } = document.documentElement;
return {
r,
k: page.offsetWidth ? r.width / page.offsetWidth : 1,
top: Math.max(r.top, 0),
bottom: Math.min(r.bottom, vh),
left: Math.max(r.left, 0),
right: Math.min(r.right, vw),
};
};
// One menu. `setup(m)` receives its parts (toggle, panel, closer, links, one, all, css, cut, and
// while open page, reduced) and returns what the menu does itself:
// page 'under' when the menu lies under the page that moves, 'over' when it covers the
// page that moves under it; without it the page stays as it is
// rig(page) sets the flat page up for the ride, returns its geometry with `k` (its scale);
// again on resize
// frames(g) the page's keyframes, set again on resize
// build(add, mode, g) the opening, add(el, keyframes, delay, duration, easing, options) per
// animation; mode is 'page', 'flat' (no page found) or 'reduced'
// ready(), entry(), key(event), resize(), reset() optional: before it opens, where the
// keyboard enters, a key of its own (true once handled), after a resize, once closed
const menu = (root, signal, setup) => {
const toggle = root.querySelector(`.kodza-${NAME}__toggle`);
const panel = root.querySelector(`.kodza-${NAME}__panel`);
if (!toggle || !panel) return;
const one = (s) => panel.querySelector(s);
const all = (s) => [...panel.querySelectorAll(s)];
const closer = one(`.kodza-${NAME}__close`);
const links = all(`.kodza-${NAME}__link`);
const home = [panel.parentNode, panel.nextSibling];
const css = (name) => getComputedStyle(root).getPropertyValue(`--kz-${NAME}-${name}`).trim();
let state = 'closed'; // closed, opening, open, closing
let sequence = []; // the opening: animations on one clock, so it can run backwards
let session = null; // what only lives while the menu is open
let moving = null; // the page taking part, and what it looked like before
let reduced = false;
let run = 0;
let then = null;
// The page: named on the menu (data-page="…"), or the marked wrapper around it, or else
// the wrapper of a WordPress theme (block themes, Astra, GeneratePress, Kadence, OceanWP,
// Blocksy, Divi…). Without one, the menu plays its sequence without the page
const findPage = () => {
let el = null;
try {
el = root.dataset.page ? document.querySelector(root.dataset.page) : null;
} catch {
el = null;
}
el = el || root.closest(`[data-${NAME}-page]`) || document.querySelector(`[data-${NAME}-page]`) || root.closest('.wp-site-blocks, #page, #outer-wrap, #main-container, #page-container');
if (!el || el === document.body || el === document.documentElement) return null;
// It has to fill the screen (below the WordPress admin bar): otherwise part of the site, a
// header outside it or the space under a short page, would be left out of the ride
const r = el.getBoundingClientRect();
const bar = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--wp-admin--admin-bar--height')) || 0;
const { clientWidth: vw, clientHeight: vh } = document.documentElement;
return r.top <= bar + 1 && r.left <= 1 && r.right >= vw - 1 && r.bottom >= vh - 1 ? el : null;
};
// The colour under the page's content, so the menu never shows through it
const ground = (page) => {
const own = css('page');
if (own && own !== 'auto') return own;
for (let el = page.parentElement; el; el = el.parentElement) {
const color = getComputedStyle(el).backgroundColor;
if (!transparent(color)) return color;
}
return '#ffffff';
};
// A flex or grid page shares its height out among its children: for the ride their sizes
// are held as they are, so a shorter page box changes nothing inside
const hold = (page, style) => {
if (style.display.includes('grid')) {
page.style.gridTemplateRows = style.gridTemplateRows;
page.style.gridTemplateColumns = style.gridTemplateColumns;
} else if (style.display.includes('flex')) {
const column = style.flexDirection.startsWith('column');
moving.held = [...page.children].map((el) => {
const own = getComputedStyle(el);
const item = { el, flex: el.style.flex, attr: el.hasAttribute('style') };
el.style.flex = `0 0 ${column ? own.height : own.width}`;
return item;
});
}
};
const release = () => {
moving.held.forEach(({ el, flex, attr }) => {
el.style.flex = flex;
if (!attr && !el.getAttribute('style')) el.removeAttribute('style');
});
moving.held = [];
Object.assign(moving.page.style, moving.cut);
};
// The page's box ends at `at` (its own pixels from its top) for the ride, the space it
// leaves kept as margin: what moves below it would stretch the scroll area. Checked on the
// spot: if that moves anything inside, even with the children held, the page is left as it
// was. Returns where the box ends
const cut = (at) => {
const { page } = moving;
const full = page.offsetHeight;
if (at >= full) return full;
const style = getComputedStyle(page);
const edges = style.boxSizing === 'border-box' ? 0 : ['paddingTop', 'paddingBottom', 'borderTopWidth', 'borderBottomWidth'].reduce((sum, side) => sum + parseFloat(style[side]), 0);
const margin = parseFloat(style.marginBottom) || 0;
const boxes = (els) => els.map((el) => el.getBoundingClientRect()).map((r) => [r.top, r.left, r.width, r.height]);
const kids = [...page.children];
const before = boxes(kids);
const shorten = () => {
page.style.height = `${Math.max(at - edges, 0)}px`;
page.style.overflowY = 'clip';
page.style.marginBottom = `${margin + full - at}px`;
return boxes(kids).some((box, i) => box.some((n, j) => Math.abs(n - before[i][j]) > 0.5));
};
let moved = shorten();
if (moved && /flex|grid/.test(style.display)) {
release();
hold(page, style);
moved = shorten();
}
if (moved) release();
return moved ? full : at;
};
const m = {
root, toggle, panel, closer, links, one, all, css, cut,
get page() {
return moving ? moving.page : null;
},
get reduced() {
return reduced;
},
};
const own = setup(m);
// With the page untransformed: where its fixed elements are, then the menu's own geometry
const rig = () => {
letGo(moving.fixed);
release();
moving.fixed = fixedInside(moving.page);
return own.rig(moving.page);
};
// The opening, as one timeline. Every animation gets an end delay that makes it as long as
// the longest, so running them all backwards is the exact reverse, even halfway through.
const timeline = (mode, g) => {
const steps = [];
const add = (el, frames, delay, duration, easing = RISE, extra = {}) => {
if (el) steps.push([el, frames, { delay, duration, easing, ...extra }]);
};
own.build(add, mode, g);
const total = Math.max(...steps.map(([, , o]) => o.delay + o.duration));
return steps.map(([el, frames, o]) => el.animate(frames, { ...o, fill: 'both', endDelay: total - o.delay - o.duration }));
};
const play = (forward) => {
const token = ++run;
sequence.forEach((animation) => {
animation.updatePlaybackRate(forward ? 1 : -BACK);
animation.play();
});
Promise.all(sequence.map((animation) => animation.finished)).then(() => {
if (token !== run) return;
if (forward) state = 'open';
else land();
}, () => {});
};
// Closed again: the animations, the borrowed styles and the listeners go, the panel goes home
const land = () => {
run++;
sequence.forEach((animation) => animation.cancel());
panel.getAnimations({ subtree: true }).forEach((animation) => animation.cancel());
sequence = [];
session?.abort();
session = null;
if (moving) {
const { page, saved, attr } = moving;
letGo(moving.fixed);
release();
Object.assign(page.style, saved);
if (!attr && !page.getAttribute('style')) page.removeAttribute('style');
if (taken.get(page) === land) taken.delete(page);
moving = null;
}
try {
if (panel.popover && panel.matches(':popover-open')) panel.hidePopover();
} catch {
// no popover support: it was a plain fixed layer
}
panel.removeAttribute('popover');
panel.removeAttribute('style');
panel.hidden = true;
if (panel.parentNode !== home[0]) home[0].insertBefore(panel, home[1]?.parentNode === home[0] ? home[1] : null);
own.reset?.();
state = 'closed';
const next = then;
then = null;
next?.();
};
// While open the page stays put: a wheel or a swipe only scrolls what scrolls in the menu
const scrollsInside = (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;
};
// The links you can reach now (a menu with levels hides the others)
const rows = () => links.filter((link) => link.getClientRects().length && !link.closest('[inert]'));
const keydown = (event) => {
if (state === 'closing' || event.defaultPrevented) return;
if (own.key?.(event)) return;
if (event.key === 'Escape') {
event.preventDefault();
shut();
return;
}
const current = document.activeElement;
if (event.key === 'Tab') {
const stops = all(FOCUSABLE).filter((el) => el.getClientRects().length && !el.closest('[inert]'));
const first = stops[0];
const last = stops[stops.length - 1];
const outside = !panel.contains(current) || current === panel;
if (outside || (event.shiftKey && current === first) || (!event.shiftKey && current === last)) {
event.preventDefault();
(event.shiftKey ? last : first)?.focus();
}
return;
}
const list = rows();
const i = list.indexOf(current);
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
event.preventDefault();
const step = event.key === 'ArrowDown' ? 1 : -1;
list[i < 0 ? (step > 0 ? 0 : list.length - 1) : (i + step + list.length) % list.length]?.focus();
} else if (event.key === 'Home' || event.key === 'End') {
event.preventDefault();
list[event.key === 'Home' ? 0 : list.length - 1]?.focus();
} else if ([' ', 'PageUp', 'PageDown'].includes(event.key) && !current?.closest?.('button, input, select, textarea')) {
event.preventDefault();
}
};
const listen = (s) => {
let last = 0;
const at = [scrollX, scrollY];
document.addEventListener('wheel', (event) => {
if (!scrollsInside(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(event.target, touch.clientX, touch.clientY, dy)) event.preventDefault();
}, { passive: false, signal: s });
document.addEventListener('keydown', keydown, { signal: s });
// A scrollbar dragged anyway: the page goes back to where it was
window.addEventListener('scroll', () => {
if (scrollX !== at[0] || scrollY !== at[1]) window.scrollTo({ left: at[0], top: at[1], behavior: 'instant' });
}, { signal: s });
let queued = 0;
window.addEventListener('resize', () => {
if (queued) return;
queued = requestAnimationFrame(() => {
queued = 0;
if (s.aborted) return;
if (moving) {
const effect = sequence.find((animation) => animation.effect.target === moving.page)?.effect;
effect?.setKeyframes([]);
const g = rig();
effect?.setKeyframes(own.frames(g));
rideAlong(moving.fixed, g.k);
}
own.resize?.();
});
}, { signal: s });
s.addEventListener('abort', () => cancelAnimationFrame(queued));
// A click on the page that moved aside brings it back
moving?.page.addEventListener('click', (event) => {
if (state === 'closing') return;
event.preventDefault();
event.stopPropagation();
shut();
}, { capture: true, signal: s });
};
const enter = (keyboard) => {
const target = keyboard ? own.entry?.() || links.find((link) => link.getAttribute('aria-current')) || rows()[0] || closer : panel;
target?.focus({ preventScroll: true });
};
const open = (keyboard) => {
if (state === 'opening' || state === 'open') return;
toggle.setAttribute('aria-expanded', 'true');
if (state === 'closing') {
state = 'opening';
then = null;
panel.style.pointerEvents = '';
play(true);
enter(keyboard);
return;
}
reduced = motion.matches;
const page = reduced || !own.page ? null : findPage();
const under = page && own.page === 'under';
let g = null;
if (page) {
taken.get(page)?.();
const { transformOrigin, backgroundColor, position, zIndex, height, overflowY, marginBottom, gridTemplateRows, gridTemplateColumns } = page.style;
moving = { page, saved: { transformOrigin, backgroundColor, position, zIndex }, cut: { height, overflowY, marginBottom, gridTemplateRows, gridTemplateColumns }, attr: page.hasAttribute('style'), fixed: [], held: [] };
taken.set(page, land);
g = rig();
const shown = getComputedStyle(page);
if (transparent(shown.backgroundColor)) page.style.backgroundColor = ground(page);
// Under the page: page over panel over the rest of the theme (a header, a sticky bar),
// under the admin bar
const still = shown.position === 'static';
if (under && (!still || ['top', 'right', 'bottom', 'left'].every((side) => shown[side] === 'auto'))) {
if (still) page.style.position = 'relative';
page.style.zIndex = '99991';
panel.style.zIndex = '99990';
}
}
// The panel leaves the menu while open, so the styles of a theme's content (links,
// paragraphs) never reach it: right under the page, or on top of everything
VARS.forEach((name) => panel.style.setProperty(`--kz-${NAME}-${name}`, css(name)));
panel.style.fontFamily = getComputedStyle(root).fontFamily;
if (under) page.before(panel);
else document.body.append(panel);
panel.hidden = false;
if (!under) {
try {
panel.popover = 'manual';
panel.showPopover();
} catch {
// no popover support: a fixed layer over the page
}
}
own.ready?.();
sequence = timeline(page ? 'page' : reduced ? 'reduced' : 'flat', g);
if (moving) rideAlong(moving.fixed, g.k);
session = new AbortController();
listen(session.signal);
state = 'opening';
play(true);
enter(keyboard);
};
const shut = (after) => {
if (state === 'closed' || state === 'closing') return;
then = after || null;
state = 'closing';
toggle.setAttribute('aria-expanded', 'false');
toggle.focus({ preventScroll: true });
// On its way out it lets clicks through: Menu, under it, opens it again from where it is
panel.style.pointerEvents = 'none';
play(false);
};
// Keyboard (Enter, Space) clicks have no detail: the focus then goes into the menu
toggle.addEventListener('click', (event) => open(event.detail === 0), { signal });
closer?.addEventListener('click', () => shut(), { signal });
// A link to this very page (#section, or just #) closes the menu first, then goes there
links.forEach((link) => link.addEventListener('click', (event) => {
const here = link.origin === location.origin && link.pathname === location.pathname && link.search === location.search;
if (!here || event.defaultPrevented || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
event.preventDefault();
const hash = link.hash;
shut(hash ? () => (location.hash = hash) : null);
}, { signal }));
// Back from another page (bfcache): the menu is closed, the page as it was
window.addEventListener('pageshow', (event) => event.persisted && state !== 'closed' && land(), { signal });
// Stopped while open: the page is put back at once and the panel goes back in place
signal.addEventListener('abort', () => {
then = null;
if (state !== 'closed') land();
});
};
// ---------- Menu engine (end) ----------
// Below 900 px the menu shows the bar's own categories: they are written from them, unless you
// wrote your own (a wp_nav_menu() for instance)
const drawer = (root) => {
const nav = root.querySelector(`.kodza-${NAME}__nav`);
if (!nav || nav.querySelector(`.kodza-${NAME}__link`)) return;
root.querySelectorAll(`.kodza-${NAME}__links .kodza-${NAME}__item`).forEach((item, i) => {
const span = (name, text) => {
const el = document.createElement('span');
el.className = `kodza-${NAME}__${name}`;
if (text) el.textContent = text;
return el;
};
const a = document.createElement('a');
a.className = `kodza-${NAME}__link`;
a.href = item.getAttribute('href') || '#';
if (item.hasAttribute('aria-current')) a.setAttribute('aria-current', item.getAttribute('aria-current'));
const mask = span('mask');
mask.append(span('word', item.textContent.trim()));
a.append(span('index', String(i + 1).padStart(2, '0')), mask);
nav.append(a);
});
};
// The search: the field unrolls from the glass over the room the categories leave (they step
// out to the left), and the glass slides to its far end while a cross takes its place. Below
// 900 px it runs over the name too. Esc, a click elsewhere or Tab out of it folds it back; Enter
// sends the form as it is (?s=…&post_type=product for WooCommerce)
const search = (root, signal) => {
const form = root.querySelector(`.kodza-${NAME}__search`);
const find = form?.querySelector(`.kodza-${NAME}__find`);
const input = form?.querySelector(`.kodza-${NAME}__input`);
if (!form || !find || !input) return;
const links = root.querySelector(`.kodza-${NAME}__links`);
const bar = root.querySelector(`.kodza-${NAME}__menu`);
const logo = root.querySelector(`.kodza-${NAME}__logo`);
const said = find.getAttribute('aria-label');
const isOpen = () => form.classList.contains('is-open');
// What the field covers can't be reached while it's open
const cover = () => {
if (links) links.inert = isOpen();
if (logo) logo.inert = isOpen() && (!bar || getComputedStyle(bar).display === 'none');
};
// How far the glass travels: from the button to the field's far end
const sizes = new ResizeObserver(() => {
form.style.setProperty(`--kz-${NAME}-run`, `${form.offsetWidth - find.offsetWidth}px`);
cover();
});
sizes.observe(form);
const set = (open) => {
form.classList.toggle('is-open', open);
root.classList.toggle('is-searching', open);
find.setAttribute('aria-expanded', String(open));
if (said) find.setAttribute('aria-label', open ? find.dataset.close || said : said);
cover();
if (open) input.focus({ preventScroll: true });
};
find.addEventListener('click', () => set(!isOpen()), { signal });
form.addEventListener('keydown', (event) => {
if (event.key !== 'Escape' || !isOpen()) return;
event.preventDefault();
set(false);
find.focus();
}, { signal });
document.addEventListener('pointerdown', (event) => {
if (isOpen() && !form.contains(event.target)) set(false);
}, { signal });
form.addEventListener('focusout', (event) => {
if (isOpen() && event.relatedTarget && !form.contains(event.relatedTarget)) set(false);
}, { signal });
signal.addEventListener('abort', () => {
sizes.disconnect();
set(false);
form.style.removeProperty(`--kz-${NAME}-run`);
}, { once: true });
};
// The bag (Add to Cart's cart): its count follows data-count, rolling only the digits that
// change (999 → 1,000 carries), and the bag gives a little bump each time something lands in it
const countOf = (cart) => Math.max(0, parseInt(cart.dataset.count, 10) || 0);
const format = (n) => new Intl.NumberFormat(document.documentElement.lang || undefined).format(n);
const mountCart = (cart, signal) => {
const count = cart.querySelector(`.kodza-${NAME}__count`);
const bag = cart.querySelector(`.kodza-${NAME}__bag`);
let shown = countOf(cart);
const label = (n) => {
const text = cart.getAttribute('aria-label');
if (!text) return;
cart.setAttribute('aria-label', text.replace(/\d[\d.,\u00a0\u202f]*/, format(n)).replace(/\bitems?\b/, n === 1 ? 'item' : 'items'));
};
// Old and new numbers aligned on the right: a digit that changes rolls (up when the count
// grows, down when it shrinks), the units first, and a digit that appears opens its room
const draw = (from, to) => {
const a = format(from);
const b = format(to);
const n = Math.max(a.length, b.length);
const was = a.padStart(n);
const now = b.padStart(n);
const k = to > from ? 1 : -1;
count.textContent = '';
for (let i = 0; i < n; i++) {
const cell = Object.assign(document.createElement('span'), { className: `kodza-${NAME}__digit` });
const next = Object.assign(document.createElement('span'), { textContent: now[i].trim() });
cell.append(next);
count.append(cell);
if (was[i] === now[i] || motion.matches) continue;
const old = Object.assign(document.createElement('span'), { textContent: was[i].trim() });
cell.append(old);
const timing = { duration: 460, delay: (n - 1 - i) * 60, easing: RISE };
next.animate([{ transform: `translateY(${100 * k}%)` }, { transform: 'none' }], { ...timing, fill: 'backwards' });
const leave = old.animate([{ transform: 'none' }, { transform: `translateY(${-100 * k}%)` }], { ...timing, fill: 'forwards' });
if (was[i] === ' ') cell.animate([{ width: '0px' }, { width: `${cell.offsetWidth}px` }], timing);
if (now[i] === ' ') cell.animate([{ width: `${old.offsetWidth}px` }, { width: '0px' }], { ...timing, fill: 'forwards' });
// Once out of sight the old digit goes, and so does a cell left empty
leave.finished.then(() => (now[i] === ' ' ? cell : old).remove(), () => {});
}
};
const observer = new MutationObserver(() => {
const next = countOf(cart);
if (next === shown) return;
const from = shown;
shown = next;
label(next);
if (!count) return;
// From zero the badge pops in with its number; to zero it shrinks away with the last one
if (from === 0) count.textContent = format(next);
else if (next > 0) draw(from, next);
if (motion.matches || next < from) return;
bag?.animate([
{ transform: 'none' },
{ transform: 'translateY(1.5px) scale(1.08, 0.9)', offset: 0.3 },
{ transform: 'translateY(-1px) scale(0.97, 1.04)', offset: 0.65 },
{ transform: 'none' },
], { duration: 520, easing: 'ease-out' });
if (from > 0) count.animate([{ transform: 'none' }, { transform: 'translateY(-3px) scale(1.12)', offset: 0.35 }, { transform: 'none' }], { duration: 420, easing: 'ease-out' });
});
observer.observe(cart, { attributes: true, attributeFilter: ['data-count'] });
signal.addEventListener('abort', () => observer.disconnect());
if (count) count.textContent = format(shown);
label(shown);
};
function mount(root, signal) {
drawer(root);
search(root, signal);
const cart = root.querySelector(`.kodza-${NAME}__cart`);
if (cart) mountCart(cart, signal);
menu(root, signal, (m) => {
const { panel, toggle, closer, links, one, all, css } = m;
const shade = one('.kodza-header-shop__shade');
const card = one('.kodza-header-shop__card');
const side = one('.kodza-header-shop__side');
const head = one('.kodza-header-shop__bar');
const cross = one('.kodza-header-shop__cross');
const say = one('.kodza-header-shop__say > span');
const label = one('.kodza-header-shop__label');
const infos = all('.kodza-header-shop__info > *');
const lines = toggle.querySelector('.kodza-header-shop__lines');
const depth = () => parseFloat(css('menu-depth')) || 0.88;
// Where the card stops: its right edge meets the menu column
const stop = () => side.getBoundingClientRect().left;
let last = null;
// Without a page the menu comes over it: a click on the dimmed page closes
shade.addEventListener('click', () => closer?.click(), { signal });
// The page steps aside from its right edge, at mid-height of what is on screen. Only its
// visible part shows, so its rounded corners are the screen's; a smaller page never
// stretches the scroll area
const rig = (page) => {
const { r, k, top, bottom, left, right } = view(page);
const clip = [(top - r.top) / k, (r.right - right) / k, (r.bottom - bottom) / k, (left - r.left) / k];
page.style.transformOrigin = `${(right - r.left) / k}px ${((top + bottom) / 2 - r.top) / k}px`;
last = { k, top, bottom, left, right, clip: clip.map((n) => `${Math.max(n, 0)}px`).join(' ') };
return last;
};
const frames = (g) => {
const s = depth();
return [
{ transform: 'translateX(0px) scale(1)', clipPath: `inset(${g.clip} round 0px)` },
{ transform: `translateX(${(stop() - g.right) / g.k}px) scale(${s})`, clipPath: `inset(${g.clip} round ${18 / (s * g.k)}px)` },
];
};
// The card's shadow, under the page: the same box on the same path
const shadow = (g) => {
const p = panel.getBoundingClientRect();
const kp = panel.offsetWidth ? p.width / panel.offsetWidth : 1;
const w = (g.right - g.left) / kp;
const s = depth();
// Its rounded corners where it lands are also written on it: the open state holds without
// the animation
Object.assign(card.style, {
inset: 'auto',
left: `${(g.left - p.left) / kp}px`,
top: `${(g.top - p.top) / kp}px`,
width: `${w}px`,
height: `${(g.bottom - g.top) / kp}px`,
transformOrigin: `${w}px 50%`,
borderRadius: `${18 / (s * kp)}px`,
});
return [
{ transform: 'translateX(0px) scale(1)', borderRadius: '0px' },
{ transform: `translateX(${(stop() - g.right) / kp}px) scale(${s})`, borderRadius: `${18 / (s * kp)}px` },
];
};
// The lines cross on the button, and Close is uncovered with them crossed
const turn = (el, sign) => {
const pseudoElement = sign > 0 ? '::before' : '::after';
return (add) => {
add(el, [{ translate: '0 0' }, { translate: `0 ${3 * sign}px` }], 0, 200, SWING, { pseudoElement });
add(el, [{ rotate: '0deg' }, { rotate: `${45 * sign}deg` }], 170, 300, RISE, { pseudoElement });
};
};
const build = (add, mode, g) => {
if (mode === 'reduced') {
add(panel, [{ opacity: 0 }, { opacity: 1 }], 0, 180, 'ease');
return;
}
const time = (parseFloat(css('menu-duration')) || 1) * 1000;
const ease = css('menu-ease') || 'cubic-bezier(0.76, 0, 0.24, 1)';
const col = side.getBoundingClientRect();
// The page steps aside and the menu is under it; without one, the column slides in over
// the dimmed page. Either way an edge goes from `right` to the column's left
let right = col.right;
if (mode === 'page') {
right = g.right;
add(m.page, frames(g), 0, time, ease);
add(card, shadow(g), 0, time, ease);
} else {
add(shade, [{ opacity: 0 }, { opacity: 1 }], 0, time, ease);
add(side, [{ transform: 'translateX(100%)' }, { transform: 'translateX(0%)' }], 0, time, ease);
}
// When that edge gets past `x` (screen pixels)
const samples = curve(ease);
const uncover = (x) => {
const i = samples.findIndex(([, p]) => right + (col.left - right) * p <= x);
return (i < 0 ? 1 : samples[i][0]) * time;
};
if (lines) [turn(lines, 1), turn(lines, -1)].forEach((go) => go(add));
if (cross) [turn(cross, 1), turn(cross, -1)].forEach((go) => go(add));
if (closer) add(say, [{ transform: 'translateY(110%)' }, { transform: 'translateY(0%)' }], uncover(closer.getBoundingClientRect().right) + 80, 600);
if (label) add(label, [{ opacity: 0, transform: 'translateY(6px)' }, { opacity: 1, transform: 'translateY(0px)' }], uncover(label.getBoundingClientRect().right) + 60, 600);
// Each word rises from its mask as the edge goes past it, never two at once
let at = 0;
links.forEach((link, i) => {
const box = (link.querySelector('.kodza-header-shop__mask') || link).getBoundingClientRect();
at = Math.max(i ? at + 70 : 0, uncover(box.left + box.width / 2) - 120);
add(link.querySelector('.kodza-header-shop__word'), [{ transform: 'translateY(135%)' }, { transform: 'translateY(0%)' }], at, 900);
add(link.querySelector('.kodza-header-shop__index'), [{ opacity: 0, transform: 'translateY(6px)' }, { opacity: 1, transform: 'translateY(0px)' }], at + 240, 600);
});
infos.forEach((info, i) => {
const from = Math.max(at + 200 + i * 70, uncover(info.getBoundingClientRect().right));
add(info, [{ opacity: 0, transform: 'translateY(10px)' }, { opacity: 1, transform: 'translateY(0px)' }], from, 650);
});
};
// Close lands where Menu was: the column's top and right margins follow the button
const ready = () => {
panel.classList.toggle('is-flat', !m.page);
head.removeAttribute('style');
side.style.removeProperty('padding-right');
const t = toggle.getBoundingClientRect();
const s = panel.getBoundingClientRect();
const k = panel.offsetWidth ? s.width / panel.offsetWidth : 1;
const dy = (t.top - s.top) / k;
const dx = (s.right - t.right) / k;
if (dy >= 0 && dy <= 96 && dx >= 0 && dx <= panel.offsetWidth / 3) {
head.style.paddingTop = `${dy}px`;
side.style.paddingRight = `${dx}px`;
}
};
const resize = () => {
if (m.page && last) card.getAnimations()[0]?.effect.setKeyframes(shadow(last));
};
// Back over 900 px, the categories are back in the bar: the menu closes
const menuBar = root.querySelector('.kodza-header-shop__menu');
const watch = new ResizeObserver(() => {
if (menuBar && getComputedStyle(menuBar).display !== 'none' && toggle.getAttribute('aria-expanded') === 'true') closer?.click();
});
watch.observe(root);
signal.addEventListener('abort', () => watch.disconnect(), { once: true });
const reset = () => {
card.removeAttribute('style');
head.removeAttribute('style');
side.removeAttribute('style');
panel.classList.remove('is-flat');
};
return { page: 'under', rig, frames, build, ready, resize, reset };
});
}
// 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 Shop, for React. From https://kodza.dev/components/header-shop/
// 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-shop.css and header-shop.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-shop.css';
export type HeaderShopProps = Omit<ComponentPropsWithoutRef<'header'>, "children" | "vars"> & {
/** Settings, as CSS variables on the root */
vars?: {
/** default: #f2f2f0 */
"--kz-header-shop-bg"?: string | number;
/** default: #0a0a0a */
"--kz-header-shop-fg"?: string | number;
/** default: rgba(10, 10, 10, 0.62) */
"--kz-header-shop-muted"?: string | number;
/** the round buttons under the pointer, the Menu button — default: rgba(10, 10, 10, 0.06) */
"--kz-header-shop-soft"?: string | number;
/** default: rgba(10, 10, 10, 0.1) */
"--kz-header-shop-rule"?: string | number;
/** the search field — default: color-mix(in srgb, var(--kz-header-shop-fg) 6%, var(--kz-header-shop-bg)) */
"--kz-header-shop-field"?: string | number;
/** below the WordPress admin bar — default: var(--wp-admin--admin-bar--height, 0px) */
"--kz-header-shop-top"?: string | number;
/** default: 72px */
"--kz-header-shop-height"?: string | number;
/** the row, centred — default: 1200px */
"--kz-header-shop-width"?: string | number;
/** default: 24px */
"--kz-header-shop-pad"?: string | number;
/** default: 0.6s */
"--kz-header-shop-search-duration"?: string | number;
/** default: cubic-bezier(0.76, 0, 0.24, 1) */
"--kz-header-shop-search-ease"?: string | number;
/** default: #0a0a0a */
"--kz-header-shop-menu-bg"?: string | number;
/** default: #f2f2f0 */
"--kz-header-shop-menu-fg"?: string | number;
/** default: rgba(242, 242, 240, 0.62) */
"--kz-header-shop-menu-muted"?: string | number;
/** Close lands on Menu on its own; this is where it goes if Menu is somewhere else — default: calc(var(--wp-admin--admin-bar--height, 0px) + 20px) */
"--kz-header-shop-menu-top"?: string | number;
/** default: 24px */
"--kz-header-shop-menu-side"?: string | number;
/** default: min(clamp(340px, 40cqw, 560px), calc(100cqw - 56px)) */
"--kz-header-shop-menu-width"?: string | number;
/** default: clamp(36px, min(4.6cqw + 8px, calc((100cqh - 300px) / 6.6)), 72px) */
"--kz-header-shop-menu-size"?: string | number;
/** the page's size once it has stepped aside — default: 0.88 */
"--kz-header-shop-menu-depth"?: string | number;
/** default: 0 32px 80px -24px rgba(0, 0, 0, 0.45) */
"--kz-header-shop-menu-shadow"?: string | number;
/** how dark the page gets when the menu slides over it — default: 0.5 */
"--kz-header-shop-menu-shade"?: string | number;
/** default: 1s */
"--kz-header-shop-menu-duration"?: string | number;
/** default: cubic-bezier(0.76, 0, 0.24, 1) */
"--kz-header-shop-menu-ease"?: string | number;
/** the page colour while it steps aside; auto = the first background above it — default: auto */
"--kz-header-shop-page"?: string | number;
};
className?: string;
};
export function HeaderShop({ vars, className, style, ...rest }: HeaderShopProps) {
const ref = useRef<ComponentRef<'header'>>(null);
const classes = ["kodza-header-shop", 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-shop.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-shop__row">
<a className="kodza-header-shop__logo" href="/" aria-label="Galet, home">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M3 12.5C3 7 7.5 3 13 3s8 3.4 8 7.6C21 15.6 16.6 18 11.4 18 6.4 18 3 16.2 3 12.5z" />
</svg>
{' '}
<span>galet</span>
</a>
<nav className="kodza-header-shop__menu" aria-label="Shop">
<ul className="kodza-header-shop__links">
<li>
<a className="kodza-header-shop__item" href="#" aria-current="page">New in</a>
</li>
<li>
<a className="kodza-header-shop__item" href="#">Kitchen</a>
</li>
<li>
<a className="kodza-header-shop__item" href="#">Table</a>
</li>
<li>
<a className="kodza-header-shop__item" href="#">Bath</a>
</li>
<li>
<a className="kodza-header-shop__item" href="#">Linen</a>
</li>
<li>
<a className="kodza-header-shop__item" href="#">Sale</a>
</li>
</ul>
</nav>
<form className="kodza-header-shop__search" role="search" action="/">
<div className="kodza-header-shop__field">
<input className="kodza-header-shop__input" type="search" name="s" placeholder="Search Galet" aria-label="Search the shop" />
{' '}
<input type="hidden" name="post_type" defaultValue="product" />
</div>
<button className="kodza-header-shop__find" type="button" aria-label="Search" aria-expanded="false" data-close="Close search">
<svg className="kodza-header-shop__glass" viewBox="0 0 24 24" aria-hidden="true">
<circle cx="10.8" cy="10.8" r="6.2" />
<path d="m15.4 15.4 4.6 4.6" />
</svg>
{' '}
<span className="kodza-header-shop__x" aria-hidden="true" />
</button>
</form>
<div className="kodza-header-shop__end">
<a className="kodza-header-shop__account" href="/account/" aria-label="Account">
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="8.2" r="3.6" />
<path d="M4.8 20.2c.9-3.6 3.7-5.6 7.2-5.6s6.3 2 7.2 5.6" />
</svg>
</a>
{' '}
<a className="kodza-header-shop__cart" href="/cart/" aria-label="Bag, 2 items" data-count="2">
<svg className="kodza-header-shop__bag" viewBox="0 0 24 24" aria-hidden="true">
<path d="M5.2 8.2h13.6l-1 11a2 2 0 0 1-2 1.8H8.2a2 2 0 0 1-2-1.8z" />
<path d="M9 8.2V6.8a3 3 0 0 1 6 0v1.4" />
</svg>
{' '}
<span className="kodza-header-shop__count" aria-hidden="true">2</span>
</a>
{' '}
<button className="kodza-header-shop__toggle" type="button" aria-haspopup="dialog" aria-expanded="false"><span className="kodza-header-shop__lines" aria-hidden="true" />Menu</button>
</div>
</div>
<div className="kodza-header-shop__panel" role="dialog" aria-modal="true" aria-label="Menu" tabIndex={-1} hidden>
<span className="kodza-header-shop__ground" aria-hidden="true" />
{' '}
<span className="kodza-header-shop__card" aria-hidden="true" />
{' '}
<span className="kodza-header-shop__shade" aria-hidden="true" />
<div className="kodza-header-shop__side">
<div className="kodza-header-shop__bar">
<p className="kodza-header-shop__label">Your bag stays put.</p>
<button className="kodza-header-shop__close" type="button">
<span className="kodza-header-shop__cross" aria-hidden="true" />
<span className="kodza-header-shop__say">
<span>Close</span>
</span>
</button>
</div>
<nav className="kodza-header-shop__nav" aria-label="Shop, menu" />
<div className="kodza-header-shop__info">
<div className="kodza-header-shop__group">
<p className="kodza-header-shop__small">Your account</p>
<p className="kodza-header-shop__pair">
<a href="/account/">Sign in</a>
<a href="/account/orders/">Your orders</a>
</p>
</div>
<div className="kodza-header-shop__group">
<p className="kodza-header-shop__small">Help</p>
<p className="kodza-header-shop__pair">
<a href="mailto:hello@galet.example">hello@galet.example</a>
<span>Free returns, 30 days</span>
</p>
</div>
<p className="kodza-header-shop__small">Esc, or click the page.</p>
</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.