Hero Collage
A centred hero with pictures scattered around the title: they open one after the other, then follow the mouse a little, each at its own depth.
View codeA hero for a place with opening hours: a status line works out, at the place's own time, if it's open ("Open now · closes 23:00", "Closes in 25 min") and rolls to the new words on the minute.
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 Hero Open to my page.
claude mcp add -t http kodza https://kodza.dev/api/mcp
<section class="kodza-hero-open" data-timezone="Europe/Paris" data-hours="mon closed; tue-thu 12:00-14:30, 18:00-23:00; fri-sat 12:00-14:30, 18:00-01:00; sun 11:00-16:00">
<div class="kodza-hero-open__inner">
<div class="kodza-hero-open__head">
<div class="kodza-hero-open__copy">
<p class="kodza-hero-open__eyebrow"><span class="kodza-hero-open__rise">Wine bar — Le Havre</span></p>
<h1 class="kodza-hero-open__title"><span class="kodza-hero-open__line"><span class="kodza-hero-open__rise">Le Quai</span></span></h1>
<p class="kodza-hero-open__lead">Natural wine, small plates and the boats going by. Booking takes one form, not an app.</p>
</div>
<div class="kodza-hero-open__info">
<p class="kodza-hero-open__status"><span class="kodza-hero-open__dot" aria-hidden="true"></span><span class="kodza-hero-open__text">Tue–Sun, from 12:00</span></p>
<address class="kodza-hero-open__address"><span class="kodza-hero-open__line">14 quai de Southampton</span><span class="kodza-hero-open__line">76600 Le Havre</span></address>
<div class="kodza-hero-open__actions">
<a class="kodza-hero-open__button kodza-hero-open__button--ink" href="#">Book a table<svg class="kodza-hero-open__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M2.5 8h10.5M9 3.5 13.5 8 9 12.5" /></svg></a>
<a class="kodza-hero-open__button kodza-hero-open__button--soft" href="https://www.google.com/maps/search/?api=1&query=14+quai+de+Southampton+Le+Havre">Directions</a>
</div>
</div>
</div>
<figure class="kodza-hero-open__media">
<div class="kodza-hero-open__frame"><div class="kodza-hero-open__curtain"><div class="kodza-hero-open__hold"><img src="https://kodza.dev/media/kz-table-2400.webp" srcset="https://kodza.dev/media/kz-table-1400.webp 1400w, https://kodza.dev/media/kz-table-2400.webp 2400w" sizes="(max-width: 1320px) 100vw, 1240px" alt="A concrete table for two on the quay edge, two glasses of red, a sailboat out in the haze" width="2400" height="1800" fetchpriority="high" /></div></div></div>
<figcaption class="kodza-hero-open__caption">fig. 01 — table for two, before service</figcaption>
</figure>
</div>
</section>
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Hero Open
A venue hero: the name set large, and beside it a status worked out at the place's own time
("Open now · closes 23:00", "Closes in 25 min", "Closed · opens Wed 12:00"), the address and a
booking button, over a wide picture of the place. On load the name rises out of its mask and
the picture opens from the top edge down. The status needs the few lines of component.js;
everything else is CSS, tuned with the --kz-hero-open-* variables. */
.kodza-hero-open {
--kz-hero-open-ink: #0a0a0a;
--kz-hero-open-paper: #f2f2f0;
--kz-hero-open-dim: rgba(10, 10, 10, 0.64);
--kz-hero-open-faint: rgba(10, 10, 10, 0.6);
--kz-hero-open-soft: rgba(10, 10, 10, 0.07);
--kz-hero-open-bg: transparent;
--kz-hero-open-width: 1240px;
--kz-hero-open-pad-y: clamp(48px, 6vw, 96px);
--kz-hero-open-gutter: clamp(16px, 4vw, 40px);
--kz-hero-open-radius: 16px;
--kz-hero-open-height: clamp(280px, 36vw, 540px);
--kz-hero-open-position: 50% 60%;
--kz-hero-open-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
--kz-hero-open-ease: cubic-bezier(0.22, 1, 0.36, 1);
--kz-hero-open-glide: cubic-bezier(0.6, 0, 0.1, 1);
--kz-hero-open-soft-ease: cubic-bezier(0.25, 1, 0.5, 1);
container: kodza-hero-open / inline-size;
box-sizing: border-box;
width: 100%;
padding-block: var(--kz-hero-open-pad-y);
padding-left: max(var(--kz-hero-open-gutter), env(safe-area-inset-left, 0px));
padding-right: max(var(--kz-hero-open-gutter), env(safe-area-inset-right, 0px));
background: var(--kz-hero-open-bg);
color: var(--kz-hero-open-ink);
}
.kodza-hero-open__inner {
max-width: var(--kz-hero-open-width);
margin: 0 auto;
}
/* The name on the left, what you need to come on the right, both on the same bottom line */
.kodza-hero-open__head {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
align-items: end;
gap: 32px clamp(32px, 5vw, 80px);
margin-bottom: clamp(28px, 3.4vw, 48px);
}
.kodza-hero-open__copy {
min-width: 0;
}
.kodza-hero-open__eyebrow {
margin: 0 0 18px;
overflow: hidden;
font-family: var(--kz-hero-open-mono);
font-size: 12.5px;
font-weight: 500;
letter-spacing: 0.02em;
color: var(--kz-hero-open-faint);
}
.kodza-hero-open__title {
margin: 0 0 24px;
/* Bounded by the container too, so the name keeps to one line on a phone */
font-size: min(clamp(64px, 11vw, 168px), 17cqi);
font-weight: 700;
line-height: 0.92;
letter-spacing: -0.055em;
color: var(--kz-hero-open-ink);
}
/* Each line is its own mask: the words rise from behind its bottom edge */
.kodza-hero-open__line {
display: block;
overflow: hidden;
padding-bottom: 0.08em;
margin-bottom: -0.08em;
}
.kodza-hero-open__rise {
display: block;
}
.kodza-hero-open__lead {
max-width: 34ch;
margin: 0;
font-size: clamp(16px, 1.35vw, 19px);
line-height: 1.55;
color: var(--kz-hero-open-dim);
text-wrap: pretty;
}
.kodza-hero-open__info {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 18px;
min-width: 0;
}
/* The status: a soft pill whose words roll when they change and whose width follows them */
.kodza-hero-open__status {
box-sizing: border-box;
display: inline-flex;
align-items: center;
gap: 10px;
max-width: 100%;
height: 36px;
margin: 0;
padding: 0 16px 0 14px;
border-radius: 999px;
background: var(--kz-hero-open-soft);
font-family: var(--kz-hero-open-mono);
font-size: 13px;
font-weight: 500;
line-height: 20px;
white-space: nowrap;
color: var(--kz-hero-open-ink);
}
/* Filled while it's open, a ring while it's closed: the words say it too */
.kodza-hero-open__dot {
position: relative;
flex: none;
box-sizing: border-box;
width: 8px;
height: 8px;
border: 1.5px solid currentColor;
border-radius: 50%;
}
.kodza-hero-open__dot::before {
content: "";
position: absolute;
inset: -1.5px;
border-radius: inherit;
background: currentColor;
transform: scale(0);
transition: transform 0.45s var(--kz-hero-open-ease);
}
/* While it's open, a soft ring leaves the dot, again and again */
.kodza-hero-open__dot::after {
content: "";
position: absolute;
inset: -1.5px;
border-radius: inherit;
background: currentColor;
opacity: 0;
}
.kodza-hero-open.is-open .kodza-hero-open__dot::before {
transform: none;
}
/* The words and the minutes each roll in their own window */
.kodza-hero-open__text,
.kodza-hero-open__num {
position: relative;
display: inline-block;
overflow: hidden;
vertical-align: top;
}
.kodza-hero-open__text {
min-width: 0;
max-width: 100%;
text-overflow: ellipsis;
}
.kodza-hero-open__num {
font-variant-numeric: tabular-nums;
}
.kodza-hero-open__text > span,
.kodza-hero-open__num > span {
display: block;
}
/* What leaves stops sizing its window, so the width only follows the new words */
.kodza-hero-open .is-leaving {
position: absolute;
top: 0;
left: 0;
}
.kodza-hero-open__address {
margin: 0;
font-size: 15px;
font-style: normal;
line-height: 1.55;
color: var(--kz-hero-open-dim);
}
.kodza-hero-open__line {
display: block;
}
.kodza-hero-open__actions {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-top: 6px;
}
.kodza-hero-open__button {
position: relative;
isolation: isolate;
overflow: hidden;
box-sizing: border-box;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 10px;
height: 52px;
padding: 0 26px;
border: 0;
border-radius: 999px;
font-family: inherit;
font-size: 15px;
font-weight: 500;
line-height: 1;
white-space: nowrap;
text-decoration: none;
cursor: pointer;
}
.kodza-hero-open__button:focus-visible {
outline: 2px solid var(--kz-hero-open-ink);
outline-offset: 3px;
}
/* Ink: the arrow steps forward on hover */
.kodza-hero-open__button--ink {
background: var(--kz-hero-open-ink);
color: var(--kz-hero-open-paper);
}
.kodza-hero-open__arrow {
flex: none;
width: 16px;
height: 16px;
fill: none;
stroke: currentColor;
stroke-width: 1.5;
stroke-linecap: round;
stroke-linejoin: round;
transition: transform 0.3s var(--kz-hero-open-ease);
}
/* Soft: ink rises from the bottom edge on hover */
.kodza-hero-open__button--soft {
background: var(--kz-hero-open-soft);
color: var(--kz-hero-open-ink);
transition: color 0.4s var(--kz-hero-open-ease);
}
.kodza-hero-open__button--soft::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background: var(--kz-hero-open-ink);
transform: translateY(101%);
transition: transform 0.4s var(--kz-hero-open-ease);
}
@media (hover: hover) {
.kodza-hero-open__button--ink:hover .kodza-hero-open__arrow {
transform: translateX(4px);
}
.kodza-hero-open__button--soft:hover {
color: var(--kz-hero-open-paper);
}
.kodza-hero-open__button--soft:hover::before {
transform: none;
}
}
.kodza-hero-open__media {
min-width: 0;
margin: 0;
}
/* The curtain: the middle layer slides down from above while the inner one slides up into
place, so the picture is uncovered from the top edge down and never moves itself */
.kodza-hero-open__frame {
height: var(--kz-hero-open-height);
overflow: hidden;
border-radius: var(--kz-hero-open-radius);
}
.kodza-hero-open__curtain,
.kodza-hero-open__hold {
height: 100%;
}
.kodza-hero-open__curtain {
overflow: hidden;
}
.kodza-hero-open__frame img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
object-position: var(--kz-hero-open-position);
}
.kodza-hero-open__caption {
margin-top: 12px;
font-family: var(--kz-hero-open-mono);
font-size: 12.5px;
color: var(--kz-hero-open-faint);
}
/* One column: the details go under the name, and the buttons share the row */
@container kodza-hero-open (max-width: 760px) {
.kodza-hero-open__head {
grid-template-columns: minmax(0, 1fr);
gap: 28px;
}
.kodza-hero-open__info {
align-items: stretch;
}
.kodza-hero-open__status {
align-self: flex-start;
}
.kodza-hero-open__button {
flex: 1 1 auto;
}
.kodza-hero-open__frame {
height: auto;
aspect-ratio: 4 / 3;
}
}
/* The entrance, on load: the name rises, the details follow in a cascade, the picture opens and
settles. The quieter words are fully there halfway up, never read half-faded */
@media (prefers-reduced-motion: no-preference) {
.kodza-hero-open__eyebrow .kodza-hero-open__rise {
animation: kodza-hero-open-rise 1000ms var(--kz-hero-open-glide) 100ms both;
}
.kodza-hero-open__line .kodza-hero-open__rise {
animation: kodza-hero-open-rise 1170ms var(--kz-hero-open-glide) 210ms both;
}
.kodza-hero-open__lead,
.kodza-hero-open__status,
.kodza-hero-open__address,
.kodza-hero-open__actions {
animation: kodza-hero-open-in 900ms var(--kz-hero-open-soft-ease) 700ms both;
}
.kodza-hero-open__status {
animation-delay: 760ms;
}
.kodza-hero-open__address {
animation-delay: 820ms;
}
.kodza-hero-open__actions {
animation-delay: 880ms;
}
.kodza-hero-open__curtain {
animation: kodza-hero-open-curtain 1350ms var(--kz-hero-open-glide) 300ms both;
}
.kodza-hero-open__hold {
animation: kodza-hero-open-hold 1350ms var(--kz-hero-open-glide) 300ms both;
}
.kodza-hero-open__frame img {
animation: kodza-hero-open-settle 2000ms var(--kz-hero-open-soft-ease) 300ms both;
}
.kodza-hero-open__caption {
animation: kodza-hero-open-in 900ms var(--kz-hero-open-soft-ease) 900ms both;
}
.kodza-hero-open.is-open .kodza-hero-open__dot::after {
animation: kodza-hero-open-breathe 2.4s var(--kz-hero-open-ease) infinite;
}
}
@keyframes kodza-hero-open-rise {
from {
transform: translateY(105%);
}
}
@keyframes kodza-hero-open-in {
from {
opacity: 0;
transform: translateY(20px);
}
50% {
opacity: 1;
}
}
/* Closed 2px past the edge: a curtain closed exactly on the frame's edge can leak a hairline */
@keyframes kodza-hero-open-curtain {
from {
transform: translateY(calc(-100% - 2px));
}
}
@keyframes kodza-hero-open-hold {
from {
transform: translateY(calc(100% + 2px));
}
}
@keyframes kodza-hero-open-settle {
from {
transform: scale(1.2);
}
}
@keyframes kodza-hero-open-breathe {
0% {
opacity: 0.35;
transform: scale(1);
}
70%,
100% {
opacity: 0;
transform: scale(2.6);
}
}
@media (prefers-reduced-motion: reduce) {
.kodza-hero-open *,
.kodza-hero-open *::before,
.kodza-hero-open *::after {
transition-duration: 0.01ms !important;
animation-duration: 0.01ms !important;
}
}
/* kodza-guard 98eda426f112 — 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-hero-open__eyebrow):not(#_),
:where(.kodza-hero-open__title):not(#_),
:where(.kodza-hero-open__lead):not(#_),
:where(.kodza-hero-open__status):not(#_),
:where(.kodza-hero-open__address):not(#_),
:where(.kodza-hero-open__media):not(#_),
:where(.kodza-hero-open__caption):not(#_),
:where(.kodza-hero-open__hold img:where(:not([class*="kodza-"]))):not(#_) {
position: revert;
transition-duration: revert;
}
:where(.kodza-hero-open__button):not(#_) {
outline: revert;
transition: revert;
outline-offset: revert;
}
:where(.kodza-hero-open__arrow):not(#_) {
position: revert;
}
/* What the browser gives, on everything the component leaves to it */
.kodza-hero-open__inner:not(#_),
.kodza-hero-open__head:not(#_),
.kodza-hero-open__copy:not(#_),
.kodza-hero-open__rise:not(#_),
.kodza-hero-open__line:not(#_),
.kodza-hero-open__info:not(#_),
.kodza-hero-open__text:not(#_),
.kodza-hero-open__actions:not(#_),
.kodza-hero-open__frame:not(#_),
.kodza-hero-open__curtain:not(#_),
.kodza-hero-open__hold:not(#_),
.kodza-hero-open__text span:where(:not([class*="kodza-"])):not(#_) {
box-sizing: revert;
}
.kodza-hero-open__eyebrow:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-style: revert;
line-height: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-open__title:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-family: revert;
font-style: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-open__lead:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: 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;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-open__status:not(#_) {
border: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
float: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-height: revert;
font-style: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-open__address:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
font-family: revert;
font-weight: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-open__button:not(#_) {
margin: revert;
list-style: revert;
float: revert;
box-shadow: revert;
appearance: revert;
max-width: revert;
max-height: 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-hero-open__arrow:not(#_) {
border: revert;
margin: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-hero-open__media:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-open__caption:not(#_) {
border: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: 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;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-open__hold img:where(:not([class*="kodza-"])):not(#_) {
border: revert;
margin: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
transition-property: revert;
transition-timing-function: revert;
transition-delay: revert;
}
.kodza-hero-open__eyebrow:not(#_):where(:not([hidden])),
.kodza-hero-open__title:not(#_):where(:not([hidden])),
.kodza-hero-open__lead:not(#_):where(:not([hidden])),
.kodza-hero-open__address:not(#_):where(:not([hidden])),
.kodza-hero-open__arrow:not(#_):where(:not([hidden])),
.kodza-hero-open__media:not(#_):where(:not([hidden])),
.kodza-hero-open__caption:not(#_):where(:not([hidden])) {
display: revert;
}
.kodza-hero-open__eyebrow:not(#_):where([hidden]),
.kodza-hero-open__title:not(#_):where([hidden]),
.kodza-hero-open__lead:not(#_):where([hidden]),
.kodza-hero-open__address:not(#_):where([hidden]),
.kodza-hero-open__arrow:not(#_):where([hidden]),
.kodza-hero-open__media:not(#_):where([hidden]),
.kodza-hero-open__caption:not(#_):where([hidden]) {
display: none;
}
.kodza-hero-open__dot:not(#_)::before,
.kodza-hero-open__dot: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-hero-open__eyebrow:not(#_) {
margin: 0 0 18px;
font-family: var(--kz-hero-open-mono);
font-size: 12.5px;
font-weight: 500;
letter-spacing: 0.02em;
color: var(--kz-hero-open-faint);
}
.kodza-hero-open__title:not(#_) {
margin: 0 0 24px;
font-size: min(clamp(64px, 11vw, 168px), 17cqi);
font-weight: 700;
line-height: 0.92;
letter-spacing: -0.055em;
color: var(--kz-hero-open-ink);
}
.kodza-hero-open__lead:not(#_) {
max-width: 34ch;
margin: 0;
font-size: clamp(16px, 1.35vw, 19px);
line-height: 1.55;
color: var(--kz-hero-open-dim);
}
.kodza-hero-open__status:not(#_) {
box-sizing: border-box;
display: inline-flex;
max-width: 100%;
margin: 0;
padding: 0 16px 0 14px;
border-radius: 999px;
background: var(--kz-hero-open-soft);
font-family: var(--kz-hero-open-mono);
font-size: 13px;
font-weight: 500;
line-height: 20px;
color: var(--kz-hero-open-ink);
}
.kodza-hero-open .is-leaving:where(p, h1, address, a, svg, figure, img, figcaption):not(#_) {
position: absolute;
}
.kodza-hero-open__address:not(#_) {
margin: 0;
font-size: 15px;
font-style: normal;
line-height: 1.55;
color: var(--kz-hero-open-dim);
}
.kodza-hero-open__button:not(#_) {
position: relative;
box-sizing: border-box;
display: inline-flex;
padding: 0 26px;
border: 0;
border-radius: 999px;
font-family: inherit;
font-size: 15px;
font-weight: 500;
line-height: 1;
text-decoration: none;
}
.kodza-hero-open__button:focus-visible:not(#_) {
outline: 2px solid var(--kz-hero-open-ink);
outline-offset: 3px;
}
.kodza-hero-open__button--ink:not(#_) {
background: var(--kz-hero-open-ink);
color: var(--kz-hero-open-paper);
}
.kodza-hero-open__arrow:not(#_) {
transition: transform 0.3s var(--kz-hero-open-ease);
}
.kodza-hero-open__button--soft:not(#_) {
background: var(--kz-hero-open-soft);
color: var(--kz-hero-open-ink);
transition: color 0.4s var(--kz-hero-open-ease);
}
@media (hover: hover) {
.kodza-hero-open__button--soft:hover:not(#_) {
color: var(--kz-hero-open-paper);
}
}
.kodza-hero-open__media:not(#_) {
margin: 0;
}
.kodza-hero-open__frame img:not(#_) {
display: block;
}
.kodza-hero-open__caption:not(#_) {
margin-top: 12px;
font-family: var(--kz-hero-open-mono);
font-size: 12.5px;
color: var(--kz-hero-open-faint);
}
@media (prefers-reduced-motion: reduce) {
.kodza-hero-open *:where(p, h1, address, a, svg, figure, img, figcaption):not(#_) {
transition-duration: 0.01ms !important;
}
}
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Kodza — Hero Open
// Works out, at the place's own time, whether it's open: the week's hours are read from
// data-hours ("mon closed; tue-thu 12:00-14:30, 18:00-23:00; fri 18:00-01:00", a later rule
// replaces an earlier one for its days, an end before the start runs past midnight) and its
// time zone from data-timezone (an IANA name such as Europe/Paris; the visitor's own time when
// it's missing or unknown). The status then reads "Open now · closes 23:00", "Closes in 25 min"
// in the last hour (data-soon, in minutes), "Closed · opens Wed 12:00" or "Opens in 20 min".
// Its words come from the status's data-open, data-closing, data-closed and data-opening, with
// {time}, {min} and {when} in them, and the day names follow the page's lang. It's written again
// on every minute; a change of words rolls the line, a change of minutes rolls the number.
// data-now ("tue 22:35") pins the clock, to check a schedule before it goes live.
(() => {
const SELECTOR = '.kodza-hero-open';
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const DAYS = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
const DAY = 1440; // minutes
const WEEK = 7 * DAY;
const WORDS = {
open: 'Open now · closes {time}',
closing: 'Closes in {min} min',
closed: 'Closed · opens {when}',
opening: 'Opens in {min} min',
always: 'Open 24/7',
};
const minutes = (time) => {
const [h, m] = time.split(':').map(Number);
return h * 60 + (m || 0);
};
const clock = (n) => {
const m = ((n % DAY) + DAY) % DAY;
return `${String(Math.floor(m / 60)).padStart(2, '0')}:${String(m % 60).padStart(2, '0')}`;
};
// The open stretches of three weeks running (the one before and the one after catch the
// nights across Sunday), in minutes from this Monday 00:00, joined where one runs into the next
const stretches = (text) => {
const week = new Map();
(text || '').toLowerCase().split(';').forEach((rule) => {
const m = rule.trim().match(/^([a-z]{3})(?:\s*-\s*([a-z]{3}))?\b(.*)$/);
const from = DAYS.indexOf(m?.[1]);
const to = m?.[2] ? DAYS.indexOf(m[2]) : from;
if (from < 0 || to < 0) return;
const ranges = [...m[3].matchAll(/(\d{1,2}:\d{2})\s*-\s*(\d{1,2}:\d{2})/g)].map(([, a, b]) => [minutes(a), minutes(b)]);
for (let d = from; ; d = (d + 1) % 7) {
week.set(d, ranges);
if (d === to) break;
}
});
const all = [];
[-WEEK, 0, WEEK].forEach((shift) => week.forEach((ranges, d) => ranges.forEach(([a, b]) => {
const start = shift + d * DAY + a;
all.push([start, start + ((b - a + DAY - 1) % DAY) + 1]);
})));
all.sort((a, b) => a[0] - b[0]);
return all.reduce((joined, [a, b]) => {
const last = joined[joined.length - 1];
if (last && a <= last[1]) last[1] = Math.max(last[1], b);
else joined.push([a, b]);
return joined;
}, []);
};
// Now, at the place: minutes from Monday 00:00
const zoned = (zone) => {
const options = { weekday: 'short', hour: '2-digit', minute: '2-digit', hourCycle: 'h23' };
try {
return new Intl.DateTimeFormat('en-GB', { ...options, timeZone: zone || undefined });
} catch {
return new Intl.DateTimeFormat('en-GB', options);
}
};
const at = (text) => {
const m = (text || '').trim().toLowerCase().match(/^([a-z]{3})\s+(\d{1,2}:\d{2})$/);
return m && DAYS.includes(m[1]) ? DAYS.indexOf(m[1]) * DAY + minutes(m[2]) : null;
};
const span = (text) => Object.assign(document.createElement('span'), { textContent: text });
// 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) {
const status = root.querySelector('.kodza-hero-open__status');
const text = status?.querySelector('.kodza-hero-open__text');
if (!text) return;
const words = (key) => status.dataset[key] || WORDS[key];
const lang = root.closest('[lang]')?.lang || undefined;
let dayName;
try {
dayName = new Intl.DateTimeFormat(lang, { weekday: 'short', timeZone: 'UTC' });
} catch {
dayName = new Intl.DateTimeFormat('en', { weekday: 'short', timeZone: 'UTC' });
}
const day = (n) => dayName.format(new Date(Date.UTC(2024, 0, 1 + Math.floor((((n % WEEK) + WEEK) % WEEK) / DAY))));
// The old words rise out of their window as the new ones come from below, and the window's
// width goes from one to the other. A change that lands mid-roll drops the words already
// leaving, and the old ones leave from where they stand
const roll = (box, next, moving) => {
const old = box.lastElementChild;
const from = box.offsetWidth;
[...box.children].forEach((el) => el !== old && el.remove());
box.append(next);
if (!old) return;
if (!moving || reduceMotion) return old.remove();
const y = new DOMMatrixReadOnly(getComputedStyle(old).transform).m42;
old.getAnimations().forEach((a) => a.cancel());
old.classList.add('is-leaving');
old.setAttribute('aria-hidden', 'true');
const timing = { duration: 700, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' };
old.animate([{ transform: `translateY(${y}px)` }, { transform: 'translateY(-100%)' }], { ...timing, fill: 'forwards' }).finished.then(() => old.remove(), () => {});
next.animate([{ transform: 'translateY(100%)' }, { transform: 'none' }], timing);
// The window opens a little ahead of the words, so their end isn't cut for long
box.getAnimations().forEach((a) => a.cancel());
box.animate([{ width: `${from}px` }, { width: `${box.offsetWidth}px` }], { ...timing, duration: 480 });
};
// A line of words, with the minutes in their own window
const line = (template, values) => {
const el = document.createElement('span');
template.split(/(\{min\})/).forEach((part) => {
if (part !== '{min}') return el.append(part.replace(/\{(time|when)\}/g, (_, key) => values[key]));
const num = Object.assign(document.createElement('span'), { className: 'kodza-hero-open__num' });
num.append(span(values.min));
el.append(num);
});
return el;
};
let open = [];
let format = null;
let shown = '';
const now = () => {
const pinned = at(root.dataset.now);
if (pinned !== null) return pinned;
const parts = Object.fromEntries(format.formatToParts(new Date()).map((p) => [p.type, p.value]));
return DAYS.indexOf(parts.weekday.toLowerCase()) * DAY + minutes(`${parts.hour}:${parts.minute}`);
};
const read = () => {
open = stretches(root.dataset.hours);
format = zoned(root.dataset.timezone);
};
const update = (moving) => {
if (!open.length) return;
const t = now();
const soon = Number(root.dataset.soon) || 60;
const current = open.find(([a, b]) => a <= t && t < b);
const next = open.find(([a]) => a > t);
let key;
let values;
if (current && current[1] - current[0] >= 2 * WEEK) {
key = 'always';
} else if (current) {
key = current[1] - t < soon ? 'closing' : 'open';
values = { time: clock(current[1]), min: String(current[1] - t) };
} else {
key = next[0] - t < soon ? 'opening' : 'closed';
const today = Math.floor(next[0] / DAY) === Math.floor(t / DAY);
values = { min: String(next[0] - t), when: today ? clock(next[0]) : `${day(next[0])} ${clock(next[0])}` };
}
root.classList.toggle('is-open', Boolean(current));
root.classList.toggle('is-closed', !current);
const template = words(key);
const same = `${key}|${template}|${values?.time}|${values?.when}`;
if (same === shown && template.includes('{min}')) {
// Only the minutes moved: they roll on their own
const num = text.lastElementChild?.querySelector('.kodza-hero-open__num');
if (num && num.lastElementChild?.textContent !== values.min) roll(num, span(values.min), moving);
return;
}
if (same === shown) return;
shown = same;
roll(text, line(template, values ?? {}), moving);
};
// The words as written stay for a first paint without the script; they're replaced at once
text.replaceChildren();
read();
update(false);
// Every minute on the minute, and at once when the tab comes back or the hours change
let timer = 0;
const tick = () => {
update(true);
timer = setTimeout(tick, 60000 - (Date.now() % 60000) + 50);
};
timer = setTimeout(tick, 60000 - (Date.now() % 60000) + 50);
document.addEventListener('visibilitychange', () => {
if (!document.hidden) update(true);
}, { signal });
const watch = new MutationObserver(() => {
read();
update(true);
});
watch.observe(root, { attributes: true, attributeFilter: ['data-hours', 'data-timezone', 'data-now', 'data-soon'] });
signal.addEventListener('abort', () => {
clearTimeout(timer);
watch.disconnect();
});
}
// 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 — Hero Open, for React. From https://kodza.dev/components/hero-open/
// 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: hero-open.css and hero-open.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.
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './hero-open.css';
export type HeroOpenProps = Omit<ComponentPropsWithoutRef<'section'>, "children" | "vars" | "timezone" | "hours"> & {
/** data-timezone on the root (default: Europe/Paris) */
timezone?: "Europe/Paris";
/** data-hours on the root (default: mon closed; tue-thu 12:00-14:30, 18:00-23:00; fri-sat 12:00-14:30, 18:00-01:00; sun 11:00-16:00) */
hours?: "mon closed; tue-thu 12:00-14:30, 18:00-23:00; fri-sat 12:00-14:30, 18:00-01:00; sun 11:00-16:00";
/** Settings, as CSS variables on the root */
vars?: {
/** default: #0a0a0a */
"--kz-hero-open-ink"?: string | number;
/** default: #f2f2f0 */
"--kz-hero-open-paper"?: string | number;
/** default: rgba(10, 10, 10, 0.64) */
"--kz-hero-open-dim"?: string | number;
/** default: rgba(10, 10, 10, 0.6) */
"--kz-hero-open-faint"?: string | number;
/** default: rgba(10, 10, 10, 0.07) */
"--kz-hero-open-soft"?: string | number;
/** default: transparent */
"--kz-hero-open-bg"?: string | number;
/** default: 1240px */
"--kz-hero-open-width"?: string | number;
/** default: clamp(48px, 6vw, 96px) */
"--kz-hero-open-pad-y"?: string | number;
/** default: clamp(16px, 4vw, 40px) */
"--kz-hero-open-gutter"?: string | number;
/** default: 16px */
"--kz-hero-open-radius"?: string | number;
/** default: clamp(280px, 36vw, 540px) */
"--kz-hero-open-height"?: string | number;
/** default: 50% 60% */
"--kz-hero-open-position"?: string | number;
/** default: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace */
"--kz-hero-open-mono"?: string | number;
/** default: cubic-bezier(0.22, 1, 0.36, 1) */
"--kz-hero-open-ease"?: string | number;
/** default: cubic-bezier(0.6, 0, 0.1, 1) */
"--kz-hero-open-glide"?: string | number;
/** default: cubic-bezier(0.25, 1, 0.5, 1) */
"--kz-hero-open-soft-ease"?: string | number;
};
className?: string;
};
export function HeroOpen({ timezone = "Europe/Paris", hours = "mon closed; tue-thu 12:00-14:30, 18:00-23:00; fri-sat 12:00-14:30, 18:00-01:00; sun 11:00-16:00", vars, className, style, ...rest }: HeroOpenProps) {
const ref = useRef<ComponentRef<'section'>>(null);
const classes = ["kodza-hero-open", 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, timezone, hours, 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('./hero-open.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 (
<section key={key} {...rest} className={classes} data-timezone={timezone} data-hours={hours} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
<div className="kodza-hero-open__inner">
<div className="kodza-hero-open__head">
<div className="kodza-hero-open__copy">
<p className="kodza-hero-open__eyebrow">
<span className="kodza-hero-open__rise">Wine bar — Le Havre</span>
</p>
<h1 className="kodza-hero-open__title">
<span className="kodza-hero-open__line">
<span className="kodza-hero-open__rise">Le Quai</span>
</span>
</h1>
<p className="kodza-hero-open__lead">Natural wine, small plates and the boats going by. Booking takes one form, not an app.</p>
</div>
<div className="kodza-hero-open__info">
<p className="kodza-hero-open__status">
<span className="kodza-hero-open__dot" aria-hidden="true" />
<span className="kodza-hero-open__text">Tue–Sun, from 12:00</span>
</p>
<address className="kodza-hero-open__address">
<span className="kodza-hero-open__line">14 quai de Southampton</span>
<span className="kodza-hero-open__line">76600 Le Havre</span>
</address>
<div className="kodza-hero-open__actions">
<a className="kodza-hero-open__button kodza-hero-open__button--ink" href="#">Book a table<svg className="kodza-hero-open__arrow" viewBox="0 0 16 16" aria-hidden="true"> <path d="M2.5 8h10.5M9 3.5 13.5 8 9 12.5" /> </svg></a>
{' '}
<a className="kodza-hero-open__button kodza-hero-open__button--soft" href={"https://www.google.com/maps/search/?api=1&query=14+quai+de+Southampton+Le+Havre"}>Directions</a>
</div>
</div>
</div>
<figure className="kodza-hero-open__media">
<div className="kodza-hero-open__frame">
<div className="kodza-hero-open__curtain">
<div className="kodza-hero-open__hold">
<img src="https://kodza.dev/media/kz-table-2400.webp" srcSet="https://kodza.dev/media/kz-table-1400.webp 1400w, https://kodza.dev/media/kz-table-2400.webp 2400w" sizes="(max-width: 1320px) 100vw, 1240px" alt="A concrete table for two on the quay edge, two glasses of red, a sailboat out in the haze" width="2400" height="1800" fetchPriority="high" />
</div>
</div>
</div>
<figcaption className="kodza-hero-open__caption">fig. 01 — table for two, before service</figcaption>
</figure>
</div>
</section>
);
}
Checked
Robots poked at it before you did. Every component goes through the same checks, and again each time it changes.