Logo Collapse
The logo fills the screen while the page loads, then flies into the header as the screen rolls up. Its line tracks the real load. Any click or key skips it; data-once plays it once per visit.
View codeBetween two real pages, an ink panel rises with the name of the next page, then lifts off onto it. Back plays it in reverse. Curved edge or from the top. Chrome, Edge, Safari.
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 Curtain Transition to my page.
claude mcp add -t http kodza https://kodza.dev/api/mcp
<section class="kodza-curtain-transition" data-kodza-curtain-transition data-page-name="Null & Void">
<p class="kodza-curtain-transition__label" data-enter="label">Case study · 04 / 12</p>
<div class="kodza-curtain-transition__split">
<h1 class="kodza-curtain-transition__title" data-enter="title">The deploy that went out on a Friday</h1>
<div class="kodza-curtain-transition__intro">
<p class="kodza-curtain-transition__lead" data-enter>A full redesign, shipped four minutes before the weekend. No rollback, no war room, nobody paged. Here is how a team of three made it boring on purpose.</p>
<dl class="kodza-curtain-transition__facts">
<div data-enter><dt>Client</dt><dd>Null & Void</dd></div>
<div data-enter><dt>Year</dt><dd>2026</dd></div>
<div data-enter><dt>Shipped</dt><dd>Fri, 17:56</dd></div>
</dl>
</div>
</div>
<figure class="kodza-curtain-transition__media">
<div class="kodza-curtain-transition__frame" data-enter="image">
<img class="kodza-curtain-transition__image" src="https://kodza.dev/media/kz-steps-2400.webp" width="2400" height="1600" alt="Concrete steps climbing through bare grey walls">
</div>
<figcaption data-enter><span>fig. 1 — the release plan, in its final form</span><span>git push, then leave</span></figcaption>
</figure>
</section>
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Curtain Transition
A page transition between two real pages (cross-document View Transitions). On a click a
panel of ink rises over the page you leave, the name of the next page comes up from its mask,
then the panel lifts off the top onto the new page, which plays its arrival: the label, the
title rising line by line, the image settling from a zoom, the rest in a cascade (mark them with
data-enter="label", "title", "image", or just data-enter). The name is the page's
data-page-name, or the first part of the page title. Going back plays it in reverse: the curtain
comes down and leaves by the bottom. Modifiers: --curved (its leading edge bows as it moves),
--from-top. Without the API (Firefox) or with reduced motion, navigation stays plain. Tuned
with the --kz-curtain-transition-* variables, on .kodza-curtain-transition (or on html, for the
pages without the section). */
.kodza-curtain-transition {
--kz-curtain-transition-duration: 1.2s; /* the whole curtain: up, a beat on the name, off */
--kz-curtain-transition-ease: cubic-bezier(0.76, 0, 0.24, 1);
--kz-curtain-transition-ink: #0a0a0a; /* the panel */
--kz-curtain-transition-ink-fg: #f2f2f0; /* the name on it */
--kz-curtain-transition-way: 1; /* 1: up from the bottom, -1: down from the top */
--kz-curtain-transition-curve: 0px; /* how far its leading edge bows */
--kz-curtain-transition-enter-delay: 0.8s; /* the arrival starts as the curtain lifts off it */
--kz-curtain-transition-enter-ease: cubic-bezier(0.2, 0.8, 0.1, 1);
--kz-curtain-transition-bg: #f2f2f0;
--kz-curtain-transition-fg: #0a0a0a;
--kz-curtain-transition-muted: rgba(10, 10, 10, 0.62);
--kz-curtain-transition-line: rgba(10, 10, 10, 0.12);
--kz-curtain-transition-image-radius: calc(16px * var(--kz-radius-scale, 1));
--kz-curtain-transition-side: 24px;
box-sizing: border-box;
padding: 64px var(--kz-curtain-transition-side) 72px;
background: var(--kz-curtain-transition-bg);
color: var(--kz-curtain-transition-fg);
font-size: 15px;
line-height: 1.5;
text-align: left;
}
.kodza-curtain-transition--curved {
--kz-curtain-transition-curve: calc(140px * var(--kz-radius-scale, 1));
}
.kodza-curtain-transition--from-top {
--kz-curtain-transition-way: -1;
}
/* ---------- The curtain: drawn by the browser between two documents ---------- */
@view-transition {
navigation: auto;
}
/* The script marks the page (kodza-curtain-transition-on); without it, a page with the section still swaps */
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine))::view-transition {
background: var(--kz-curtain-transition-backdrop, var(--kz-curtain-transition-ink, #0a0a0a));
}
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine))::view-transition-group(root) {
animation: none;
}
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine))::view-transition-old(root),
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine))::view-transition-new(root),
html.kodza-curtain-transition-on::view-transition-new(kodza-curtain-transition-panel),
html.kodza-curtain-transition-on::view-transition-new(kodza-curtain-transition-name) {
mix-blend-mode: normal;
animation-duration: var(--kz-curtain-transition-duration, 1.2s);
animation-timing-function: var(--kz-curtain-transition-ease, cubic-bezier(0.76, 0, 0.24, 1));
animation-delay: calc(var(--kz-curtain-transition-at, 0) * var(--kz-curtain-transition-duration, 1.2s) * -1); /* an interrupted curtain goes on from where it was */
animation-fill-mode: both;
}
/* The page you leave is pushed a little by the panel, and goes once it is covered... */
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine))::view-transition-old(root) {
animation-name: kodza-curtain-transition-leave;
}
/* ...the next one is there when the panel lifts off it, and settles as it is uncovered */
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine))::view-transition-new(root) {
animation-name: kodza-curtain-transition-arrive;
}
/* The panel and the name, above everything (the header too: the curtain covers the screen) */
html.kodza-curtain-transition-on::view-transition-group(kodza-curtain-transition-panel) {
z-index: 50;
animation: none;
}
html.kodza-curtain-transition-on::view-transition-group(kodza-curtain-transition-name) {
z-index: 51;
overflow: clip; /* its mask: the name rises from behind its own edge */
animation: none;
}
html.kodza-curtain-transition-on::view-transition-new(kodza-curtain-transition-panel) {
animation-name: kodza-curtain-transition-panel;
}
html.kodza-curtain-transition-on::view-transition-new(kodza-curtain-transition-name) {
animation-name: kodza-curtain-transition-name;
}
/* Back: the same curtain played backwards, so it comes down and leaves by the bottom */
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine)).kodza-curtain-transition-back::view-transition-old(root) {
animation-name: kodza-curtain-transition-arrive;
animation-direction: reverse;
}
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine)).kodza-curtain-transition-back::view-transition-new(root) {
animation-name: kodza-curtain-transition-leave;
animation-direction: reverse;
}
html.kodza-curtain-transition-on.kodza-curtain-transition-back::view-transition-new(kodza-curtain-transition-panel),
html.kodza-curtain-transition-on.kodza-curtain-transition-back::view-transition-new(kodza-curtain-transition-name) {
animation-direction: reverse;
}
/* The header stays: the script names it on both pages, the new one is shown from the start */
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine))::view-transition-group(*.kodza-curtain-transition-stay) {
animation: none;
}
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine))::view-transition-old(*.kodza-curtain-transition-stay) {
animation: none;
opacity: 0;
}
/* It fills its group: Firefox keeps the proportions of its first capture, so a header that
widens while the page changes (a pill growing back to full width) would grow taller with it */
:is(html.kodza-curtain-transition-on, html:has(.kodza-curtain-transition):not(.kodza-page-engine))::view-transition-new(*.kodza-curtain-transition-stay) {
height: 100%;
mix-blend-mode: normal;
animation: none;
}
/* Off screen at both ends (0–4 %, 92–100 %): it is only drawn while the transition runs. Its
leading edge bows while it moves (--curved) and is flat when it covers the page; on the way
off, the bow passes to the edge that trails */
@keyframes kodza-curtain-transition-panel {
0%,
4% {
transform: translateY(calc(100% * var(--kz-curtain-transition-way, 1)));
clip-path: inset(0 round 50% 50% 50% 50% / calc(var(--kz-curtain-transition-curve, 0px) * (1 + var(--kz-curtain-transition-way, 1)) / 2) calc(var(--kz-curtain-transition-curve, 0px) * (1 + var(--kz-curtain-transition-way, 1)) / 2) calc(var(--kz-curtain-transition-curve, 0px) * (1 - var(--kz-curtain-transition-way, 1)) / 2) calc(var(--kz-curtain-transition-curve, 0px) * (1 - var(--kz-curtain-transition-way, 1)) / 2));
}
40%,
56% {
transform: none;
clip-path: inset(0 round 50% 50% 50% 50% / 0px 0px 0px 0px);
}
92%,
100% {
transform: translateY(calc(-100% * var(--kz-curtain-transition-way, 1)));
clip-path: inset(0 round 50% 50% 50% 50% / calc(var(--kz-curtain-transition-curve, 0px) * (1 - var(--kz-curtain-transition-way, 1)) / 2) calc(var(--kz-curtain-transition-curve, 0px) * (1 - var(--kz-curtain-transition-way, 1)) / 2) calc(var(--kz-curtain-transition-curve, 0px) * (1 + var(--kz-curtain-transition-way, 1)) / 2) calc(var(--kz-curtain-transition-curve, 0px) * (1 + var(--kz-curtain-transition-way, 1)) / 2));
}
}
/* The name: up from its mask once the panel is nearly there, a beat, then away the same way */
@keyframes kodza-curtain-transition-name {
0%,
30% {
transform: translateY(calc(110% * var(--kz-curtain-transition-way, 1)));
animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}
48%,
60% {
transform: none;
animation-timing-function: cubic-bezier(0.64, 0, 0.78, 0);
}
72%,
100% {
transform: translateY(calc(-110% * var(--kz-curtain-transition-way, 1)));
}
}
/* The two pages trade places under the panel, at 48 %, when it covers the whole screen */
@keyframes kodza-curtain-transition-leave {
0% {
transform: none;
}
40% {
transform: translateY(calc(-6% * var(--kz-curtain-transition-way, 1)));
opacity: 1;
}
48%,
100% {
transform: translateY(calc(-6% * var(--kz-curtain-transition-way, 1)));
opacity: 0;
animation-timing-function: steps(1, start);
}
}
@keyframes kodza-curtain-transition-arrive {
0%,
48% {
transform: translateY(calc(8% * var(--kz-curtain-transition-way, 1)));
opacity: 0;
animation-timing-function: steps(1, end);
}
48.01%,
56% {
transform: translateY(calc(8% * var(--kz-curtain-transition-way, 1)));
opacity: 1;
}
100% {
transform: none;
opacity: 1;
}
}
/* The panel itself: put on the page by the script, drawn only while a transition runs */
.kodza-curtain-transition__curtain {
display: none;
position: fixed;
inset: 0;
z-index: 2147483000;
align-items: center;
justify-content: center;
background: var(--kz-curtain-transition-ink, #0a0a0a);
pointer-events: none;
view-transition-name: kodza-curtain-transition-panel;
}
html.kodza-curtain-transition-cover:active-view-transition .kodza-curtain-transition__curtain {
display: flex;
}
.kodza-curtain-transition__name {
display: block;
max-width: 90vw;
margin: 0;
padding: 0.08em 0.06em 0.16em; /* room for the descenders, inside its mask */
color: var(--kz-curtain-transition-ink-fg, #f2f2f0);
font-family: var(--kz-font-display, inherit);
font-size: calc(clamp(40px, 7vw, 112px) * var(--kz-font-display-scale, 1));
font-weight: var(--kz-font-display-weight, 600);
line-height: 1;
letter-spacing: var(--kz-font-display-tracking, -0.05em);
text-transform: var(--kz-font-display-case, none);
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
view-transition-name: kodza-curtain-transition-name;
}
/* ---------- The arrival: hidden from the first paint, until the script plays it ---------- */
@media (prefers-reduced-motion: no-preference) {
html.kodza-curtain-transition-enter .kodza-curtain-transition [data-enter] {
opacity: 0;
animation: kodza-curtain-transition-failsafe 0.5s 2.5s both; /* no script: the page shows anyway */
}
}
@keyframes kodza-curtain-transition-failsafe {
to {
opacity: 1;
}
}
/* The title, cut into words by the script: each one rises from behind its own edge */
.kodza-curtain-transition__mask {
display: inline-block;
vertical-align: top;
margin-bottom: -0.16em;
padding-bottom: 0.16em; /* room for the descenders, inside the mask */
}
.kodza-curtain-transition.is-entering .kodza-curtain-transition__mask {
clip-path: inset(-0.3em -0.2em 0 -0.2em); /* open above, for the accents */
}
.kodza-curtain-transition__word {
display: inline-block;
}
/* ---------- The section: a case study opening ---------- */
.kodza-curtain-transition__label,
.kodza-curtain-transition__facts dt,
.kodza-curtain-transition__media figcaption {
margin: 0;
font-family: var(--kz-font-mono, "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace);
font-size: 12px;
font-weight: 400;
line-height: 1.4;
letter-spacing: 0;
color: var(--kz-curtain-transition-muted);
}
.kodza-curtain-transition__label {
margin-bottom: 24px;
}
.kodza-curtain-transition__split {
display: grid;
grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
align-items: end;
gap: 32px 64px;
}
.kodza-curtain-transition__title {
margin: 0;
color: inherit;
font-family: var(--kz-font-display, inherit);
font-size: calc(clamp(44px, 6.6vw, 96px) * var(--kz-font-display-scale, 1));
font-weight: var(--kz-font-display-weight, 600);
line-height: 0.95;
letter-spacing: var(--kz-font-display-tracking, -0.055em);
text-transform: var(--kz-font-display-case, inherit);
text-wrap: balance;
}
.kodza-curtain-transition__intro {
display: grid;
gap: 32px;
padding-bottom: 6px;
}
.kodza-curtain-transition__lead {
max-width: 30em;
margin: 0;
color: var(--kz-curtain-transition-muted);
font-size: clamp(16px, 1.4vw, 18px);
line-height: 1.5;
text-wrap: pretty;
}
.kodza-curtain-transition__facts {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 16px;
margin: 0;
padding: 0;
}
.kodza-curtain-transition__facts > div {
padding-top: 12px;
border-top: 1px solid var(--kz-curtain-transition-line);
}
.kodza-curtain-transition__facts dd {
margin: 6px 0 0;
font-size: 15px;
font-weight: 500;
letter-spacing: -0.01em;
}
.kodza-curtain-transition__media {
margin: 56px 0 0;
}
.kodza-curtain-transition__frame {
overflow: hidden;
aspect-ratio: 21 / 9;
border-radius: var(--kz-curtain-transition-image-radius);
background: var(--kz-curtain-transition-line);
}
.kodza-curtain-transition__image {
display: block;
width: 100%;
height: 100%;
max-width: none;
margin: 0;
object-fit: cover;
}
.kodza-curtain-transition__media figcaption {
display: flex;
justify-content: space-between;
gap: 16px;
margin-top: 12px;
}
@media (max-width: 860px) {
.kodza-curtain-transition {
padding-top: 48px;
}
.kodza-curtain-transition__split {
grid-template-columns: minmax(0, 1fr);
}
.kodza-curtain-transition__media {
margin-top: 40px;
}
.kodza-curtain-transition__frame {
aspect-ratio: 4 / 3;
}
}
@media (max-width: 480px) {
.kodza-curtain-transition__media figcaption span + span {
display: none;
}
}
/* Reduced motion: plain navigation, the page straight away */
@media (prefers-reduced-motion: reduce) {
@view-transition {
navigation: none;
}
}
/* kodza-guard ef349d1265ff — 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, on everything the component leaves to it */
.kodza-curtain-transition__label:not(#_),
.kodza-curtain-transition__facts dt:where(:is(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))):not(.kodza-curtain-transition__facts :not(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))) *)):not(#_),
.kodza-curtain-transition__media figcaption:where(:is(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))):not(.kodza-curtain-transition__media :not(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))) *)):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-curtain-transition__split:not(#_),
.kodza-curtain-transition__mask:not(#_),
.kodza-curtain-transition__word:not(#_),
.kodza-curtain-transition__intro:not(#_),
.kodza-curtain-transition__frame:not(#_),
.kodza-curtain-transition__facts div:where(:is(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))):not(.kodza-curtain-transition__facts :not(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))) *)):not(#_),
.kodza-curtain-transition__media span:where(:is(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))):not(.kodza-curtain-transition__media :not(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))) *)):not(#_) {
box-sizing: revert;
}
.kodza-curtain-transition__title: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-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-curtain-transition__lead: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-height: revert;
font-family: revert;
font-weight: revert;
font-style: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-curtain-transition__facts: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-curtain-transition__media: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-curtain-transition__image: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-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-curtain-transition__facts dd:where(:is(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))):not(.kodza-curtain-transition__facts :not(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))) *)):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-style: revert;
line-height: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-curtain-transition__label:not(#_):where(:not([hidden])),
.kodza-curtain-transition__title:not(#_):where(:not([hidden])),
.kodza-curtain-transition__lead:not(#_):where(:not([hidden])),
.kodza-curtain-transition__media:not(#_):where(:not([hidden])),
.kodza-curtain-transition__facts dt:where(:is(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))):not(.kodza-curtain-transition__facts :not(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))) *)):not(#_):where(:not([hidden])),
.kodza-curtain-transition__facts dd:where(:is(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))):not(.kodza-curtain-transition__facts :not(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))) *)):not(#_):where(:not([hidden])) {
display: revert;
}
.kodza-curtain-transition__label:not(#_):where([hidden]),
.kodza-curtain-transition__title:not(#_):where([hidden]),
.kodza-curtain-transition__lead:not(#_):where([hidden]),
.kodza-curtain-transition__media:not(#_):where([hidden]),
.kodza-curtain-transition__facts dt:where(:is(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))):not(.kodza-curtain-transition__facts :not(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))) *)):not(#_):where([hidden]),
.kodza-curtain-transition__facts dd:where(:is(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))):not(.kodza-curtain-transition__facts :not(:not([class]), [class=""], [class^="is-"]:not([class*="kodza-"]):not([class*=" "]:not([class*=" is-"]))) *)):not(#_):where([hidden]) {
display: none;
}
/* 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-curtain-transition__label:not(#_),
.kodza-curtain-transition__facts dt:not(#_),
.kodza-curtain-transition__media figcaption:not(#_) {
margin: 0;
font-family: var(--kz-font-mono, "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace);
font-size: 12px;
font-weight: 400;
line-height: 1.4;
letter-spacing: 0;
color: var(--kz-curtain-transition-muted);
}
.kodza-curtain-transition__label:not(#_) {
margin-bottom: 24px;
}
.kodza-curtain-transition__title:not(#_) {
margin: 0;
color: inherit;
font-family: var(--kz-font-display, inherit);
font-size: calc(clamp(44px, 6.6vw, 96px) * var(--kz-font-display-scale, 1));
font-weight: var(--kz-font-display-weight, 600);
line-height: 0.95;
letter-spacing: var(--kz-font-display-tracking, -0.055em);
text-transform: var(--kz-font-display-case, inherit);
}
.kodza-curtain-transition__lead:not(#_) {
max-width: 30em;
margin: 0;
color: var(--kz-curtain-transition-muted);
font-size: clamp(16px, 1.4vw, 18px);
line-height: 1.5;
}
.kodza-curtain-transition__facts:not(#_) {
display: grid;
margin: 0;
padding: 0;
}
.kodza-curtain-transition__facts dd:not(#_) {
margin: 6px 0 0;
font-size: 15px;
font-weight: 500;
letter-spacing: -0.01em;
}
.kodza-curtain-transition__media:not(#_) {
margin: 56px 0 0;
}
.kodza-curtain-transition__image:not(#_) {
display: block;
max-width: none;
margin: 0;
}
.kodza-curtain-transition__media figcaption:not(#_) {
display: flex;
margin-top: 12px;
}
@media (max-width: 860px) {
.kodza-curtain-transition__media:not(#_) {
margin-top: 40px;
}
}
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Kodza — Curtain Transition
// The curtain itself is CSS: between two real pages the browser draws it (cross-document View
// Transitions). The script puts the panel and the name of the next page on the page for the
// transition, gives it its direction (back plays it in reverse, from wherever an interrupted
// curtain was), keeps the header in place, plays the arrival of the new page, and runs the same
// curtain inside one page for sites that swap their content (kodza:page-transition).
(() => {
const SELECTOR = '[data-kodza-curtain-transition]';
// The two lines that change from one page transition of the family to the next
const NAME = 'curtain-transition';
const VARS = ['duration', 'ease', 'ink', 'ink-fg', 'way', 'curve', 'backdrop'];
// ---------- Page engine (begin) ----------
// The same block in every page transition of the family (Page Lift, Curtain, Stairs...),
// copied as is. The page you leave writes a short record (direction, where an interrupted
// transition was, which headers stay); the page that lands reads it before its first paint.
// Pages: data-page-back on a link plays the return (an "All work" link), data-page-stay marks
// what stays in place (the site header by default), data-enter the parts of the arrival.
const html = document.documentElement;
const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
const ON = `kodza-${NAME}-on`;
const BACK = `kodza-${NAME}-back`;
const ENTER = `kodza-${NAME}-enter`;
const STAY = `kodza-${NAME}-stay`;
const KEY = 'kodza-page-engine';
const WAIT = 5000; // ms a turned-round transition can wait for its content swap
const navType = performance.getEntriesByType('navigation')[0]?.type;
const signals = new WeakMap(); // root -> its signal, for its arrival
const entries = new WeakMap(); // root -> its arrival, prepared or playing
const pending = new Set(); // arrivals waiting for their start
let go = null; // when the arrival starts, once the page knows
let current = null; // the transition running
let heading = null; // where it goes: true back, false forward
let local = null; // the one this page runs itself, around a content swap
let turn = null; // the swap waiting for the page on screen to be out of sight
let hold = null; // its animations, kept on until the swap is done
let stayed = [];
let pressed = null;
let revealed = false;
// One engine per page: an earlier one (another transition of the family) steps aside
document.dispatchEvent(new CustomEvent('kodza:page-engine'));
const page = new AbortController();
document.addEventListener('kodza:page-engine', () => {
page.abort();
html.classList.remove(ON, BACK, ENTER);
}, { once: true, signal: page.signal });
html.classList.add(ON, 'kodza-page-engine');
const here = (href) => {
const url = new URL(href, location.href);
url.hash = '';
return url.href;
};
const ms = (value, fallback) => {
const n = parseFloat(value);
return Number.isNaN(n) ? fallback : /ms\s*$/.test(value) ? n : n * 1000;
};
const now = () => document.timeline.currentTime;
const shown = () => [...document.querySelectorAll(SELECTOR)].filter((root) => root.getClientRects().length);
// Where the transition running is, as a share of the way forward (null: none is)
function progress() {
const run = document.getAnimations().find((a) => a.animationName?.startsWith(`kodza-${NAME}`) && a.effect?.pseudoElement?.startsWith('::view-transition'));
if (!run) return null;
const { delay, duration } = run.effect.getTiming();
const t = Math.min(Math.max((run.currentTime ?? 0) - delay, 0), duration) / duration;
return html.classList.contains(BACK) ? 1 - t : t;
}
// Settings of the section that decides (the one that arrives, or the one you leave going back)
function values(root) {
if (!root) return null;
const style = getComputedStyle(root);
const out = {};
VARS.forEach((v) => {
const value = style.getPropertyValue(`--kz-${NAME}-${v}`).trim();
if (value) out[v] = value;
});
return out;
}
const apply = (out) => Object.entries(out || {}).forEach(([v, value]) => html.style.setProperty(`--kz-${NAME}-${v}`, value));
// What stays in place: [data-page-stay], or the site header (and the WordPress admin bar)
// when it sits at the top of the screen. Going back through history, a header that scrolls
// with its page may not be at the top of the next one: only a fixed or sticky one stays.
function candidates() {
const marked = document.querySelectorAll('[data-page-stay]');
if (marked.length) return [...marked];
return [...document.querySelectorAll('header, #wpadminbar')].filter((el) => !el.parentElement?.closest(`header, main, article, section, aside, footer, ${SELECTOR}`));
}
function stays(el, traverse) {
const box = el.getBoundingClientRect();
if (!box.height || box.top < -1 || box.top > 64 || box.height > innerHeight * 0.4) return false;
if (!traverse) return true;
for (let node = el; node && node !== html; node = node.parentElement) {
if (/fixed|sticky/.test(getComputedStyle(node).position)) return true;
}
return false;
}
function release() {
stayed.forEach((el) => {
el.style.removeProperty('view-transition-name');
el.style.removeProperty('view-transition-class');
});
stayed = [];
}
function name(only, traverse) {
release();
const named = [];
candidates().forEach((el, i) => {
if ((only && !only.includes(i)) || !stays(el, traverse)) return;
el.style.setProperty('view-transition-name', `${STAY}-${i}`);
el.style.setProperty('view-transition-class', STAY);
stayed.push(el);
named.push(i);
});
return named;
}
function unturn() {
hold?.forEach((a) => a.playState !== 'idle' && a.finish());
hold = null;
turn = null;
}
function clean() {
unturn();
heading = null;
html.classList.remove(BACK);
html.style.removeProperty(`--kz-${NAME}-at`);
VARS.forEach((v) => html.style.removeProperty(`--kz-${NAME}-${v}`));
release();
}
// The record the page you leave writes, read once by the next one
function read(restored) {
let record = null;
try {
record = JSON.parse(sessionStorage.getItem(KEY));
sessionStorage.removeItem(KEY);
} catch (error) {
record = null;
}
if (record && (Date.now() - record.time > 4000 || (record.to && record.to !== here(location.href)))) record = null;
const activation = window.navigation?.activation;
const from = activation?.from;
const back = record ? record.back
: activation?.navigationType === 'traverse' ? !from || from.index < 0 || activation.entry.index < from.index
: restored || navType === 'back_forward';
// An interrupted transition turned around goes on from where it was
const at = !record || record.p == null || record.was === back ? 0 : back ? 1 - record.p : record.p;
return { back, at, stay: record?.stay || [], vars: record?.vars };
}
// The arrival: label, title line by line from its mask, image settling from a zoom, the
// rest in a cascade. Prepared hidden (paused on its first frame), started once the page knows.
// The title is cut into words for it, and put back as it was once they have landed.
function split(title) {
const nodes = [];
const walker = document.createTreeWalker(title, NodeFilter.SHOW_TEXT);
while (walker.nextNode()) nodes.push(walker.currentNode);
const words = [];
nodes.forEach((node) => {
const fragment = document.createDocumentFragment();
node.data.split(/(\s+)/).forEach((piece) => {
if (!piece) return;
if (!piece.trim()) {
fragment.append(piece);
return;
}
const mask = document.createElement('span');
const word = document.createElement('span');
mask.className = `kodza-${NAME}__mask`;
word.className = `kodza-${NAME}__word`;
word.textContent = piece;
mask.append(word);
fragment.append(mask);
words.push(word);
});
node.replaceWith(fragment);
});
return words;
}
function prepare(root) {
const signal = signals.get(root);
if (!signal || signal.aborted || motion.matches) return;
entries.get(root)?.stop();
const parts = [...root.querySelectorAll('[data-enter]')];
if (!parts.length) return;
const style = getComputedStyle(root);
const easing = style.getPropertyValue(`--kz-${NAME}-enter-ease`).trim() || 'cubic-bezier(0.2, 0.8, 0.1, 1)';
const lift = 0.56 * ms(style.getPropertyValue(`--kz-${NAME}-duration`), 1200); // the next page starts to show
const delay = ms(style.getPropertyValue(`--kz-${NAME}-enter-delay`), 360);
const title = parts.find((el) => el.dataset.enter === 'title');
const markup = title?.innerHTML;
const words = title ? split(title) : [];
const anims = [];
const add = (el, keyframes, duration, ease = easing) => {
const anim = el.animate(keyframes, { duration, easing: ease, fill: 'both' });
anim.pause();
anims.push(anim);
return anim;
};
root.classList.add('is-entering');
parts.filter((el) => el.dataset.enter === 'label').forEach((el) => add(el, [{ opacity: 0, transform: 'translateY(8px)' }, { opacity: 1, transform: 'none' }], 500));
const lines = words.map((word) => [word, add(word, [{ transform: 'translateY(calc(110% + 0.16em))' }, { transform: 'none' }], 850)]);
// The image is there when the panel uncovers it, and settles from a zoom as it lifts:
// it moves with the transition instead of starting once it has gone.
const image = parts.filter((el) => el.dataset.enter === 'image').flatMap((el) => {
const media = el.matches('img, video, picture') ? null : el.querySelector('img, video, picture');
return media ? [add(media, [{ transform: 'scale(1.2)' }, { transform: 'none' }], 1600)] : [];
});
const rest = parts.filter((el) => !['label', 'title', 'image'].includes(el.dataset.enter)).map((el) => add(el, [{ opacity: 0, transform: 'translateY(16px)' }, { opacity: 1, transform: 'none' }], 650));
const stop = () => {
anims.forEach((anim) => anim.cancel());
if (title && title.innerHTML !== markup) title.innerHTML = markup;
root.classList.remove('is-entering');
pending.delete(entry);
if (entries.get(root) === entry) entries.delete(root);
};
const entry = {
stop,
start({ time, lifted }) {
// Lines are measured now, in their final font: the words of a line rise together
let top = null;
let line = -1;
lines.forEach(([word, anim]) => {
const y = Math.round(word.parentElement.getBoundingClientRect().top);
if (y !== top) {
top = y;
line += 1;
}
anim.effect.updateTiming({ delay: 60 + line * 90 });
});
image.forEach((anim) => anim.effect.updateTiming({ delay: lifted ? lift - delay : 0 }));
rest.forEach((anim, i) => anim.effect.updateTiming({ delay: 60 + (line + 1) * 90 + i * 70 }));
const at = Math.max(time + (lifted ? delay : 0), now());
anims.forEach((anim) => {
anim.startTime = at;
});
Promise.all(anims.map((anim) => anim.finished)).then(stop, () => {});
},
};
entries.set(root, entry);
signal.addEventListener('abort', stop, { once: true });
if (go) entry.start(go);
else pending.add(entry);
}
function arrive(time, lifted) {
go = { time, lifted };
pending.forEach((entry) => entry.start(go));
pending.clear();
}
// Inside one page (Swup, an app, the demo): the same transition around a content swap.
// document.dispatchEvent(new CustomEvent('kodza:page-transition', { cancelable: true,
// detail: { update: () => swapTheContent(), back: false } })) || nothing to do
// dispatchEvent() returns true when no engine took it: then run update() yourself.
function swap(update, back) {
const lift = Boolean(document.startViewTransition) && !motion.matches;
if (lift && current && current === local && turn && back === heading) {
const first = turn; // already on its way there: this swap waits its turn too
turn = async () => {
await first();
await update();
};
return;
}
if (lift && current && current === local && !turn && back !== heading && reverse(update, back)) return;
unturn();
const before = shown();
const p = lift ? progress() : null;
const at = p == null || back === heading ? 0 : back ? 1 - p : p;
const stay = lift ? name(null, false) : [];
const run = async () => {
await update();
init();
const after = shown();
const arriving = after.filter((root) => !before.includes(root));
if (lift) {
VARS.forEach((v) => html.style.removeProperty(`--kz-${NAME}-${v}`));
apply(back ? values(before.find((root) => !after.includes(root))) || values(after[0]) : values(arriving[0]) || values(after[0]));
name(stay, false);
}
go = null;
if (!back && !at) arriving.forEach(prepare);
};
if (!lift) {
run().then(() => arrive(now(), false));
return;
}
const vt = document.startViewTransition(run);
current = vt;
local = vt;
heading = back;
html.classList.toggle(BACK, back);
html.style.setProperty(`--kz-${NAME}-at`, at);
vt.ready.then(() => arrive(now(), true), () => arrive(now(), false));
vt.finished.finally(() => {
if (current !== vt) return;
current = null;
clean();
});
}
// Turned round in the middle (back while it lifts, or the other way): the same transition
// plays backwards from where it is, and the content swaps once it is back where it started,
// the page it was showing out of sight. A new one would first show that page whole, a frame.
// It goes back to the page it came from, as a "back" does. Its animations wait at their start
// (a longer delay, the same place) until the swap is done: the transition stays on screen.
function reverse(update, back) {
const runs = document.getAnimations().filter((a) => a.effect?.pseudoElement?.startsWith('::view-transition') && a.playState === 'running');
if (!runs.length) return false;
runs.forEach((a) => {
const time = a.currentTime;
a.effect.updateTiming({ delay: a.effect.getTiming().delay + WAIT });
a.currentTime = time + WAIT;
a.updatePlaybackRate(-a.playbackRate);
});
hold = runs;
heading = back;
turn = update;
const wait = () => {
if (hold !== runs) return;
if (runs.some((a) => a.currentTime > WAIT)) {
requestAnimationFrame(wait);
return;
}
Promise.resolve()
.then(() => turn())
.then(init)
.finally(() => hold === runs && unturn());
};
requestAnimationFrame(wait);
return true;
}
document.addEventListener('kodza:page-transition', (event) => {
if (typeof event.detail?.update !== 'function') return;
event.preventDefault();
swap(event.detail.update, Boolean(event.detail.back));
}, { signal: page.signal });
// Between two documents: the page you leave writes the record...
document.addEventListener('click', (event) => {
const link = event.target.closest?.('a[href]');
pressed = link?.hasAttribute('data-page-back') ? { href: here(link.href), time: Date.now() } : null;
}, { capture: true, signal: page.signal });
// While the pages trade places the browser sends every click to the page itself: one on the
// header that stays goes on to the link under it (back, in the middle of a lift, turns it round).
// After the listener above, which would forget the link pressed.
document.addEventListener('click', (event) => {
if (!current || event.target !== html) return;
const { clientX: x, clientY: y } = event;
const hit = stayed.flatMap((el) => [...el.querySelectorAll('a[href], button')]).find((el) => {
const box = el.getBoundingClientRect();
return x >= box.left && x <= box.right && y >= box.top && y <= box.bottom;
});
hit?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window, detail: 1, clientX: x, clientY: y, ctrlKey: event.ctrlKey, metaKey: event.metaKey, shiftKey: event.shiftKey, altKey: event.altKey }));
}, { capture: true, signal: page.signal });
window.addEventListener('pageswap', (event) => {
if (!event.viewTransition) return;
const activation = event.activation;
const traverse = activation?.navigationType === 'traverse';
const to = activation?.entry?.url ? here(activation.entry.url) : '';
const clicked = Boolean(pressed) && Date.now() - pressed.time < 4000 && (!to || pressed.href === to);
const record = {
to,
back: traverse ? activation.entry.index < activation.from.index : clicked,
p: progress(),
was: heading,
stay: name(null, traverse),
vars: values(shown()[0]),
time: Date.now(),
};
try {
sessionStorage.setItem(KEY, JSON.stringify(record));
} catch (error) {
// no storage: the next page still lifts, forward
}
}, { signal: page.signal });
// ...and the page that lands reads it before its first paint
let landing = read(false);
if (!motion.matches && !landing.back && !landing.at && navType !== 'back_forward' && !performance.getEntriesByType('paint').length) html.classList.add(ENTER);
window.addEventListener('pagereveal', (event) => {
const land = landing || read(true); // later ones: the page comes back from the back/forward cache
landing = null;
revealed = true;
clean();
const vt = event.viewTransition;
if (!vt) {
arrive(now(), false);
return;
}
current = vt;
heading = land.back;
html.classList.toggle(BACK, land.back);
if (land.at) html.style.setProperty(`--kz-${NAME}-at`, land.at);
const own = values(shown()[0]);
apply(land.back ? land.vars || own : own || land.vars);
name(land.stay, false);
vt.ready.then(() => arrive(now(), true), () => arrive(now(), false));
vt.finished.finally(() => {
if (current !== vt) return;
current = null;
clean();
});
}, { signal: page.signal });
// No pagereveal (Firefox, older Safari), or the script came after it: the arrival plays now
requestAnimationFrame(() => {
if (!revealed) arrive(now(), false);
});
// Once the sections of the page are prepared, the class goes: one added later starts shown
const settle = () => requestAnimationFrame(() => html.classList.remove(ENTER));
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', settle, { once: true, signal: page.signal });
else settle();
// ---------- Page engine (end) ----------
// The curtain: a panel with the name of the page you go to, drawn only while a transition
// runs. The name is the page's data-page-name, or the first part of its title.
const COVER = `kodza-${NAME}-cover`;
let curtain = null;
let label = null;
let watching = false;
const active = () => {
try {
return html.matches(':active-view-transition');
} catch (error) {
return false;
}
};
const named = () => [...document.querySelectorAll('[data-page-name]')].filter((el) => el.getClientRects().length);
function cover(before) {
if (!curtain) {
curtain = document.createElement('div');
curtain.className = `kodza-${NAME}__curtain`;
curtain.setAttribute('aria-hidden', 'true');
label = document.createElement('span');
label.className = `kodza-${NAME}__name`;
curtain.append(label);
page.signal.addEventListener('abort', () => {
curtain.remove();
html.classList.remove(COVER);
}, { once: true });
}
const shown = named();
const to = shown.find((el) => !before.includes(el)) || shown[0];
label.textContent = to?.dataset.pageName?.trim() || document.title.split(/\s+[|·–—-]\s+/)[0].trim();
if (!curtain.isConnected) (document.body || html).append(curtain);
html.classList.add(COVER);
if (watching) return;
watching = true;
// The class goes with the transition: the panel is never drawn on the page itself
const watch = () => {
if (active() && !page.signal.aborted) {
requestAnimationFrame(watch);
return;
}
watching = false;
html.classList.remove(COVER);
};
requestAnimationFrame(watch);
}
// Between two documents: the page that lands puts it on before the browser captures it
window.addEventListener('pagereveal', (event) => {
if (event.viewTransition && !motion.matches) cover([]);
}, { signal: page.signal });
// Inside one page: once the content is swapped, before the browser captures the new state.
// A curtain turned round mid-way keeps the name it had.
window.addEventListener('kodza:page-transition', (event) => {
const update = event.detail?.update;
if (typeof update !== 'function' || motion.matches) return;
event.detail.update = async () => {
const before = named();
await update();
if (active() && !html.classList.contains(COVER)) cover(before);
};
}, { capture: true, signal: page.signal });
// One instance, with its own state: two copies on a page never interfere. Everything it
// starts is tied to `signal` (listeners get { signal }, observers and timers stop on its
// 'abort' event), so kodza:destroy stops it all.
function mount(root, signal) {
signals.set(root, signal);
if (!html.classList.contains(ENTER)) return;
prepare(root); // hidden from the first paint by the CSS, then by its own first frame
queueMicrotask(() => html.classList.remove(ENTER));
}
// 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. Two
// components on one root (a reveal on a stat card) both start, and stop together.
const KODZA = Symbol.for('kodza');
const RUNNING = Symbol.for(`kodza ${SELECTOR}`); // a root this component runs on, for every copy of this script
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) => {
// Already running, maybe from another copy of this script. Marked is-ready with no Kodza component
// running on it, a root is a copy of a started one (a cloned slide): it is left as it is
if (root[RUNNING] || (root.classList.contains('is-ready') && !root[KODZA])) return;
// Rendered by React (data-kodza-manual): React starts it, with an init aimed at that markup once
// it has hydrated it. Any earlier start would change markup React has not taken over yet
const owner = root.closest('[data-kodza-manual]');
if (owner && !(scope && owner.contains(scope))) return;
const controller = new AbortController();
// Another Kodza component already running on this root: its markup as written is kept, and the
// two stop together
const before = root[KODZA];
const saved = { html: before ? before.html : written(root), attrs: before ? before.attrs : attrsOf(root), stop: () => destroy(root) };
if (before) before.above = saved;
instances.set(root, { controller, saved, before });
root[KODZA] = saved;
root[RUNNING] = true;
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);
instance.saved.above?.stop(); // a Kodza component started after it on the same root stops first
// 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[RUNNING];
// Started on top of another one: that one stops next, and puts the markup back
if (instance.before) {
delete instance.before.above;
root[KODZA] = instance.before;
return instance.before.stop();
}
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 — Curtain Transition, for React. From https://kodza.dev/components/curtain-transition/
// 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: curtain-transition.css and curtain-transition.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.
// data-kodza-manual keeps the script from starting it on its own: the effect below does, once
// React has hydrated the markup (on a page that streams in, the script can load first).
// 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 './curtain-transition.css';
type Variant = "curved" | "from-top";
export type CurtainTransitionProps = Omit<ComponentPropsWithoutRef<'section'>, "children" | "variant" | "vars" | "pageName" | "onPageEngine" | "onPageTransition"> & {
/** Modifier class(es): .kodza-curtain-transition--curved, .kodza-curtain-transition--from-top */
variant?: Variant | Variant[];
/** data-page-name on the root (default: Null & Void) */
pageName?: "Null & Void";
/** Settings, as CSS variables on the root */
vars?: {
/** the whole curtain: up, a beat on the name, off — default: 1.2s */
"--kz-curtain-transition-duration"?: string | number;
/** default: cubic-bezier(0.76, 0, 0.24, 1) */
"--kz-curtain-transition-ease"?: string | number;
/** the panel — default: #0a0a0a */
"--kz-curtain-transition-ink"?: string | number;
/** the name on it — default: #f2f2f0 */
"--kz-curtain-transition-ink-fg"?: string | number;
/** 1: up from the bottom, -1: down from the top — default: 1 */
"--kz-curtain-transition-way"?: string | number;
/** how far its leading edge bows — default: 0px */
"--kz-curtain-transition-curve"?: string | number;
/** the arrival starts as the curtain lifts off it — default: 0.8s */
"--kz-curtain-transition-enter-delay"?: string | number;
/** default: cubic-bezier(0.2, 0.8, 0.1, 1) */
"--kz-curtain-transition-enter-ease"?: string | number;
/** default: #f2f2f0 */
"--kz-curtain-transition-bg"?: string | number;
/** default: #0a0a0a */
"--kz-curtain-transition-fg"?: string | number;
/** default: rgba(10, 10, 10, 0.62) */
"--kz-curtain-transition-muted"?: string | number;
/** default: rgba(10, 10, 10, 0.12) */
"--kz-curtain-transition-line"?: string | number;
/** default: calc(16px * var(--kz-radius-scale, 1)) */
"--kz-curtain-transition-image-radius"?: string | number;
/** default: 24px */
"--kz-curtain-transition-side"?: string | number;
};
/** "kodza:page-engine", fired by the script (bubbles from the root) */
onPageEngine?: (event: CustomEvent) => void;
/** "kodza:page-transition", fired by the script (bubbles from the root) */
onPageTransition?: (event: CustomEvent) => void;
className?: string;
};
export function CurtainTransition({ variant, pageName = "Null & Void", vars, onPageEngine, onPageTransition, className, style, ...rest }: CurtainTransitionProps) {
const ref = useRef<ComponentRef<'section'>>(null);
const classes = ["kodza-curtain-transition", ...([] as string[]).concat(variant ?? []).map((v) => `kodza-curtain-transition--${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, pageName, 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('./curtain-transition.js').then(() => {
if (live) document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root } }));
});
return () => {
live = false;
document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } }));
};
}, [key]);
useEffect(() => {
const root = ref.current;
if (!root || !onPageEngine) return;
const listener = (event: Event) => onPageEngine(event as CustomEvent);
root.addEventListener("kodza:page-engine", listener);
return () => root.removeEventListener("kodza:page-engine", listener);
}, [onPageEngine, key]);
useEffect(() => {
const root = ref.current;
if (!root || !onPageTransition) return;
const listener = (event: Event) => onPageTransition(event as CustomEvent);
root.addEventListener("kodza:page-transition", listener);
return () => root.removeEventListener("kodza:page-transition", listener);
}, [onPageTransition, key]);
return (
<section data-kodza-curtain-transition="" key={key} {...rest} className={classes} data-kodza-manual data-page-name={pageName} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
<p className="kodza-curtain-transition__label" data-enter="label">Case study · 04 / 12</p>
<div className="kodza-curtain-transition__split">
<h1 className="kodza-curtain-transition__title" data-enter="title">The deploy that went out on a Friday</h1>
<div className="kodza-curtain-transition__intro">
<p className="kodza-curtain-transition__lead" data-enter="">A full redesign, shipped four minutes before the weekend. No rollback, no war room, nobody paged. Here is how a team of three made it boring on purpose.</p>
<dl className="kodza-curtain-transition__facts">
<div data-enter="">
<dt>Client</dt>
<dd>{"Null & Void"}</dd>
</div>
<div data-enter="">
<dt>Year</dt>
<dd>2026</dd>
</div>
<div data-enter="">
<dt>Shipped</dt>
<dd>Fri, 17:56</dd>
</div>
</dl>
</div>
</div>
<figure className="kodza-curtain-transition__media">
<div className="kodza-curtain-transition__frame" data-enter="image">
<img className="kodza-curtain-transition__image" src="https://kodza.dev/media/kz-steps-2400.webp" width="2400" height="1600" alt="Concrete steps climbing through bare grey walls" />
</div>
<figcaption data-enter="">
<span>fig. 1 — the release plan, in its final form</span>
<span>git push, then leave</span>
</figcaption>
</figure>
</section>
);
}
Checked
Robots poked at it before you did. Every component goes through the same checks, and again each time it changes.