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
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: build

on:
Expand Down Expand Up @@ -38,6 +38,11 @@
- name: Format, lint and type-check
run: vp run check

# Mzizi's tokens.css is copied from the registry at a pinned commit
# (issue 153); this fails if the copy was edited or no longer matches.
- name: Mzizi tokens match the registry
run: vpx scripts/sync-mzizi-css.mjs --check

# `vp run test` builds the site (Astro, bundled by Vite+'s Vite), runs
# the tests (vp test), and then verifies that every inline script in
# the build is covered by the CSP hash allowlist in public/_headers — so
Expand Down
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ pnpm-lock.yaml
#
# These files are still type-checked by `npm run check` (astro check).
*.astro

# Mzizi's tokens.css, copied byte for byte from the registry by
# scripts/sync-mzizi-css.mjs (issue 153). vite.config.ts's fmt block skips it too.
src/styles/mzizi/
22 changes: 21 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import { defineConfig } from "astro/config";
import sitemap from "@astrojs/sitemap";
import tailwindcss from "@tailwindcss/vite";

/* Mzizi's browser floor (mzizi-css, mzizi-dev/mzizi-registry): the first
versions with color-mix(), nesting and :is(). Lightning CSS encodes a
version as major << 16 | minor << 8. */
const MZIZI_TARGETS = {
chrome: 111 << 16,
edge: 111 << 16,
firefox: 113 << 16,
safari: (16 << 16) | (2 << 8),
};

export default defineConfig({
site: "https://learning.nyuchi.com",
/* Astro's HTML compression drops the space where a line break sits between
Expand Down Expand Up @@ -40,5 +50,15 @@ export default defineConfig({
},
}),
],
vite: { plugins: [tailwindcss()] },
vite: {
plugins: [tailwindcss()],
/* Lightning CSS (issue 153), as Mzizi builds its stylesheets: it
transforms and minifies the site's CSS, lowering nesting and
color-mix() for Mzizi's browser floor. */
css: {
transformer: "lightningcss",
lightningcss: { targets: MZIZI_TARGETS },
},
build: { cssMinify: "lightningcss" },
},
});
33 changes: 33 additions & 0 deletions docs/toolchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,39 @@ that this repo does not control.
Astro does not read `vite.config.ts`; it takes its Vite settings from
`astro.config.mjs`. The override is what puts it on Vite+'s Vite.

## CSS: Lightning CSS and Mzizi's tokens.css

Mzizi builds its CSS with Lightning CSS, which works with Rust where Tailwind
does not, around `tokens.css` (values only) and `floor.css` (accessibility
minimums). This site is moving the same way (issue 153), in steps:

1. **Done.** Vite+'s CSS pipeline runs on Lightning CSS (`css.transformer`
and `build.cssMinify` in `astro.config.mjs`), targeting Mzizi's browser
floor: Chrome and Edge 111, Firefox 113, Safari 16.2.
2. **Done.** Mzizi's `tokens.css` is in `src/styles/mzizi/`, copied from
`mzizi-dev/mzizi-registry` at a pinned commit by
`vpx scripts/sync-mzizi-css.mjs`. CI checks the copy with `--check`. It is
imported into the lowest cascade layer, so it changes no value the site
already sets: a browser comparison of every page, in light and dark, at
phone and desktop width, found no change. It adds Mzizi's tokens the kit
does not have, such as `--measure` and `--ring-width`.
3. **In progress.** Pages and components move from Tailwind utilities to
plain CSS that reads the tokens, one at a time, each checked with
`vp run qa` and a screenshot comparison. Done: the accessibility statement
(`src/styles/site/document.css`, which the legal pages will share).
`src/styles/site/tokens.css` holds the few values Mzizi's tokens do not
have (this site's fluid heading sizes and their letter-spacing), and
`tests/plain-css.test.ts` keeps a converted page off utility classes and
its stylesheet on tokens.
`floor.css` comes in with the first page on Mzizi's `data-slot` pattern.
Loaded now, it would size `@bundu/ui`'s buttons by the kit's 49px floor,
not Mzizi's.
4. Last: Tailwind, `@tailwindcss/vite`, the typography plugin and
`tailwind.config.mjs` go.

When Mzizi publishes the pattern stylesheets in a package, it replaces the
copy and the sync script.

## Two formatters

Prettier and Vite+'s formatter (Oxfmt, through `vp fmt`) both format this
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@tailwindcss/vite": "^4.1.18",
"@types/node": "^24.10.0",
"axe-core": "^4.12.1",
"lightningcss": "^1.33.0",
"playwright": "^1.63.0",
"prettier": "3.3.3",
"tailwindcss": "^4.1.18",
Expand Down
Binary file added public/brand/og.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions scripts/og-image.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env node
/**
* The share image (issue 161): public/brand/og.jpg, 1200 by 630, the size
* LinkedIn, WhatsApp, X and Slack show beside a shared link.
*
* It is a still of the Bundu scene (src/scripts/bundu-scene.js, issue 160) at
* golden hour, with the wordmark and the home page's statement. The image is
* committed; run this again only when the scene or the statement changes:
*
* vpx scripts/og-image.mjs
*
* It loads the site's fonts from Google Fonts, so it needs the network.
*/
import { readFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { chromium } from "playwright";
import { findChromium } from "./lib/browser.mjs";

const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const scene = readFileSync(
join(root, "src/scripts/bundu-scene.js"),
"utf8",
).replace("export function mountBunduScene", "function mountBunduScene");
const bee = readFileSync(
join(root, "public/brand/nyuchi-bee-light.png"),
).toString("base64");

const html = `<!doctype html><meta charset="utf-8">
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif:wght@400;600&family=Noto+Sans:wght@400;500&display=swap" rel="stylesheet">
<style>
html, body { margin: 0; }
#card { position: relative; width: 1200px; height: 630px; overflow: hidden; background: #f4f3f0; color: #1a1917; font-family: "Noto Sans", sans-serif; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; --scene-accent: #ffd740;
-webkit-mask-image: linear-gradient(to right, transparent 20%, #000 58%); mask-image: linear-gradient(to right, transparent 20%, #000 58%); }
.text { position: absolute; left: 64px; top: 56px; width: 600px; }
.brand { display: flex; align-items: center; gap: 14px; font: 600 30px/1 "Noto Serif", serif; }
.brand img { width: 40px; height: 40px; }
h1 { margin: 64px 0 0; font: 400 66px/1.08 "Noto Serif", serif; letter-spacing: -0.02em; }
p { margin: 28px 0 0; max-width: 500px; font-size: 27px; line-height: 1.4; color: #55534f; }
.url { position: absolute; left: 64px; bottom: 48px; font-size: 22px; font-weight: 500; color: #5d4037; }
</style>
<div id="card">
<canvas id="scene"></canvas>
<div class="text">
<div class="brand"><img src="data:image/png;base64,${bee}" alt="">Nyuchi Learning</div>
<h1>Built for your school, not for every school.</h1>
<p>Open tools for schools, built to open standards and handed over.</p>
</div>
<div class="url">learning.nyuchi.com</div>
</div>`;

const browser = await chromium.launch({ executablePath: findChromium() });
const page = await browser.newPage({
viewport: { width: 1200, height: 630 },
deviceScaleFactor: 1,
});
await page.setContent(html, { waitUntil: "networkidle" });
await page.addScriptTag({ content: scene });
await page.evaluate(() => {
// eslint-disable-next-line no-undef -- defined by the script tag above
mountBunduScene(
document.getElementById("scene"),
document.getElementById("card"),
{ time: "golden" },
).setPaused(true);
});
await page.waitForTimeout(1200);
const out = join(root, "public/brand/og.jpg");
await page
.locator("#card")
.screenshot({ path: out, type: "jpeg", quality: 88 });
await browser.close();
console.log(`wrote ${out}`);
8 changes: 5 additions & 3 deletions scripts/qa.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ for (const scheme of ["light", "dark"]) {
* claim the privacy policy makes and the one worth a browser to check.
*
* Everything else third-party must be on the approved list. Google Fonts
* and Google Analytics are there because a commit put them there; anything
* else arriving is the regression this exists to catch.
* and Google Analytics are there because a commit put them there, and
* Cloudflare Web Analytics' cookieless beacon (issue 157), which the CSP
* and the privacy policy already name; anything else arriving is the
* regression this exists to catch.
*
* Google Analytics loads only after consent, which this run never gives;
* scripts/probe-consent.mjs is what asserts that. Either way, analytics
* is not a licence for the messenger to load, which is why these are two
* assertions rather than one "no third parties". */
const APPROVED =
/(^|\.)(googleapis|gstatic|googletagmanager|google-analytics)\.com$|(^|\.)analytics\.google\.com$/;
/(^|\.)(googleapis|gstatic|googletagmanager|google-analytics|cloudflareinsights)\.com$|(^|\.)analytics\.google\.com$/;
const unapproved = [];
const intercomBeforeClick = [];
page.on("request", (request) => {
Expand Down
81 changes: 81 additions & 0 deletions scripts/sync-mzizi-css.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env node
/**
* Mzizi's pattern stylesheets, copied in from the registry (issue 153).
*
* Mzizi moved its CSS to Lightning CSS and plain stylesheets built around
* `tokens.css` (values only) and `floor.css` (the accessibility minimums),
* in mzizi-dev/mzizi-registry's `styles/pattern/`. They are not in an npm
* package yet, so this site keeps a copy, pinned to one registry commit:
*
* src/styles/mzizi/tokens.css values only, light and dark
*
* Each copy starts with a header naming the commit and source path. The rest
* of the file is the registry's, byte for byte: nothing here edits a token.
* When Mzizi publishes these in a package, import the package and delete
* this script.
*
* vpx scripts/sync-mzizi-css.mjs fetch the pinned commit, write the copies
* vpx scripts/sync-mzizi-css.mjs --check fail if a copy differs from the pinned commit
*
* To move to a newer registry commit, change REF and run it without --check,
* then review the diff.
*/
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";

export const REPO = "mzizi-dev/mzizi-registry";
/** registry main, 2026-11-28 (tokens with the nine chrome tokens of 2026-11-22) */
export const REF = "292ecc8f775eaa189550e7bb3add4df40d527d22";
/* floor.css joins when the first page moves to Mzizi's data-slot pattern:
loaded now, it would size @bundu/ui's buttons by the kit's own floor
(49px), not Mzizi's, and change the look (issue 153). */
export const FILES = ["tokens.css"];

const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
export const OUT_DIR = join(root, "src", "styles", "mzizi");

/** The header written above the registry's own text. */
export const header = (file) =>
`/* Copied from ${REPO}@${REF}, styles/pattern/${file}.\n` +
` Do not edit: run \`vpx scripts/sync-mzizi-css.mjs\` (issue 153). */\n`;

async function fetchSource(file) {
const url = `https://raw.githubusercontent.com/${REPO}/${REF}/styles/pattern/${file}`;
const res = await fetch(url);
if (!res.ok) throw new Error(`${url}: HTTP ${res.status}`);
return res.text();
}

async function main() {
const check = process.argv.includes("--check");
mkdirSync(OUT_DIR, { recursive: true });
let stale = 0;
for (const file of FILES) {
const want = header(file) + (await fetchSource(file));
const path = join(OUT_DIR, file);
let have = "";
try {
have = readFileSync(path, "utf8");
} catch {
/* not written yet */
}
if (have === want) continue;
if (check) {
console.error(`${path} differs from ${REPO}@${REF.slice(0, 7)}`);
stale++;
} else {
writeFileSync(path, want);
console.log(`wrote ${path}`);
}
}
if (stale) {
console.error(
"Run `vpx scripts/sync-mzizi-css.mjs`, then review the diff.",
);
process.exit(1);
}
if (check) console.log(`Mzizi stylesheets match ${REF.slice(0, 7)}`);
}

if (process.argv[1] === fileURLToPath(import.meta.url)) await main();
31 changes: 31 additions & 0 deletions src/components/BunduScene.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
/**
* The Bundu scene behind a hero (issue 160). Put it first inside the element
* it should fill, and mark that element data-bundu-host (it must be
* positioned, and clip its overflow). The scene is decoration: the canvas is
* hidden from assistive technology, and the button pauses it (WCAG 2.2.2).
* The painting is src/scripts/bundu-scene.js; the look of the canvas and the
* button is the page's (src/styles/site/home.css).
*/
---

<canvas class="bundu-scene" data-bundu-scene aria-hidden="true"></canvas>
<button class="bundu-scene-toggle" type="button" data-bundu-toggle aria-pressed="false">Pause animation</button>

<script>
import { mountBunduScene } from "../scripts/bundu-scene.js";

for (const canvas of document.querySelectorAll("[data-bundu-scene]")) {
const host = canvas.closest("[data-bundu-host]");
if (!host) continue;
const scene = mountBunduScene(canvas, host);
const toggle = host.querySelector("[data-bundu-toggle]");
let paused = false;
toggle?.addEventListener("click", () => {
paused = !paused;
toggle.setAttribute("aria-pressed", String(paused));
toggle.textContent = paused ? "Play animation" : "Pause animation";
scene.setPaused(paused);
});
}
</script>
17 changes: 11 additions & 6 deletions src/components/SiteHeader.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
* a single hairline border, and a 64/80px row.
*
* The right-hand side carries the page's one primary call to action (by
* default, installing the extension: it is the product most visitors can act
* on today), with "Talk to us" beside it as the quieter link from `xl` up.
* default, working with Nyuchi Learning, which is what the site is for:
* issue 158), with "Talk to us" beside it as the quieter link from
* `xl` up when the action goes elsewhere. A product's own pages pass their
* own action (the extension's pages, "Add to Chrome").
*/
import Wordmark from "./Wordmark.astro";
import { headerCta, primaryNav, toddleExtension, type HeaderAction } from "../data/site";
import { headerCta, primaryNav, type HeaderAction } from "../data/site";

interface Props {
action?: HeaderAction;
}

const defaultAction: HeaderAction = toddleExtension.webStore
? { label: "Add to Chrome", short: "Install", href: toddleExtension.webStore, external: true }
: { label: "Talk to us", href: toddleExtension.enquiry };
const defaultAction: HeaderAction = {
label: "Work with us",
short: "Contact",
href: headerCta.href,
external: headerCta.external,
};
const { action = defaultAction } = Astro.props;

const { pathname } = Astro.url;
Expand Down
Loading
Loading