Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ jobs:
- name: Set env parameters
run: echo "hugovr=$(cat .hugo_version)" >> $GITHUB_ENV

# The wave data, its drift direction and the --wave-shift values in
# waves.css have to agree, and a break shows up only partway through a
# minute-long animation cycle — no other gate can see it.
- name: Wave data is consistent
run: npm run check:waves --prefix themes/capro-tw

- uses: peaceiris/actions-hugo@v3
with:
hugo-version: ${{ env.hugovr }}
Expand Down
27 changes: 27 additions & 0 deletions scripts/a11y/run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,23 @@ for (const viewport of VIEWPORTS) {
const el = document.querySelector('.reveal') || document.body;
const cs = getComputedStyle(el);
const reveals = [...document.querySelectorAll('.reveal')];
// An infinite animation is the case duration cannot speak to: the global
// reduced-motion rule pins every element at 0.01ms, so a loop that never
// stops reports the same duration as one that was suppressed. Iteration
// count is what actually distinguishes them.
const looping = [...document.querySelectorAll('*')].flatMap((e) => {
const s = getComputedStyle(e);
return s.animationName !== 'none' && s.animationIterationCount !== '1'
? [s.animationIterationCount]
: [];
});
const waves = [...document.querySelectorAll('.wave')];
return {
transition: cs.transitionDuration,
animation: cs.animationDuration,
scroll: getComputedStyle(document.documentElement).scrollBehavior,
looping,
waveCount: waves.length,
allVisible:
reveals.length === 0 ||
reveals.every((e) => parseFloat(getComputedStyle(e).opacity) > 0.9),
Expand All @@ -306,6 +319,20 @@ for (const viewport of VIEWPORTS) {
const near0 = (v) => v.split(',').every((x) => parseFloat(x) <= 0.02);
note('reduced motion: transitions suppressed', near0(r.transition), r.transition);
note('reduced motion: animations suppressed', near0(r.animation), r.animation);
note(
'reduced motion: no animation still loops',
r.looping.length === 0,
r.looping.length
? `${r.looping.length} element(s) with iteration-count ${[...new Set(r.looping)].join(', ')}`
: 'none',
);
// Guards the probe itself: if the waves stop rendering, the check above
// passes vacuously and would hide a later regression.
note(
'reduced motion: the drifting waves are present to be checked',
r.waveCount > 0,
`${r.waveCount} .wave element(s)`,
);
note('reduced motion: smooth scroll disabled', r.scroll === 'auto', r.scroll);
note('reduced motion: content visible without the observer', r.allVisible);
await page.close();
Expand Down
16 changes: 0 additions & 16 deletions themes/capro-tw/assets/css/components/footer-waves.css

This file was deleted.

80 changes: 80 additions & 0 deletions themes/capro-tw/assets/css/components/waves.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@layer components {
.waves {
overflow: hidden;
pointer-events: none;
}

.waves svg {
display: block;
width: 100%;
height: 100%;
}

.waves--banner {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 6rem;
z-index: 10;
}

.waves--footer {
position: relative;
height: 3.75rem;
background-color: var(--color-dark);
}

.wave {
animation: wave-drift linear infinite;
}

/* --wave-shift must match drift/shift in data/waves.yaml; check-waves.mjs
fails the build if it does not. The durations differ per layer so that all
of them travel at a similar rate despite the two shift distances. */
.wave--1 {
--wave-shift: -1440px;
animation-duration: 96s;
stroke: var(--color-primary);
stroke-width: 2;
opacity: 0.3;
}

.wave--2 {
--wave-shift: 1440px;
animation-duration: 78s;
stroke: var(--color-primary-text);
stroke-width: 1.5;
opacity: 0.26;
}

.wave--3 {
--wave-shift: -720px;
animation-duration: 32s;
stroke: var(--color-primary);
stroke-width: 2;
opacity: 0.4;
}

.wave--4 {
--wave-shift: 1440px;
animation-duration: 110s;
stroke: var(--color-primary);
stroke-width: 2.5;
opacity: 0.5;
}

.wave--5 {
--wave-shift: -720px;
animation-duration: 42s;
stroke: var(--color-primary-text);
stroke-width: 1.5;
opacity: 0.22;
}

@keyframes wave-drift {
to {
transform: translateX(var(--wave-shift));
}
}
}
5 changes: 4 additions & 1 deletion themes/capro-tw/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@
html {
scroll-behavior: auto;
}
/* A 0.01ms loop does not stop, it runs flat out forever, so an infinite
animation needs the iteration cap rather than the duration. */
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
Expand Down Expand Up @@ -184,7 +187,7 @@
@import "./components/offerings.css";
@import "./components/team.css";
@import "./components/pubs.css";
@import "./components/footer-waves.css";
@import "./components/waves.css";

/* Leaflet's stylesheet is unlayered and loads after ours, so an @layer rule
can never override it however specific. Its attribution links are #0078a8
Expand Down
2 changes: 1 addition & 1 deletion themes/capro-tw/assets/css/vendor/tailwind.css

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions themes/capro-tw/data/waves.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by tools/gen-waves.mjs -- do not edit by hand.
# Run: npm run gen:waves --prefix themes/capro-tw
#
# A layer loops seamlessly because it is translated by exactly one period,
# so it lands on itself, and because it is drawn a further period past the
# viewBox on the side it drifts toward, so its trailing end stays out of
# sight. The second half depends on the direction: change `drift` without
# regenerating `d` and the line ends in mid-air partway through the cycle.
layers:
- key: 1
drift: left
shift: 1440
d: "M-720,114 C-360,114 -360,70 0,70 C360,70 360,114 720,114 C1080,114 1080,70 1440,70 C1800,70 1800,114 2160,114 C2520,114 2520,70 2880,70 C3240,70 3240,114 3600,114"
- key: 2
drift: right
shift: 1440
d: "M-2700,46 C-2340,46 -2340,102 -1980,102 C-1620,102 -1620,46 -1260,46 C-900,46 -900,102 -540,102 C-180,102 -180,46 180,46 C540,46 540,102 900,102 C1260,102 1260,46 1620,46 C1980,46 1980,102 2340,102"
- key: 3
drift: left
shift: 720
d: "M-630,44 C-450,44 -450,80 -270,80 C-90,80 -90,44 90,44 C270,44 270,80 450,80 C630,80 630,44 810,44 C990,44 990,80 1170,80 C1350,80 1350,44 1530,44 C1710,44 1710,80 1890,80 C2070,80 2070,44 2250,44 C2430,44 2430,80 2610,80"
- key: 4
drift: right
shift: 1440
d: "M-2480,24 C-2120,24 -2120,72 -1760,72 C-1400,72 -1400,24 -1040,24 C-680,24 -680,72 -320,72 C40,72 40,24 400,24 C760,24 760,72 1120,72 C1480,72 1480,24 1840,24 C2200,24 2200,72 2560,72"
- key: 5
drift: left
shift: 720
d: "M-460,20 C-280,20 -280,48 -100,48 C80,48 80,20 260,20 C440,20 440,48 620,48 C800,48 800,20 980,20 C1160,20 1160,48 1340,48 C1520,48 1520,20 1700,20 C1880,20 1880,48 2060,48 C2240,48 2240,20 2420,20 C2600,20 2600,48 2780,48"
10 changes: 1 addition & 9 deletions themes/capro-tw/layouts/partials/footer/footer.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
<div class="footer-waves" aria-hidden="true">
<svg viewBox="0 0 1440 120" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0,90 C240,30 480,110 720,60 C960,10 1200,80 1440,50" fill="none" stroke="#c04545" stroke-width="2" opacity="0.35"/>
<path d="M0,70 C200,110 440,20 720,80 C1000,140 1240,40 1440,70" fill="none" stroke="#c04545" stroke-width="2" opacity="0.5"/>
<path d="M0,50 C300,90 500,30 720,70 C940,110 1140,50 1440,90" fill="none" stroke="#E57575" stroke-width="2" opacity="0.4"/>
<path d="M0,100 C180,60 420,100 720,40 C1020,80 1260,30 1440,60" fill="none" stroke="#c04545" stroke-width="2.5" opacity="0.6"/>
<path d="M0,80 C260,40 500,90 720,50 C940,10 1180,70 1440,40" fill="none" stroke="#E57575" stroke-width="1.5" opacity="0.3"/>
</svg>
</div>
{{ partial "helpers/waves.html" (dict "variant" "footer") }}
<footer class="pt-6 pb-12" style="background-color: var(--color-dark);">
<div class="max-w-7xl mx-auto px-4 text-center">
{{/* The team is not in the main nav; keep /team/ reachable site-wide. */}}
Expand Down
22 changes: 22 additions & 0 deletions themes/capro-tw/layouts/partials/helpers/waves.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- /* Drifting hairline waves. Takes a dict {variant}.

Path data, drift and shift come from data/waves.yaml; see its header for
why the three have to change together. tools/check-waves.mjs enforces it. */ -}}
{{- $variant := .variant | default "" -}}
{{- $sets := dict
"banner" (slice 1 3 4)
"footer" (slice 1 2 3 4 5)
-}}
{{- $keys := index $sets $variant -}}
{{- if not $keys -}}
{{- $names := slice -}}
{{- range $name, $_ := $sets -}}{{- $names = $names | append $name -}}{{- end -}}
{{- errorf "waves.html: unknown variant %q (expected one of %s)" $variant (delimit $names ", ") -}}
{{- end -}}
<div class="waves waves--{{ $variant }}" aria-hidden="true">
<svg viewBox="0 0 1440 120" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg">
{{- range where hugo.Data.waves.layers "key" "in" $keys }}
<path class="wave wave--{{ .key }}" d="{{ .d }}" fill="none" />
{{- end }}
</svg>
</div>
8 changes: 1 addition & 7 deletions themes/capro-tw/layouts/partials/sections/banner.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ <h1 class="text-4xl md:text-6xl font-light mb-8">{{ .title | markdownify }}</h1>
</div>
</div>
</section>
<div class="absolute bottom-0 left-0 right-0 h-24 z-10 pointer-events-none" aria-hidden="true">
<svg viewBox="0 0 1440 96" preserveAspectRatio="none" class="w-full h-full" xmlns="http://www.w3.org/2000/svg">
<path d="M0,70 C240,20 480,80 720,40 C960,0 1200,60 1440,30" fill="none" stroke="#c04545" stroke-width="2" opacity="0.5"/>
<path d="M0,50 C200,80 440,10 720,60 C1000,110 1240,30 1440,50" fill="none" stroke="#E57575" stroke-width="2" opacity="0.4"/>
<path d="M0,85 C300,50 500,90 720,55 C940,20 1140,70 1440,45" fill="none" stroke="#c04545" stroke-width="2.5" opacity="0.6"/>
</svg>
</div>
{{ partial "helpers/waves.html" (dict "variant" "banner") }}
</div>
{{ end }}
28 changes: 0 additions & 28 deletions themes/capro-tw/layouts/partials/sections/cta.html

This file was deleted.

2 changes: 2 additions & 0 deletions themes/capro-tw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"setup": "mkdir -p assets/css/vendor assets/js/vendor static/webfonts/google-fonts/space-grotesk static/webfonts/google-fonts/spectral",
"build": "npm run clean && npm run setup && npm run build:css && npm run sync:deps",
"build:css": "npx @tailwindcss/cli -i assets/css/main.css -o assets/css/vendor/tailwind.css --minify",
"gen:waves": "node tools/gen-waves.mjs",
"check:waves": "node tools/check-waves.mjs",
"sync:deps": "npm run sync:alpine && npm run sync:leaflet && npm run sync:icons && npm run sync:fonts",
"sync:alpine": "cp node_modules/alpinejs/dist/cdn.min.js assets/js/vendor/alpine.min.js",
"sync:leaflet": "cp node_modules/leaflet/dist/leaflet.js assets/js/vendor/leaflet.js && cp node_modules/leaflet/dist/leaflet.css assets/css/vendor/leaflet.css && mkdir -p static/webfonts/leaflet && cp node_modules/leaflet/dist/images/* static/webfonts/leaflet/",
Expand Down
Loading
Loading