Hero uit het CMS, verschuivingsfix, productie alleen vanaf release-branch #18

Merged
Sluijsens merged 8 commits from feature/hero-module into master 2026-11-17 12:58:07 +01:00
4 changed files with 49 additions and 1 deletions
Showing only changes of commit d6a3acdd47 - Show all commits
+15
View File
@@ -45,6 +45,21 @@
}
</script>
<!--SLP:OFFERINGS-JSON-LD-->
<!-- The host may inject a crawler-readable packages list above #root (removed by main.tsx at start-up).
Take it out of the layout so that removing it does not shift the page (CLS). -->
<style>
#packages-static {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
</style>
<!--CMS:HERO-PRELOAD--><!--/CMS:HERO-PRELOAD-->
<!--CMS:DATA-->
<script type="application/json" id="cms-data">
+8
View File
@@ -2,6 +2,14 @@
@tailwind components;
@tailwind utilities;
/* Metric-compatible stand-in for JetBrains Mono while it loads (both have an advance of 0.6em), so the code
line of the hero does not re-wrap and shift the page when the real font arrives (CLS). */
@font-face {
font-family: 'JetBrains Mono Fallback';
src: local('Courier New'), local('Liberation Mono'), local('Cousine');
font-display: swap;
}
/* Theme tokens: variant (b | e) x mode (light | dark), selected by <html data-variant data-mode>
(set before first paint by public/theme-init.js and kept in sync by ThemeProvider).
Semantic names stay the same so the Tailwind colors in tailwind.config.ts keep working.
+25
View File
@@ -0,0 +1,25 @@
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
const root = resolve(__dirname, '../..');
const read = (file: string) => readFileSync(resolve(root, file), 'utf8');
/**
* Guards against layout shifts (CLS) at start-up: the static packages list that the CMS host may inject above #root
* is removed by main.tsx, so it must not take any space, and the code line needs a metric-compatible font fallback.
*/
describe('layout stability at start-up', () => {
it('takes the injected #packages-static list out of the layout in index.html', () => {
const html = read('index.html');
const rule = html.match(/#packages-static\s*\{([^}]*)\}/);
expect(rule).not.toBeNull();
expect(rule?.[1]).toMatch(/position:\s*absolute/);
expect(rule?.[1]).toMatch(/clip:/);
});
it('gives the mono font a metric-compatible fallback', () => {
expect(read('src/index.css')).toMatch(/font-family:\s*'JetBrains Mono Fallback'/);
expect(read('tailwind.config.ts')).toMatch(/'JetBrains Mono',\s*'JetBrains Mono Fallback'/);
});
});
+1 -1
View File
@@ -29,7 +29,7 @@ export default {
// `[font-stretch:125%]` for the wide display type.
sans: ['Archivo Variable', 'system-ui', 'sans-serif'],
display: ['Archivo Variable', 'system-ui', 'sans-serif'],
mono: ['JetBrains Mono', 'monospace'],
mono: ['JetBrains Mono', 'JetBrains Mono Fallback', 'monospace'],
archivo: ['Archivo Variable', 'system-ui', 'sans-serif'],
},
borderRadius: {