Burger Button
A menu button: the lines meet, then cross, and Menu rolls to Close at a fixed width. It follows aria-expanded and fires kodza:burger, so it drives the menu you already have.
View codeA fullscreen menu: a curtain comes down with its edge bending as it moves, the page backs off under it, and each link rises as the edge passes. Closing plays it backwards.
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 Fullscreen Menu to my page.
claude mcp add -t http kodza https://kodza.dev/api/mcp
<div class="kodza-fullscreen">
<button class="kodza-fullscreen__toggle" type="button" aria-haspopup="dialog" aria-expanded="false"><span class="kodza-fullscreen__lines" aria-hidden="true"></span>Menu</button>
<div class="kodza-fullscreen__panel" role="dialog" aria-modal="true" aria-label="Menu" tabindex="-1" hidden>
<span class="kodza-fullscreen__shade" aria-hidden="true"></span>
<span class="kodza-fullscreen__curtain" aria-hidden="true"><svg class="kodza-fullscreen__edge" viewBox="0 0 100 100" preserveAspectRatio="none" focusable="false"><path d="M0 0Q50 200 100 0Z"/></svg></span>
<div class="kodza-fullscreen__body">
<div class="kodza-fullscreen__bar">
<p class="kodza-fullscreen__label">Five links. That's the site.</p>
<button class="kodza-fullscreen__close" type="button"><span class="kodza-fullscreen__cross" aria-hidden="true"></span><span class="kodza-fullscreen__say"><span>Close</span></span></button>
</div>
<div class="kodza-fullscreen__stage">
<nav class="kodza-fullscreen__nav" aria-label="Main">
<a class="kodza-fullscreen__link" href="#"><span class="kodza-fullscreen__mask"><span class="kodza-fullscreen__word">Work</span></span><span class="kodza-fullscreen__index">01</span></a>
<a class="kodza-fullscreen__link" href="#"><span class="kodza-fullscreen__mask"><span class="kodza-fullscreen__word">Studio</span></span><span class="kodza-fullscreen__index">02</span></a>
<a class="kodza-fullscreen__link" href="#"><span class="kodza-fullscreen__mask"><span class="kodza-fullscreen__word">Process</span></span><span class="kodza-fullscreen__index">03</span></a>
<a class="kodza-fullscreen__link" href="#"><span class="kodza-fullscreen__mask"><span class="kodza-fullscreen__word">Notes</span></span><span class="kodza-fullscreen__index">04</span></a>
<a class="kodza-fullscreen__link" href="#"><span class="kodza-fullscreen__mask"><span class="kodza-fullscreen__word">Contact</span></span><span class="kodza-fullscreen__index">05</span></a>
</nav>
<div class="kodza-fullscreen__info">
<div class="kodza-fullscreen__group">
<p class="kodza-fullscreen__small">New project</p>
<p><a href="#">studio@example.com</a></p>
</div>
<div class="kodza-fullscreen__group">
<p class="kodza-fullscreen__small">Studio</p>
<p><span class="kodza-fullscreen__row">Quai de Southampton</span><span class="kodza-fullscreen__row">Le Havre</span></p>
</div>
<div class="kodza-fullscreen__group">
<p class="kodza-fullscreen__small">Elsewhere</p>
<p class="kodza-fullscreen__socials"><a href="#">GitHub</a><a href="#">X</a><a href="#">Bluesky</a></p>
</div>
<p class="kodza-fullscreen__small">Esc closes it. So does Close.</p>
</div>
</div>
</div>
</div>
</div>
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Fullscreen Menu
A curtain of ink comes down over the whole screen, its edge bending with the speed and
flattening as it lands. Under it the page backs off and dims; the big links rise from their
masks as the edge passes them, then the contact column. Closing plays it all backwards.
Mark the wrapper of your site with data-fullscreen-page, or name it on the menu with
data-page="…" (the wrapper of most WordPress themes is found on its own).
Everything is tuned with the --kz-fullscreen-* variables. */
.kodza-fullscreen {
--kz-fullscreen-bg: #0a0a0a; /* the curtain */
--kz-fullscreen-fg: #f2f2f0;
--kz-fullscreen-muted: rgba(242, 242, 240, 0.62);
--kz-fullscreen-ink: #0a0a0a; /* the Menu button, on the page */
--kz-fullscreen-on-ink: #ffffff;
--kz-fullscreen-page: auto; /* the page colour while it backs off; auto = the first background above it */
--kz-fullscreen-top: calc(var(--wp-admin--admin-bar--height, 0px) + 20px); /* match your header, so Close lands right where Menu was (below the WordPress admin bar) */
--kz-fullscreen-side: 24px;
--kz-fullscreen-size: clamp(40px, min(10cqw + 12px, calc((100cqh - 230px) / 5.3)), 132px);
--kz-fullscreen-curve: 1; /* how far the edge bends on the way; 0 = a straight edge */
--kz-fullscreen-shade: 0.5; /* how dark the page gets under it */
--kz-fullscreen-depth: 0.94; /* the page's size once covered */
--kz-fullscreen-duration: 1s;
--kz-fullscreen-ease: cubic-bezier(0.76, 0, 0.24, 1);
display: inline-block;
}
/* A straight edge, for a stricter site */
.kodza-fullscreen--straight {
--kz-fullscreen-curve: 0;
}
.kodza-fullscreen__toggle,
.kodza-fullscreen__close {
display: inline-flex;
align-items: center;
gap: 10px;
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-fullscreen__toggle {
background: var(--kz-fullscreen-ink);
color: var(--kz-fullscreen-on-ink);
}
.kodza-fullscreen__close {
background: var(--kz-fullscreen-fg);
color: var(--kz-fullscreen-bg);
}
.kodza-fullscreen__toggle:focus-visible {
outline: 2px solid var(--kz-fullscreen-ink);
outline-offset: 3px;
}
.kodza-fullscreen__close:focus-visible,
.kodza-fullscreen__info a:focus-visible {
outline: 2px solid var(--kz-fullscreen-fg);
outline-offset: 4px;
}
/* A link's focus is drawn on its word, so it rises with it instead of waiting there as an empty box */
.kodza-fullscreen__link:focus-visible {
outline: none;
}
.kodza-fullscreen__link:focus-visible .kodza-fullscreen__word {
text-decoration: underline;
text-decoration-thickness: 2px;
text-underline-offset: 0.12em;
}
/* Two lines on the button: they meet and cross as the curtain comes, and Close takes them
over crossed, in the same place */
.kodza-fullscreen__lines,
.kodza-fullscreen__cross {
position: relative;
flex: none;
width: 14px;
height: 8px;
}
.kodza-fullscreen__lines::before,
.kodza-fullscreen__lines::after,
.kodza-fullscreen__cross::before,
.kodza-fullscreen__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-fullscreen__lines::before,
.kodza-fullscreen__cross::before {
top: 0;
}
.kodza-fullscreen__lines::after,
.kodza-fullscreen__cross::after {
top: 6px; /* whole pixels: both lines sit on the pixel grid the same way */
}
/* The script turns them on the same clock as the curtain: when its edge goes over the button,
Close shows the lines exactly as they were, and closing plays it backwards */
.kodza-fullscreen__lines::before,
.kodza-fullscreen__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-fullscreen__lines::after {
clip-path: inset(0 0 0 0);
}
.kodza-fullscreen__toggle:hover .kodza-fullscreen__lines::after {
clip-path: inset(0 45% 0 0);
}
.kodza-fullscreen__toggle[aria-expanded="true"] .kodza-fullscreen__lines::after {
clip-path: inset(0 0 0 0);
}
.kodza-fullscreen__cross::before {
translate: 0 3px;
rotate: 45deg;
}
.kodza-fullscreen__cross::after {
translate: 0 -3px;
rotate: -45deg;
}
/* The word rolls in from below its mask */
.kodza-fullscreen__say {
display: grid;
margin: -3px 0;
padding: 3px 0;
overflow: hidden;
}
.kodza-fullscreen__say > span {
display: block;
}
/* The menu: over the whole screen, on top of everything while it is open */
.kodza-fullscreen__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-fullscreen-fg);
font: inherit;
font-size: 15px;
line-height: 1.4;
text-align: left;
container-type: size;
-webkit-font-smoothing: antialiased;
}
.kodza-fullscreen__panel[hidden] {
display: none;
}
.kodza-fullscreen__panel:focus {
outline: none;
}
.kodza-fullscreen__shade,
.kodza-fullscreen__curtain {
position: absolute;
inset: 0;
pointer-events: none;
}
.kodza-fullscreen__shade {
background: rgba(0, 0, 0, var(--kz-fullscreen-shade));
/* Around the page once it has backed off: darker than the page, so its edge reads */
box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.82);
}
.kodza-fullscreen__curtain {
background: var(--kz-fullscreen-bg);
}
/* The bend under the curtain: as deep as the curtain is fast, flat once it lands */
.kodza-fullscreen__edge {
position: absolute;
top: 100%;
left: 0;
display: block;
width: 100%;
height: calc(var(--kz-fullscreen-curve) * min(22cqh, 32cqw, 200px)); /* a phone gets a gentler bend */
margin-top: -1px;
overflow: visible;
fill: var(--kz-fullscreen-bg);
transform: scaleY(0);
transform-origin: top;
}
/* What the curtain carries: it scrolls on its own on a short screen */
.kodza-fullscreen__body {
position: absolute;
inset: 0;
display: grid;
grid-template-rows: auto 1fr;
overflow: hidden auto;
overscroll-behavior: contain;
}
.kodza-fullscreen__bar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: var(--kz-fullscreen-top) var(--kz-fullscreen-side) 0;
}
.kodza-fullscreen__label,
.kodza-fullscreen__index,
.kodza-fullscreen__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-fullscreen-muted);
}
.kodza-fullscreen__label {
margin: 0;
}
/* The links, big, at the bottom left; the contact column at the bottom right */
.kodza-fullscreen__stage {
display: grid;
grid-template-columns: minmax(0, 1fr) clamp(190px, 21cqw, 280px);
align-items: end;
gap: 32px clamp(32px, 6cqw, 96px);
padding: 32px var(--kz-fullscreen-side) clamp(20px, 4cqh, 36px);
}
.kodza-fullscreen__nav {
display: grid;
justify-items: start;
}
.kodza-fullscreen__link {
display: grid;
grid-template-columns: max-content auto;
align-items: start;
column-gap: calc(var(--kz-fullscreen-size) * 0.1);
color: inherit;
text-decoration: none;
border-radius: 4px;
transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
/* The mask has the size of its word, so its room for descenders (g, j, p, q, y) is measured
on the word */
.kodza-fullscreen__mask {
display: block;
margin: -0.06em 0 -0.22em;
padding: 0.06em 0 0.22em;
overflow: hidden;
font-size: var(--kz-fullscreen-size);
}
.kodza-fullscreen__word {
display: block;
font-size: var(--kz-fullscreen-size);
font-weight: 500;
line-height: 0.95;
letter-spacing: -0.045em;
white-space: nowrap;
}
.kodza-fullscreen__index {
padding-top: calc(var(--kz-fullscreen-size) * 0.1);
transition: color 0.25s;
}
/* Pointed at: the other links step back, its number lights up */
.kodza-fullscreen__nav:hover .kodza-fullscreen__link:not(:hover),
.kodza-fullscreen__nav:has(.kodza-fullscreen__link:focus-visible) .kodza-fullscreen__link:not(:focus-visible) {
opacity: 0.35;
}
.kodza-fullscreen__link:hover .kodza-fullscreen__index,
.kodza-fullscreen__link:focus-visible .kodza-fullscreen__index {
color: var(--kz-fullscreen-fg);
}
.kodza-fullscreen__info {
display: grid;
gap: 22px;
padding-bottom: calc(var(--kz-fullscreen-size) * 0.08);
}
.kodza-fullscreen__info p {
margin: 0;
text-wrap: pretty;
}
.kodza-fullscreen__group {
display: grid;
gap: 6px;
}
/* One line of an address */
.kodza-fullscreen__row {
display: block;
}
.kodza-fullscreen__info a {
color: var(--kz-fullscreen-fg);
text-decoration: none;
border-radius: 2px;
}
.kodza-fullscreen__info a:hover {
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
}
.kodza-fullscreen__socials {
display: flex;
flex-wrap: wrap;
gap: 4px 16px;
}
/* A phone: the links, then the contact column under them */
@container (max-width: 720px) {
.kodza-fullscreen__stage {
grid-template-columns: minmax(0, 1fr);
align-content: end;
gap: 40px;
}
.kodza-fullscreen__info {
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 20px 16px;
padding-bottom: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-fullscreen__toggle *,
.kodza-fullscreen__toggle *::before,
.kodza-fullscreen__toggle *::after,
.kodza-fullscreen__link,
.kodza-fullscreen__index {
transition-duration: 0.01ms !important;
transition-delay: 0s !important;
}
}
/* Dark site: a paper curtain
.kodza-fullscreen {
--kz-fullscreen-bg: #f2f2f0;
--kz-fullscreen-fg: #0a0a0a;
--kz-fullscreen-muted: rgba(10, 10, 10, 0.62);
--kz-fullscreen-ink: #f2f2f0;
--kz-fullscreen-on-ink: #0a0a0a;
}
*/
/* kodza-guard 40885bd00908 — 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-fullscreen__toggle):not(#_),
:where(.kodza-fullscreen__close):not(#_) {
outline: revert;
outline-offset: revert;
}
:where(.kodza-fullscreen__panel):not(#_),
:where(.kodza-fullscreen__link):not(#_) {
outline: revert;
}
:where(.kodza-fullscreen__group a:where(:not([class*="kodza-"]):not(.kodza-fullscreen__group [class*="kodza-"] *))):not(#_),
:where(.kodza-fullscreen__socials a:where(:not([class*="kodza-"]))):not(#_) {
outline: revert;
outline-offset: revert;
text-underline-offset: revert;
}
/* What the browser gives, on everything the component leaves to it */
.kodza-fullscreen:not(#_),
.kodza-fullscreen__lines:not(#_),
.kodza-fullscreen__shade:not(#_),
.kodza-fullscreen__curtain:not(#_),
.kodza-fullscreen__body:not(#_),
.kodza-fullscreen__bar:not(#_),
.kodza-fullscreen__cross:not(#_),
.kodza-fullscreen__say:not(#_),
.kodza-fullscreen__stage:not(#_),
.kodza-fullscreen__mask:not(#_),
.kodza-fullscreen__word:not(#_),
.kodza-fullscreen__index:not(#_),
.kodza-fullscreen__info:not(#_),
.kodza-fullscreen__group:not(#_),
.kodza-fullscreen__row:not(#_),
.kodza-fullscreen__say span:where(:not([class*="kodza-"])):not(#_) {
box-sizing: revert;
}
.kodza-fullscreen__toggle:not(#_),
.kodza-fullscreen__close:not(#_) {
text-decoration: revert;
transition: revert;
list-style: revert;
box-sizing: 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-fullscreen__panel:not(#_) {
box-shadow: revert;
outline-offset: revert;
}
.kodza-fullscreen__edge:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
transition: revert;
list-style: revert;
box-sizing: revert;
float: revert;
margin-right: revert;
margin-bottom: revert;
margin-left: 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-fullscreen__label:not(#_),
.kodza-fullscreen__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-fullscreen__nav: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-fullscreen__link:not(#_) {
border: revert;
margin: revert;
padding: 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-fullscreen__socials:not(#_),
.kodza-fullscreen__group p:where(:not([class*="kodza-"]):not(.kodza-fullscreen__group [class*="kodza-"] *)):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-fullscreen__group a:where(:not([class*="kodza-"]):not(.kodza-fullscreen__group [class*="kodza-"] *)):not(#_),
.kodza-fullscreen__socials 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-fullscreen__label:not(#_):where(:not([hidden])),
.kodza-fullscreen__small:not(#_):where(:not([hidden])),
.kodza-fullscreen__group p:where(:not([class*="kodza-"]):not(.kodza-fullscreen__group [class*="kodza-"] *)):not(#_):where(:not([hidden])),
.kodza-fullscreen__group a:where(:not([class*="kodza-"]):not(.kodza-fullscreen__group [class*="kodza-"] *)):not(#_):where(:not([hidden])),
.kodza-fullscreen__socials a:where(:not([class*="kodza-"])):not(#_):where(:not([hidden])) {
display: revert;
}
.kodza-fullscreen__label:not(#_):where([hidden]),
.kodza-fullscreen__small:not(#_):where([hidden]),
.kodza-fullscreen__group p:where(:not([class*="kodza-"]):not(.kodza-fullscreen__group [class*="kodza-"] *)):not(#_):where([hidden]),
.kodza-fullscreen__group a:where(:not([class*="kodza-"]):not(.kodza-fullscreen__group [class*="kodza-"] *)):not(#_):where([hidden]),
.kodza-fullscreen__socials a:where(:not([class*="kodza-"])):not(#_):where([hidden]) {
display: none;
}
.kodza-fullscreen__lines:not(#_)::before,
.kodza-fullscreen__lines:not(#_)::after,
.kodza-fullscreen__cross:not(#_)::before,
.kodza-fullscreen__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-fullscreen__toggle:not(#_),
.kodza-fullscreen__close:not(#_) {
display: inline-flex;
align-items: center;
gap: 10px;
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-fullscreen__toggle:not(#_) {
background: var(--kz-fullscreen-ink);
color: var(--kz-fullscreen-on-ink);
}
.kodza-fullscreen__close:not(#_) {
background: var(--kz-fullscreen-fg);
color: var(--kz-fullscreen-bg);
}
.kodza-fullscreen__toggle:focus-visible:not(#_) {
outline: 2px solid var(--kz-fullscreen-ink);
outline-offset: 3px;
}
.kodza-fullscreen__close:focus-visible:not(#_) {
outline: 2px solid var(--kz-fullscreen-fg);
outline-offset: 4px;
}
.kodza-fullscreen__info a:focus-visible:not(#_) {
outline: 2px solid var(--kz-fullscreen-fg);
outline-offset: 4px;
}
.kodza-fullscreen__link:focus-visible:not(#_) {
outline: none;
}
.kodza-fullscreen__panel:focus:not(#_) {
outline: none;
}
.kodza-fullscreen__edge:not(#_) {
position: absolute;
display: block;
margin-top: -1px;
}
.kodza-fullscreen__label:not(#_),
.kodza-fullscreen__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-fullscreen-muted);
}
.kodza-fullscreen__label:not(#_) {
margin: 0;
}
.kodza-fullscreen__nav:not(#_) {
display: grid;
}
.kodza-fullscreen__link:not(#_) {
display: grid;
color: inherit;
text-decoration: none;
border-radius: 4px;
transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.kodza-fullscreen__info p:not(#_) {
margin: 0;
}
.kodza-fullscreen__info a:not(#_) {
color: var(--kz-fullscreen-fg);
text-decoration: none;
border-radius: 2px;
}
.kodza-fullscreen__info a:hover:not(#_) {
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 3px;
}
.kodza-fullscreen__socials:not(#_) {
display: flex;
}
@media (prefers-reduced-motion: reduce) {
.kodza-fullscreen__link: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 — Fullscreen Menu
// A curtain of ink comes down over the screen, its edge bending with the speed and flattening as
// it lands. Under it the page marked with data-fullscreen-page backs off a little and dims; each
// link rises from its mask as the edge passes it, Close takes over the button where it was, and
// closing plays the same timeline backwards, from wherever it is. The page only carries a
// transform while the menu is open, and is put back exactly as it was.
(() => {
// The two lines that change from one menu of the family to the next
const NAME = 'fullscreen';
const VARS = ['bg', 'fg', 'muted', 'top', 'side', 'size', 'curve', 'shade'];
// ---------- 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) ----------
function mount(root, signal) {
menu(root, signal, (m) => {
const { panel, toggle, closer, links, one, all, css } = m;
const shade = one('.kodza-fullscreen__shade');
const curtain = one('.kodza-fullscreen__curtain');
const edge = one('.kodza-fullscreen__edge');
const cross = one('.kodza-fullscreen__cross');
const say = one('.kodza-fullscreen__say > span');
const label = one('.kodza-fullscreen__label');
const infos = all('.kodza-fullscreen__info > *');
const lines = toggle.querySelector('.kodza-fullscreen__lines');
const depth = () => parseFloat(css('depth')) || 0.94;
// The page backs off towards the bottom of the 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 hinge = (bottom - r.top) / k;
const clip = [(top - r.top) / k, (r.right - right) / k, page.offsetHeight - hinge, (left - r.left) / k];
page.style.transformOrigin = `${((left + right) / 2 - r.left) / k}px ${hinge}px`;
return { k, clip: clip.map((n) => `${Math.max(n, 0)}px`).join(' ') };
};
const frames = (g) => [
{ transform: 'scale(1)', clipPath: `inset(${g.clip} round 0px)` },
{ transform: `scale(${depth()})`, clipPath: `inset(${g.clip} round 18px)` },
];
// Around the page once it has backed off: its own colour on screen, much darker, so the
// edge reads and the site's body never shows through
const around = () => {
const { clientWidth: vw, clientHeight: vh } = document.documentElement;
let el = document.elementsFromPoint(vw / 2, vh / 2).find((node) => m.page.contains(node));
for (; el && el !== m.page.parentElement; el = el.parentElement) {
const color = getComputedStyle(el).backgroundColor;
if (!transparent(color)) return `color-mix(in srgb, ${color} 18%, #000)`;
}
return '#000';
};
// The lines cross on the button, and Close shows them crossed once the edge is over it
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('duration')) || 1) * 1000;
const ease = css('ease') || 'cubic-bezier(0.76, 0, 0.24, 1)';
const { top: y0, left: x0, width: w, height: h } = panel.getBoundingClientRect();
// The curtain comes down on the curve; its edge bends as deep as it is fast
const samples = curve(ease);
const speed = samples.map((_, i) => {
const [a, b] = [samples[Math.max(i - 1, 0)], samples[Math.min(i + 1, 100)]];
return b[0] > a[0] ? (b[1] - a[1]) / (b[0] - a[0]) : 0;
});
const most = Math.max(...speed) || 1;
const bend = speed.map((v, i) => (i === 0 || i === 100 ? 0 : v / most));
const deep = parseFloat(getComputedStyle(edge).height) || 0;
add(curtain, [{ transform: 'translateY(-100%)' }, { transform: 'translateY(0%)' }], 0, time, ease);
add(edge, samples.map(([t], i) => ({ offset: t, transform: `scaleY(${bend[i]})` })).filter((_, i) => i % 5 === 0), 0, time, 'linear');
// When the edge gets to `y` at `x` (screen pixels): the middle comes first, the sides last
const reach = (y, x) => {
const u = (2 * (x - x0)) / w - 1;
const shape = Math.max(1 - u * u, 0);
const i = samples.findIndex(([, p], j) => y0 + p * h + deep * bend[j] * shape >= y);
return (i < 0 ? 1 : samples[i][0]) * time;
};
const far = (r) => (Math.abs(r.left - (x0 + w / 2)) > Math.abs(r.right - (x0 + w / 2)) ? r.left : r.right);
// The page backs off and dims (without one, the shade alone). Only the dimming fades in:
// what shows around the page is solid from the first frame
const dim = getComputedStyle(shade).backgroundColor;
if (mode === 'page') {
add(m.page, frames(g), 0, time, ease);
const scale = depth();
// Where it lands, also written on the element: the open state holds without the animation
Object.assign(shade.style, { boxShadow: `0 0 0 100vmax ${around()}`, borderRadius: `${18 * g.k}px` });
add(shade, [
{ backgroundColor: 'rgba(0, 0, 0, 0)', transform: 'scale(1)', borderRadius: '0px', transformOrigin: '50% 100%' },
{ backgroundColor: dim, transform: `scale(${scale})`, borderRadius: `${18 * g.k}px`, transformOrigin: '50% 100%' },
], 0, time, ease);
} else {
add(shade, [{ backgroundColor: 'rgba(0, 0, 0, 0)' }, { backgroundColor: dim }], 0, time, ease);
}
// The button's lines cross, and Close is uncovered by the edge, its lines already crossed
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) {
const r = closer.getBoundingClientRect();
const x = r.left + r.width / 2;
const from = reach(r.top - 8, x);
add(closer, [
{ clipPath: 'inset(-8px -8px calc(100% + 8px) -8px round 28px)' },
{ clipPath: 'inset(-8px -8px -8px -8px round 28px)' },
], from, Math.max(reach(r.bottom + 8, x) - from, 1), 'linear');
add(say, [{ transform: 'translateY(110%)' }, { transform: 'translateY(0%)' }], from + 120, 600);
}
if (label) {
const r = label.getBoundingClientRect();
add(label, [{ opacity: 0, transform: 'translateY(6px)' }, { opacity: 1, transform: 'translateY(0px)' }], reach(r.bottom, far(r)) + 100, 600);
}
// Each link rises from its mask once the edge has gone past all of it
let at = 0;
links.forEach((link) => {
const mask = link.querySelector('.kodza-fullscreen__mask');
const r = (mask || link).getBoundingClientRect();
at = Math.max(at + 70, reach(r.bottom, far(r)));
add(link.querySelector('.kodza-fullscreen__word'), [{ transform: 'translateY(135%)' }, { transform: 'translateY(0%)' }], at, 900);
add(link.querySelector('.kodza-fullscreen__index'), [{ opacity: 0, transform: 'translateY(6px)' }, { opacity: 1, transform: 'translateY(0px)' }], at + 240, 600);
});
infos.forEach((info, i) => {
const r = info.getBoundingClientRect();
add(info, [{ opacity: 0, transform: 'translateY(10px)' }, { opacity: 1, transform: 'translateY(0px)' }], Math.max(at + 200 + i * 70, reach(r.bottom, far(r))), 650);
});
};
return { page: 'over', rig, frames, build, reset: () => shade.removeAttribute('style') };
});
}
// 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 — Fullscreen Menu, for React. From https://kodza.dev/components/fullscreen-menu/
// 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: fullscreen-menu.css and fullscreen-menu.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 './fullscreen-menu.css';
type Variant = "straight";
export type FullscreenMenuProps = Omit<ComponentPropsWithoutRef<'div'>, "children" | "variant" | "vars"> & {
/** Modifier class(es): .kodza-fullscreen--straight */
variant?: Variant | Variant[];
/** Settings, as CSS variables on the root */
vars?: {
/** the curtain — default: #0a0a0a */
"--kz-fullscreen-bg"?: string | number;
/** default: #f2f2f0 */
"--kz-fullscreen-fg"?: string | number;
/** default: rgba(242, 242, 240, 0.62) */
"--kz-fullscreen-muted"?: string | number;
/** the Menu button, on the page — default: #0a0a0a */
"--kz-fullscreen-ink"?: string | number;
/** default: #ffffff */
"--kz-fullscreen-on-ink"?: string | number;
/** the page colour while it backs off; auto = the first background above it — default: auto */
"--kz-fullscreen-page"?: string | number;
/** match your header, so Close lands right where Menu was (below the WordPress admin bar) — default: calc(var(--wp-admin--admin-bar--height, 0px) + 20px) */
"--kz-fullscreen-top"?: string | number;
/** default: 24px */
"--kz-fullscreen-side"?: string | number;
/** default: clamp(40px, min(10cqw + 12px, calc((100cqh - 230px) / 5.3)), 132px) */
"--kz-fullscreen-size"?: string | number;
/** how far the edge bends on the way; 0 = a straight edge — default: 1 */
"--kz-fullscreen-curve"?: string | number;
/** how dark the page gets under it — default: 0.5 */
"--kz-fullscreen-shade"?: string | number;
/** the page's size once covered — default: 0.94 */
"--kz-fullscreen-depth"?: string | number;
/** default: 1s */
"--kz-fullscreen-duration"?: string | number;
/** default: cubic-bezier(0.76, 0, 0.24, 1) */
"--kz-fullscreen-ease"?: string | number;
};
className?: string;
};
export function FullscreenMenu({ variant, vars, className, style, ...rest }: FullscreenMenuProps) {
const ref = useRef<ComponentRef<'div'>>(null);
const classes = ["kodza-fullscreen", ...([] as string[]).concat(variant ?? []).map((v) => `kodza-fullscreen--${v}`), 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('./fullscreen-menu.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 (
<div key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
<button className="kodza-fullscreen__toggle" type="button" aria-haspopup="dialog" aria-expanded="false"><span className="kodza-fullscreen__lines" aria-hidden="true" />Menu</button>
<div className="kodza-fullscreen__panel" role="dialog" aria-modal="true" aria-label="Menu" tabIndex={-1} hidden>
<span className="kodza-fullscreen__shade" aria-hidden="true" />
{' '}
<span className="kodza-fullscreen__curtain" aria-hidden="true">
<svg className="kodza-fullscreen__edge" viewBox="0 0 100 100" preserveAspectRatio="none" focusable="false">
<path d="M0 0Q50 200 100 0Z" />
</svg>
</span>
<div className="kodza-fullscreen__body">
<div className="kodza-fullscreen__bar">
<p className="kodza-fullscreen__label">Five links. That's the site.</p>
<button className="kodza-fullscreen__close" type="button">
<span className="kodza-fullscreen__cross" aria-hidden="true" />
<span className="kodza-fullscreen__say">
<span>Close</span>
</span>
</button>
</div>
<div className="kodza-fullscreen__stage">
<nav className="kodza-fullscreen__nav" aria-label="Main">
<a className="kodza-fullscreen__link" href="#">
<span className="kodza-fullscreen__mask">
<span className="kodza-fullscreen__word">Work</span>
</span>
<span className="kodza-fullscreen__index">01</span>
</a>
{' '}
<a className="kodza-fullscreen__link" href="#">
<span className="kodza-fullscreen__mask">
<span className="kodza-fullscreen__word">Studio</span>
</span>
<span className="kodza-fullscreen__index">02</span>
</a>
{' '}
<a className="kodza-fullscreen__link" href="#">
<span className="kodza-fullscreen__mask">
<span className="kodza-fullscreen__word">Process</span>
</span>
<span className="kodza-fullscreen__index">03</span>
</a>
{' '}
<a className="kodza-fullscreen__link" href="#">
<span className="kodza-fullscreen__mask">
<span className="kodza-fullscreen__word">Notes</span>
</span>
<span className="kodza-fullscreen__index">04</span>
</a>
{' '}
<a className="kodza-fullscreen__link" href="#">
<span className="kodza-fullscreen__mask">
<span className="kodza-fullscreen__word">Contact</span>
</span>
<span className="kodza-fullscreen__index">05</span>
</a>
</nav>
<div className="kodza-fullscreen__info">
<div className="kodza-fullscreen__group">
<p className="kodza-fullscreen__small">New project</p>
<p>
<a href="#">studio@example.com</a>
</p>
</div>
<div className="kodza-fullscreen__group">
<p className="kodza-fullscreen__small">Studio</p>
<p>
<span className="kodza-fullscreen__row">Quai de Southampton</span>
<span className="kodza-fullscreen__row">Le Havre</span>
</p>
</div>
<div className="kodza-fullscreen__group">
<p className="kodza-fullscreen__small">Elsewhere</p>
<p className="kodza-fullscreen__socials">
<a href="#">GitHub</a>
<a href="#">X</a>
<a href="#">Bluesky</a>
</p>
</div>
<p className="kodza-fullscreen__small">Esc closes it. So does Close.</p>
</div>
</div>
</div>
</div>
</div>
);
}
Checked
Robots poked at it before you did. Every component goes through the same checks, and again each time it changes.