photos/src/index.scss
2026-06-02 20:03:36 +01:00

310 lines
5.9 KiB
SCSS

$breakpoint: 900px;
:root {
--color-text: #fff;
--color-ink: #202124;
--color-accent: #a63446;
--color-accent-strong: #7c2130;
--color-background: #eee;
--color-focus: #ffd166;
--border-width: 5px;
--space-xs: 0.375rem;
--space-s: 0.75rem;
--space-m: 1.5rem;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
min-height: 100%;
background: var(--color-background);
color: var(--color-ink);
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
sans-serif;
}
body {
block-size: 100dvh;
margin: 0;
display: grid;
grid-template-columns: auto minmax(0, 1fr);
overflow: hidden;
}
img {
display: block;
max-inline-size: 100%;
block-size: auto;
}
:focus {
outline: none;
}
:focus-visible {
outline: 3px solid var(--color-focus);
outline-offset: 4px;
}
.site-header {
display: grid;
place-items: center;
position: relative;
min-inline-size: 5rem;
background: var(--color-accent);
color: var(--color-text);
padding: var(--space-m) var(--space-s);
}
.site-header h1 {
margin: 0;
font-size: clamp(1.5rem, 4vmin, 3rem);
font-weight: 300;
line-height: 1;
writing-mode: vertical-rl;
transform: rotate(180deg);
white-space: nowrap;
}
.gallery {
min-width: 0;
min-height: 100dvh;
display: grid;
grid-template-columns: minmax(5rem, 10vmin) minmax(0, 1fr) minmax(
7rem,
14vmin
);
position: relative;
}
.rail {
min-height: 0;
max-height: 100dvh;
overflow-y: auto;
overscroll-behavior: contain;
display: flex;
flex-direction: column;
align-items: center;
gap: var(--space-s);
padding: var(--space-m) var(--space-s);
scrollbar-color: var(--color-accent) transparent;
}
.thumbnail {
display: block;
flex: 0 0 auto;
border: var(--border-width) solid var(--color-text);
background: var(--color-text);
color: inherit;
box-shadow: 0 0 0 1px rgb(32 33 36 / 16%);
}
.thumbnail:hover,
.thumbnail.is-selected {
border-color: var(--color-accent);
}
.thumbnail:focus-visible {
outline: 3px solid var(--color-focus);
outline-offset: 3px;
box-shadow:
0 0 0 6px var(--color-accent-strong),
0 0 0 1px rgb(32 33 36 / 16%);
}
.thumbnail--portrait {
inline-size: 8vmin;
}
.thumbnail--landscape {
inline-size: 12vmin;
}
.thumbnail picture,
.thumbnail img {
inline-size: 100%;
}
.frame {
min-width: 0;
min-height: 0;
display: grid;
padding: var(--space-m);
}
.frame-content {
min-width: 0;
min-height: 0;
display: grid;
// A full-width column gives the figure a definite width to size against, so
// `100%` below resolves to the real available width (not the image's own,
// content-collapsed width) even before the photo has loaded.
grid-template-columns: minmax(0, 1fr);
align-content: center;
justify-items: center;
position: relative;
}
.frame-content.is-loading::after {
content: '';
position: absolute;
inset: 0;
margin: auto;
inline-size: 3rem;
block-size: 3rem;
border: 4px solid rgb(32 33 36 / 20%);
border-block-start-color: var(--color-accent);
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: reduce) {
.frame-content.is-loading::after {
animation: none;
}
}
// Holds the next photo's <picture> off-screen so the browser fetches it before
// the slideshow advances. Kept renderable (not display: none) so loading runs.
.frame-preload {
position: absolute;
inline-size: 0;
block-size: 0;
overflow: hidden;
pointer-events: none;
}
// Size the framed photo to its final, contained dimensions up front — width is
// capped by the available width (100%) and by the height limit scaled by the
// photo's aspect ratio — so the white frame never grows from a tiny box to the
// photo's size while the image is still loading. --frame-ratio is set per photo.
.frame-figure {
margin: 0;
inline-size: min(100%, calc((100dvh - 5rem) * var(--frame-ratio, 1)));
}
.frame-figure picture {
display: block;
}
.frame-figure img {
inline-size: 100%;
block-size: auto;
max-block-size: calc(100dvh - 5rem);
border: var(--border-width) solid var(--color-text);
background: var(--color-text);
object-fit: contain;
box-shadow: 0 0 0 1px rgb(32 33 36 / 16%);
}
.slideshow-toggle {
display: none;
position: absolute;
inset-block-start: var(--space-s);
justify-self: center;
border: 0;
border-radius: 4px;
padding: 0.45rem 0.75rem;
background: var(--color-accent-strong);
color: var(--color-text);
font: inherit;
font-size: 0.875rem;
line-height: 1;
cursor: pointer;
}
.js .slideshow-toggle {
display: block;
}
.slideshow-toggle:hover {
background: #5f1724;
}
@media (width < $breakpoint) {
body {
grid-template-columns: 1fr;
grid-template-rows: auto minmax(0, 1fr);
}
.site-header {
padding: var(--space-s);
}
.slideshow-toggle {
inset-block-start: 50%;
inset-inline: auto var(--space-s);
transform: translateY(-50%);
}
.site-header h1 {
writing-mode: horizontal-tb;
transform: none;
font-size: clamp(1.5rem, 7vw, 2rem);
}
.gallery {
min-height: 0;
grid-template-columns: minmax(0, 1fr);
grid-template-rows: auto minmax(0, 1fr) auto;
}
.rail {
max-height: none;
min-width: 0;
overflow: auto hidden;
flex-direction: row;
justify-content: flex-start;
padding: var(--space-xs) var(--space-s);
}
.rail--portraits {
grid-row: 1;
}
.rail--landscapes {
grid-row: 3;
}
.thumbnail {
inline-size: auto;
}
.thumbnail--portrait img {
block-size: 12vmin;
inline-size: auto;
}
.thumbnail--landscape img {
block-size: 8vmin;
inline-size: auto;
}
.frame {
grid-row: 2;
padding: var(--space-s);
}
.frame-figure {
inline-size: min(100%, calc((100dvh - 12rem) * var(--frame-ratio, 1)));
}
.frame-figure img {
max-block-size: calc(100dvh - 12rem);
}
}