From 70d7bd91aa3fadd7031d9cc3388f3ffb601727b9 Mon Sep 17 00:00:00 2001 From: TheMeinerLP Date: Wed, 25 Nov 2026 10:08:45 +0100 Subject: [PATCH] refactor(web): build the ui on the pavo material 3 library Grus carried its own copy of the Material 3 kit (components, tokens, theme composable, icon setup). The shared library @onelitefeathernet/pavo now provides these, so the web UI depends on it instead of maintaining the copy. Fixes and new components arrive by updating one dependency. The local kit, its token generator and the Roboto font packages are removed. Pages use the Pavo components and M3AppFrame for the shell. Grus registers its own icon set with the Pavo icon registry. The Dockerfile reads the GitHub Packages token from a BuildKit secret, which is not written into any image layer. The theme storage key moves to pavo.theme, so a stored theme choice resets once. --- .github/workflows/web.yml | 3 + web/.npmrc | 2 + web/Dockerfile | 9 +- web/app/assets/css/m3-tokens.css | 248 --------------------------- web/app/assets/css/main.css | 203 +--------------------- web/app/components/AppProblem.vue | 35 ---- web/app/components/ConfirmDialog.vue | 47 ----- web/app/components/PageHeader.vue | 16 -- web/app/components/StatusChip.vue | 4 +- web/app/components/m3/Alert.vue | 32 ---- web/app/components/m3/Button.vue | 77 --------- web/app/components/m3/Card.vue | 32 ---- web/app/components/m3/Chip.vue | 50 ------ web/app/components/m3/Dialog.vue | 79 --------- web/app/components/m3/EmptyState.vue | 13 -- web/app/components/m3/Icon.vue | 20 --- web/app/components/m3/IconButton.vue | 44 ----- web/app/components/m3/NavDrawer.vue | 71 -------- web/app/components/m3/NavItem.vue | 25 --- web/app/components/m3/Progress.vue | 31 ---- web/app/components/m3/Snackbar.vue | 23 --- web/app/components/m3/TopAppBar.vue | 7 - web/app/components/m3/types.ts | 5 - web/app/composables/useColorTheme.ts | 44 ----- web/app/composables/useMediaQuery.ts | 18 -- web/app/composables/useSnackbar.ts | 18 -- web/app/layouts/default.vue | 76 +------- web/app/lib/icons.ts | 50 ------ web/app/lib/problem.test.ts | 93 ---------- web/app/lib/problem.ts | 118 ++----------- web/app/lib/theme.test.ts | 19 -- web/app/lib/theme.ts | 12 -- web/app/pages/events/index.vue | 4 +- web/app/pages/index.vue | 6 +- web/app/pages/instances/[id].vue | 16 +- web/app/pages/instances/index.vue | 6 +- web/app/pages/pools/[pool].vue | 14 +- web/app/pages/pools/index.vue | 6 +- web/app/pages/templates/index.vue | 6 +- web/app/plugins/icons.ts | 55 ++++++ web/i18n/locales/de/common.json | 14 -- web/i18n/locales/en/common.json | 14 -- web/nuxt.config.ts | 10 +- web/package.json | 4 +- web/pnpm-lock.yaml | 36 +++- web/scripts/m3-tokens.mjs | 74 -------- 46 files changed, 150 insertions(+), 1639 deletions(-) create mode 100644 web/.npmrc delete mode 100644 web/app/assets/css/m3-tokens.css delete mode 100644 web/app/components/AppProblem.vue delete mode 100644 web/app/components/ConfirmDialog.vue delete mode 100644 web/app/components/PageHeader.vue delete mode 100644 web/app/components/m3/Alert.vue delete mode 100644 web/app/components/m3/Button.vue delete mode 100644 web/app/components/m3/Card.vue delete mode 100644 web/app/components/m3/Chip.vue delete mode 100644 web/app/components/m3/Dialog.vue delete mode 100644 web/app/components/m3/EmptyState.vue delete mode 100644 web/app/components/m3/Icon.vue delete mode 100644 web/app/components/m3/IconButton.vue delete mode 100644 web/app/components/m3/NavDrawer.vue delete mode 100644 web/app/components/m3/NavItem.vue delete mode 100644 web/app/components/m3/Progress.vue delete mode 100644 web/app/components/m3/Snackbar.vue delete mode 100644 web/app/components/m3/TopAppBar.vue delete mode 100644 web/app/components/m3/types.ts delete mode 100644 web/app/composables/useColorTheme.ts delete mode 100644 web/app/composables/useMediaQuery.ts delete mode 100644 web/app/composables/useSnackbar.ts delete mode 100644 web/app/lib/icons.ts delete mode 100644 web/app/lib/problem.test.ts delete mode 100644 web/app/lib/theme.test.ts delete mode 100644 web/app/lib/theme.ts create mode 100644 web/app/plugins/icons.ts delete mode 100644 web/scripts/m3-tokens.mjs diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index 59ec5b1..e62e745 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -18,6 +18,7 @@ on: permissions: contents: read + packages: read concurrency: group: web-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -50,6 +51,8 @@ jobs: cache-dependency-path: web/pnpm-lock.yaml - name: Install dependencies + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: pnpm install --frozen-lockfile - name: Lint diff --git a/web/.npmrc b/web/.npmrc new file mode 100644 index 0000000..813d648 --- /dev/null +++ b/web/.npmrc @@ -0,0 +1,2 @@ +@onelitefeathernet:registry=https://npm.pkg.github.com +//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN} diff --git a/web/Dockerfile b/web/Dockerfile index dca119e..a3b0f25 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,14 +1,17 @@ +# syntax=docker/dockerfile:1 # Grus web UI: Nuxt node-server build (BFF plus SPA) on a distroless Node runtime. # Build from the repository root, so the image is built from the same context as the controller: -# docker build -f web/Dockerfile -t grus-web . +# docker build --secret id=npm_token,env=NODE_AUTH_TOKEN -f web/Dockerfile -t grus-web . +# The build needs the secret `npm_token`: a token with read:packages, to install @onelitefeathernet/pavo from +# GitHub Packages. It is mounted for the install step only and never written into an image layer. # Runtime settings come from the environment (NUXT_GRUS_API_URL, NUXT_GRUS_TOKEN), nothing is baked in. FROM node:24-alpine AS build WORKDIR /app RUN corepack enable -COPY web/package.json web/pnpm-lock.yaml web/pnpm-workspace.yaml ./ +COPY web/package.json web/pnpm-lock.yaml web/pnpm-workspace.yaml web/.npmrc ./ # `nuxt prepare` (postinstall) needs the sources, so install without scripts first. -RUN pnpm install --frozen-lockfile --ignore-scripts +RUN --mount=type=secret,id=npm_token,env=NODE_AUTH_TOKEN pnpm install --frozen-lockfile --ignore-scripts COPY web/ ./ RUN pnpm exec nuxt prepare && pnpm build diff --git a/web/app/assets/css/m3-tokens.css b/web/app/assets/css/m3-tokens.css deleted file mode 100644 index 6cbe532..0000000 --- a/web/app/assets/css/m3-tokens.css +++ /dev/null @@ -1,248 +0,0 @@ -/* Generated by scripts/m3-tokens.mjs from seed #114cc8 (Vibrant). Do not edit; run `pnpm tokens`. */ - -:root { - color-scheme: light; - --md-sys-color-background: #faf8ff; - --md-sys-color-on-background: #191b25; - --md-sys-color-surface: #faf8ff; - --md-sys-color-surface-dim: #d8d9e7; - --md-sys-color-surface-bright: #faf8ff; - --md-sys-color-surface-container-lowest: #ffffff; - --md-sys-color-surface-container-low: #f3f3ff; - --md-sys-color-surface-container: #ecedfb; - --md-sys-color-surface-container-high: #e6e7f5; - --md-sys-color-surface-container-highest: #e1e1ef; - --md-sys-color-on-surface: #191b25; - --md-sys-color-surface-variant: #e0e1f2; - --md-sys-color-on-surface-variant: #434654; - --md-sys-color-inverse-surface: #2e303a; - --md-sys-color-inverse-on-surface: #eff0fe; - --md-sys-color-outline: #747685; - --md-sys-color-outline-variant: #c3c5d6; - --md-sys-color-shadow: #000000; - --md-sys-color-scrim: #000000; - --md-sys-color-surface-tint: #0051df; - --md-sys-color-primary: #0051df; - --md-sys-color-on-primary: #ffffff; - --md-sys-color-primary-container: #dbe1ff; - --md-sys-color-on-primary-container: #003dab; - --md-sys-color-inverse-primary: #b5c4ff; - --md-sys-color-secondary: #5d5b7d; - --md-sys-color-on-secondary: #ffffff; - --md-sys-color-secondary-container: #e3dfff; - --md-sys-color-on-secondary-container: #454364; - --md-sys-color-tertiary: #675687; - --md-sys-color-on-tertiary: #ffffff; - --md-sys-color-tertiary-container: #ebdcff; - --md-sys-color-on-tertiary-container: #4f3e6e; - --md-sys-color-error: #ba1a1a; - --md-sys-color-on-error: #ffffff; - --md-sys-color-error-container: #ffdad6; - --md-sys-color-on-error-container: #93000a; - --md-sys-color-primary-fixed: #dbe1ff; - --md-sys-color-primary-fixed-dim: #b5c4ff; - --md-sys-color-on-primary-fixed: #00174d; - --md-sys-color-on-primary-fixed-variant: #003dab; - --md-sys-color-secondary-fixed: #e3dfff; - --md-sys-color-secondary-fixed-dim: #c6c2ea; - --md-sys-color-on-secondary-fixed: #191836; - --md-sys-color-on-secondary-fixed-variant: #454364; - --md-sys-color-tertiary-fixed: #ebdcff; - --md-sys-color-tertiary-fixed-dim: #d2bdf5; - --md-sys-color-on-tertiary-fixed: #22123f; - --md-sys-color-on-tertiary-fixed-variant: #4f3e6e; - --md-sys-color-success: #006e2a; - --md-sys-color-on-success: #ffffff; - --md-sys-color-success-container: #6aff87; - --md-sys-color-on-success-container: #002107; - --md-sys-color-warning: #725c00; - --md-sys-color-on-warning: #ffffff; - --md-sys-color-warning-container: #ffe082; - --md-sys-color-on-warning-container: #231b00; -} - -/* Dark scheme: the system preference, unless the user picked a theme explicitly. */ -@media (prefers-color-scheme: dark) { - :root:not([data-theme="light"]) { - color-scheme: dark; - --md-sys-color-background: #10131c; - --md-sys-color-on-background: #e1e1ef; - --md-sys-color-surface: #10131c; - --md-sys-color-surface-dim: #10131c; - --md-sys-color-surface-bright: #363943; - --md-sys-color-surface-container-lowest: #0b0e17; - --md-sys-color-surface-container-low: #191b25; - --md-sys-color-surface-container: #1d1f29; - --md-sys-color-surface-container-high: #272a34; - --md-sys-color-surface-container-highest: #32343f; - --md-sys-color-on-surface: #e1e1ef; - --md-sys-color-surface-variant: #434654; - --md-sys-color-on-surface-variant: #c3c5d6; - --md-sys-color-inverse-surface: #e1e1ef; - --md-sys-color-inverse-on-surface: #2e303a; - --md-sys-color-outline: #8d909f; - --md-sys-color-outline-variant: #434654; - --md-sys-color-shadow: #000000; - --md-sys-color-scrim: #000000; - --md-sys-color-surface-tint: #b5c4ff; - --md-sys-color-primary: #b5c4ff; - --md-sys-color-on-primary: #00297a; - --md-sys-color-primary-container: #003dab; - --md-sys-color-on-primary-container: #dbe1ff; - --md-sys-color-inverse-primary: #0051df; - --md-sys-color-secondary: #c6c2ea; - --md-sys-color-on-secondary: #2e2d4d; - --md-sys-color-secondary-container: #454364; - --md-sys-color-on-secondary-container: #e3dfff; - --md-sys-color-tertiary: #d2bdf5; - --md-sys-color-on-tertiary: #382856; - --md-sys-color-tertiary-container: #4f3e6e; - --md-sys-color-on-tertiary-container: #ebdcff; - --md-sys-color-error: #ffb4ab; - --md-sys-color-on-error: #690005; - --md-sys-color-error-container: #93000a; - --md-sys-color-on-error-container: #ffdad6; - --md-sys-color-primary-fixed: #dbe1ff; - --md-sys-color-primary-fixed-dim: #b5c4ff; - --md-sys-color-on-primary-fixed: #00174d; - --md-sys-color-on-primary-fixed-variant: #003dab; - --md-sys-color-secondary-fixed: #e3dfff; - --md-sys-color-secondary-fixed-dim: #c6c2ea; - --md-sys-color-on-secondary-fixed: #191836; - --md-sys-color-on-secondary-fixed-variant: #454364; - --md-sys-color-tertiary-fixed: #ebdcff; - --md-sys-color-tertiary-fixed-dim: #d2bdf5; - --md-sys-color-on-tertiary-fixed: #22123f; - --md-sys-color-on-tertiary-fixed-variant: #4f3e6e; - --md-sys-color-success: #45e26c; - --md-sys-color-on-success: #003912; - --md-sys-color-success-container: #00531d; - --md-sys-color-on-success-container: #6aff87; - --md-sys-color-warning: #ecc222; - --md-sys-color-on-warning: #3c2f00; - --md-sys-color-warning-container: #564500; - --md-sys-color-on-warning-container: #ffe082; - } -} - -:root[data-theme="dark"] { - color-scheme: dark; - --md-sys-color-background: #10131c; - --md-sys-color-on-background: #e1e1ef; - --md-sys-color-surface: #10131c; - --md-sys-color-surface-dim: #10131c; - --md-sys-color-surface-bright: #363943; - --md-sys-color-surface-container-lowest: #0b0e17; - --md-sys-color-surface-container-low: #191b25; - --md-sys-color-surface-container: #1d1f29; - --md-sys-color-surface-container-high: #272a34; - --md-sys-color-surface-container-highest: #32343f; - --md-sys-color-on-surface: #e1e1ef; - --md-sys-color-surface-variant: #434654; - --md-sys-color-on-surface-variant: #c3c5d6; - --md-sys-color-inverse-surface: #e1e1ef; - --md-sys-color-inverse-on-surface: #2e303a; - --md-sys-color-outline: #8d909f; - --md-sys-color-outline-variant: #434654; - --md-sys-color-shadow: #000000; - --md-sys-color-scrim: #000000; - --md-sys-color-surface-tint: #b5c4ff; - --md-sys-color-primary: #b5c4ff; - --md-sys-color-on-primary: #00297a; - --md-sys-color-primary-container: #003dab; - --md-sys-color-on-primary-container: #dbe1ff; - --md-sys-color-inverse-primary: #0051df; - --md-sys-color-secondary: #c6c2ea; - --md-sys-color-on-secondary: #2e2d4d; - --md-sys-color-secondary-container: #454364; - --md-sys-color-on-secondary-container: #e3dfff; - --md-sys-color-tertiary: #d2bdf5; - --md-sys-color-on-tertiary: #382856; - --md-sys-color-tertiary-container: #4f3e6e; - --md-sys-color-on-tertiary-container: #ebdcff; - --md-sys-color-error: #ffb4ab; - --md-sys-color-on-error: #690005; - --md-sys-color-error-container: #93000a; - --md-sys-color-on-error-container: #ffdad6; - --md-sys-color-primary-fixed: #dbe1ff; - --md-sys-color-primary-fixed-dim: #b5c4ff; - --md-sys-color-on-primary-fixed: #00174d; - --md-sys-color-on-primary-fixed-variant: #003dab; - --md-sys-color-secondary-fixed: #e3dfff; - --md-sys-color-secondary-fixed-dim: #c6c2ea; - --md-sys-color-on-secondary-fixed: #191836; - --md-sys-color-on-secondary-fixed-variant: #454364; - --md-sys-color-tertiary-fixed: #ebdcff; - --md-sys-color-tertiary-fixed-dim: #d2bdf5; - --md-sys-color-on-tertiary-fixed: #22123f; - --md-sys-color-on-tertiary-fixed-variant: #4f3e6e; - --md-sys-color-success: #45e26c; - --md-sys-color-on-success: #003912; - --md-sys-color-success-container: #00531d; - --md-sys-color-on-success-container: #6aff87; - --md-sys-color-warning: #ecc222; - --md-sys-color-on-warning: #3c2f00; - --md-sys-color-warning-container: #564500; - --md-sys-color-on-warning-container: #ffe082; -} - -/* Tailwind utilities: bg-primary, text-on-surface, border-outline-variant, ... */ -@theme inline { - --color-background: var(--md-sys-color-background); - --color-on-background: var(--md-sys-color-on-background); - --color-surface: var(--md-sys-color-surface); - --color-surface-dim: var(--md-sys-color-surface-dim); - --color-surface-bright: var(--md-sys-color-surface-bright); - --color-surface-container-lowest: var(--md-sys-color-surface-container-lowest); - --color-surface-container-low: var(--md-sys-color-surface-container-low); - --color-surface-container: var(--md-sys-color-surface-container); - --color-surface-container-high: var(--md-sys-color-surface-container-high); - --color-surface-container-highest: var(--md-sys-color-surface-container-highest); - --color-on-surface: var(--md-sys-color-on-surface); - --color-surface-variant: var(--md-sys-color-surface-variant); - --color-on-surface-variant: var(--md-sys-color-on-surface-variant); - --color-inverse-surface: var(--md-sys-color-inverse-surface); - --color-inverse-on-surface: var(--md-sys-color-inverse-on-surface); - --color-outline: var(--md-sys-color-outline); - --color-outline-variant: var(--md-sys-color-outline-variant); - --color-shadow: var(--md-sys-color-shadow); - --color-scrim: var(--md-sys-color-scrim); - --color-surface-tint: var(--md-sys-color-surface-tint); - --color-primary: var(--md-sys-color-primary); - --color-on-primary: var(--md-sys-color-on-primary); - --color-primary-container: var(--md-sys-color-primary-container); - --color-on-primary-container: var(--md-sys-color-on-primary-container); - --color-inverse-primary: var(--md-sys-color-inverse-primary); - --color-secondary: var(--md-sys-color-secondary); - --color-on-secondary: var(--md-sys-color-on-secondary); - --color-secondary-container: var(--md-sys-color-secondary-container); - --color-on-secondary-container: var(--md-sys-color-on-secondary-container); - --color-tertiary: var(--md-sys-color-tertiary); - --color-on-tertiary: var(--md-sys-color-on-tertiary); - --color-tertiary-container: var(--md-sys-color-tertiary-container); - --color-on-tertiary-container: var(--md-sys-color-on-tertiary-container); - --color-error: var(--md-sys-color-error); - --color-on-error: var(--md-sys-color-on-error); - --color-error-container: var(--md-sys-color-error-container); - --color-on-error-container: var(--md-sys-color-on-error-container); - --color-primary-fixed: var(--md-sys-color-primary-fixed); - --color-primary-fixed-dim: var(--md-sys-color-primary-fixed-dim); - --color-on-primary-fixed: var(--md-sys-color-on-primary-fixed); - --color-on-primary-fixed-variant: var(--md-sys-color-on-primary-fixed-variant); - --color-secondary-fixed: var(--md-sys-color-secondary-fixed); - --color-secondary-fixed-dim: var(--md-sys-color-secondary-fixed-dim); - --color-on-secondary-fixed: var(--md-sys-color-on-secondary-fixed); - --color-on-secondary-fixed-variant: var(--md-sys-color-on-secondary-fixed-variant); - --color-tertiary-fixed: var(--md-sys-color-tertiary-fixed); - --color-tertiary-fixed-dim: var(--md-sys-color-tertiary-fixed-dim); - --color-on-tertiary-fixed: var(--md-sys-color-on-tertiary-fixed); - --color-on-tertiary-fixed-variant: var(--md-sys-color-on-tertiary-fixed-variant); - --color-success: var(--md-sys-color-success); - --color-on-success: var(--md-sys-color-on-success); - --color-success-container: var(--md-sys-color-success-container); - --color-on-success-container: var(--md-sys-color-on-success-container); - --color-warning: var(--md-sys-color-warning); - --color-on-warning: var(--md-sys-color-on-warning); - --color-warning-container: var(--md-sys-color-warning-container); - --color-on-warning-container: var(--md-sys-color-on-warning-container); -} diff --git a/web/app/assets/css/main.css b/web/app/assets/css/main.css index 44b54eb..c852644 100644 --- a/web/app/assets/css/main.css +++ b/web/app/assets/css/main.css @@ -1,203 +1,2 @@ @import "tailwindcss"; -@import "./m3-tokens.css"; - -/* Fonts are self-hosted (@fontsource, imported in nuxt.config.ts); the CSP allows font-src 'self' only. */ -@theme { - --font-sans: 'Roboto', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif; - --font-mono: ui-monospace, 'Roboto Mono', SFMono-Regular, Menlo, Consolas, monospace; - - /* Material 3 type scale: size / line height / tracking / weight. */ - --text-display-large: 3.5625rem; - --text-display-large--line-height: 4rem; - --text-display-large--letter-spacing: -0.016em; - --text-display-large--font-weight: 400; - --text-display-medium: 2.8125rem; - --text-display-medium--line-height: 3.25rem; - --text-display-medium--letter-spacing: 0; - --text-display-medium--font-weight: 400; - --text-display-small: 2.25rem; - --text-display-small--line-height: 2.75rem; - --text-display-small--letter-spacing: 0; - --text-display-small--font-weight: 400; - --text-headline-large: 2rem; - --text-headline-large--line-height: 2.5rem; - --text-headline-large--letter-spacing: 0; - --text-headline-large--font-weight: 400; - --text-headline-medium: 1.75rem; - --text-headline-medium--line-height: 2.25rem; - --text-headline-medium--letter-spacing: 0; - --text-headline-medium--font-weight: 400; - --text-headline-small: 1.5rem; - --text-headline-small--line-height: 2rem; - --text-headline-small--letter-spacing: 0; - --text-headline-small--font-weight: 400; - --text-title-large: 1.375rem; - --text-title-large--line-height: 1.75rem; - --text-title-large--letter-spacing: 0; - --text-title-large--font-weight: 400; - --text-title-medium: 1rem; - --text-title-medium--line-height: 1.5rem; - --text-title-medium--letter-spacing: 0.009em; - --text-title-medium--font-weight: 500; - --text-title-small: 0.875rem; - --text-title-small--line-height: 1.25rem; - --text-title-small--letter-spacing: 0.007em; - --text-title-small--font-weight: 500; - --text-body-large: 1rem; - --text-body-large--line-height: 1.5rem; - --text-body-large--letter-spacing: 0.031em; - --text-body-large--font-weight: 400; - --text-body-medium: 0.875rem; - --text-body-medium--line-height: 1.25rem; - --text-body-medium--letter-spacing: 0.018em; - --text-body-medium--font-weight: 400; - --text-body-small: 0.75rem; - --text-body-small--line-height: 1rem; - --text-body-small--letter-spacing: 0.033em; - --text-body-small--font-weight: 400; - --text-label-large: 0.875rem; - --text-label-large--line-height: 1.25rem; - --text-label-large--letter-spacing: 0.007em; - --text-label-large--font-weight: 500; - --text-label-medium: 0.75rem; - --text-label-medium--line-height: 1rem; - --text-label-medium--letter-spacing: 0.042em; - --text-label-medium--font-weight: 500; - --text-label-small: 0.6875rem; - --text-label-small--line-height: 1rem; - --text-label-small--letter-spacing: 0.045em; - --text-label-small--font-weight: 500; - - /* Material 3 shape scale (corner radii): rounded-xs ... rounded-xl, rounded-full. */ - --radius-xs: 0.25rem; - --radius-sm: 0.5rem; - --radius-md: 0.75rem; - --radius-lg: 1rem; - --radius-xl: 1.75rem; - - /* Material 3 elevation levels 1 to 5 (key + ambient shadow). */ - --shadow-elevation-1: 0 1px 2px 0 rgb(0 0 0 / 0.3), 0 1px 3px 1px rgb(0 0 0 / 0.15); - --shadow-elevation-2: 0 1px 2px 0 rgb(0 0 0 / 0.3), 0 2px 6px 2px rgb(0 0 0 / 0.15); - --shadow-elevation-3: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 4px 8px 3px rgb(0 0 0 / 0.15); - --shadow-elevation-4: 0 2px 3px 0 rgb(0 0 0 / 0.3), 0 6px 10px 4px rgb(0 0 0 / 0.15); - --shadow-elevation-5: 0 4px 4px 0 rgb(0 0 0 / 0.3), 0 8px 12px 6px rgb(0 0 0 / 0.15); - - /* Material 3 motion. */ - --ease-emphasized: cubic-bezier(0.2, 0, 0, 1); - --ease-standard: cubic-bezier(0.2, 0, 0, 1); -} - -@layer base { - html { - font-family: var(--font-sans); - background: var(--md-sys-color-surface); - color: var(--md-sys-color-on-surface); - -webkit-text-size-adjust: 100%; - } - - body { - margin: 0; - min-height: 100vh; - overflow-x: hidden; - font-size: var(--text-body-large); - line-height: var(--text-body-large--line-height); - letter-spacing: var(--text-body-large--letter-spacing); - } - - /* Visible keyboard focus everywhere, in both themes (3px, 2px offset). */ - :focus-visible { - outline: 3px solid var(--md-sys-color-primary); - outline-offset: 2px; - } - - a { - color: var(--md-sys-color-primary); - text-underline-offset: 2px; - } - - button { - cursor: pointer; - } - - button:disabled { - cursor: default; - } - - h1, h2, h3, p, dl, dd, ul, ol, pre, figure { - margin: 0; - } - - ul, ol { - padding: 0; - } - - caption { - text-align: start; - } -} - -@layer components { - /* - * Material 3 state layer: a tint of the content colour over the container. - * hover 8%, focus 10%, pressed 10%. The host needs a border radius; the layer inherits it. - */ - .state-layer { - position: relative; - isolation: isolate; - } - - .state-layer::before { - content: ''; - position: absolute; - inset: 0; - z-index: -1; - border-radius: inherit; - background: currentColor; - opacity: 0; - pointer-events: none; - transition: opacity 150ms var(--ease-standard); - } - - .state-layer:hover:not(:disabled, [aria-disabled='true'])::before { - opacity: 0.08; - } - - .state-layer:focus-visible::before { - opacity: 0.1; - } - - .state-layer:active:not(:disabled, [aria-disabled='true'])::before { - opacity: 0.1; - } - - /* Monospace for identifiers (hashes, pseudonyms); applied to values, never to labels. */ - .mono { - font-family: var(--font-mono); - font-size: 0.875em; - word-break: break-all; - } - - .kv { - display: grid; - grid-template-columns: minmax(0, max-content) minmax(0, 1fr); - gap: 0.5rem 1.5rem; - } - - .kv dt { - color: var(--md-sys-color-on-surface-variant); - } - - .kv dd { - min-width: 0; - overflow-wrap: anywhere; - } -} - -@media (prefers-reduced-motion: reduce) { - *, - *::before, - *::after { - animation-duration: 0.01ms !important; - transition-duration: 0.01ms !important; - } -} +@import "@onelitefeathernet/pavo/css"; diff --git a/web/app/components/AppProblem.vue b/web/app/components/AppProblem.vue deleted file mode 100644 index 25ed162..0000000 --- a/web/app/components/AppProblem.vue +++ /dev/null @@ -1,35 +0,0 @@ - - - diff --git a/web/app/components/ConfirmDialog.vue b/web/app/components/ConfirmDialog.vue deleted file mode 100644 index e7cb620..0000000 --- a/web/app/components/ConfirmDialog.vue +++ /dev/null @@ -1,47 +0,0 @@ - - - diff --git a/web/app/components/PageHeader.vue b/web/app/components/PageHeader.vue deleted file mode 100644 index f16ffd9..0000000 --- a/web/app/components/PageHeader.vue +++ /dev/null @@ -1,16 +0,0 @@ - - - diff --git a/web/app/components/StatusChip.vue b/web/app/components/StatusChip.vue index 35b4770..2e128da 100644 --- a/web/app/components/StatusChip.vue +++ b/web/app/components/StatusChip.vue @@ -1,7 +1,5 @@ diff --git a/web/app/components/m3/Button.vue b/web/app/components/m3/Button.vue deleted file mode 100644 index 2dd08d8..0000000 --- a/web/app/components/m3/Button.vue +++ /dev/null @@ -1,77 +0,0 @@ - - - diff --git a/web/app/components/m3/Card.vue b/web/app/components/m3/Card.vue deleted file mode 100644 index 065a756..0000000 --- a/web/app/components/m3/Card.vue +++ /dev/null @@ -1,32 +0,0 @@ - - - diff --git a/web/app/components/m3/Chip.vue b/web/app/components/m3/Chip.vue deleted file mode 100644 index 8735aa3..0000000 --- a/web/app/components/m3/Chip.vue +++ /dev/null @@ -1,50 +0,0 @@ - - - diff --git a/web/app/components/m3/Dialog.vue b/web/app/components/m3/Dialog.vue deleted file mode 100644 index 5ccce24..0000000 --- a/web/app/components/m3/Dialog.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - diff --git a/web/app/components/m3/EmptyState.vue b/web/app/components/m3/EmptyState.vue deleted file mode 100644 index e6f2b3e..0000000 --- a/web/app/components/m3/EmptyState.vue +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/web/app/components/m3/Icon.vue b/web/app/components/m3/Icon.vue deleted file mode 100644 index 7dd46bc..0000000 --- a/web/app/components/m3/Icon.vue +++ /dev/null @@ -1,20 +0,0 @@ - - - diff --git a/web/app/components/m3/IconButton.vue b/web/app/components/m3/IconButton.vue deleted file mode 100644 index fc9da70..0000000 --- a/web/app/components/m3/IconButton.vue +++ /dev/null @@ -1,44 +0,0 @@ - - - diff --git a/web/app/components/m3/NavDrawer.vue b/web/app/components/m3/NavDrawer.vue deleted file mode 100644 index 97f4450..0000000 --- a/web/app/components/m3/NavDrawer.vue +++ /dev/null @@ -1,71 +0,0 @@ - - - diff --git a/web/app/components/m3/NavItem.vue b/web/app/components/m3/NavItem.vue deleted file mode 100644 index 77cff10..0000000 --- a/web/app/components/m3/NavItem.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/web/app/components/m3/Progress.vue b/web/app/components/m3/Progress.vue deleted file mode 100644 index 902bcfd..0000000 --- a/web/app/components/m3/Progress.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - - - diff --git a/web/app/components/m3/Snackbar.vue b/web/app/components/m3/Snackbar.vue deleted file mode 100644 index 204f099..0000000 --- a/web/app/components/m3/Snackbar.vue +++ /dev/null @@ -1,23 +0,0 @@ - - - diff --git a/web/app/components/m3/TopAppBar.vue b/web/app/components/m3/TopAppBar.vue deleted file mode 100644 index 582afda..0000000 --- a/web/app/components/m3/TopAppBar.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/web/app/components/m3/types.ts b/web/app/components/m3/types.ts deleted file mode 100644 index 014be89..0000000 --- a/web/app/components/m3/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface NavEntry { - to: string - icon: string - label: string -} diff --git a/web/app/composables/useColorTheme.ts b/web/app/composables/useColorTheme.ts deleted file mode 100644 index 1cf7123..0000000 --- a/web/app/composables/useColorTheme.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { parseTheme, resolveTheme, THEME_KEY } from '~/lib/theme' -import type { ThemeName } from '~/lib/theme' - -function stored(): string | null { - try { - return localStorage.getItem(THEME_KEY) - } - catch { - return null - } -} - -/** - * Light/dark theme. The page is server-rendered, so the theme is only known after mount: `restore` reads the stored - * choice or the system preference. Without an explicit choice, m3-tokens.css follows the system through CSS and the - * data-theme attribute stays unset. The toggle writes the choice to the html element and to localStorage. - */ -export function useColorTheme() { - const theme = useState('grus.theme', () => 'light') - const isDark = computed(() => theme.value === 'dark') - - function apply(next: ThemeName) { - theme.value = next - document.documentElement.dataset.theme = next - } - function toggle() { - const next: ThemeName = isDark.value ? 'light' : 'dark' - apply(next) - try { - localStorage.setItem(THEME_KEY, next) - } - catch { /* storage unavailable: the choice just does not persist */ } - } - /** Called once after mount, in the browser only. */ - function restore() { - const choice = parseTheme(stored()) - if (choice) { - apply(choice) - return - } - theme.value = resolveTheme(null, window.matchMedia('(prefers-color-scheme: dark)').matches) - } - return { theme, isDark, toggle, restore } -} diff --git a/web/app/composables/useMediaQuery.ts b/web/app/composables/useMediaQuery.ts deleted file mode 100644 index 97c6663..0000000 --- a/web/app/composables/useMediaQuery.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Reactive `matchMedia` result. The page is server-rendered, so the value starts as false and is read after mount; - * the browser only ever sees the real value after hydration. - */ -export function useMediaQuery(query: string) { - const matches = ref(false) - let media: MediaQueryList | undefined - const update = () => { - matches.value = media?.matches ?? false - } - onMounted(() => { - media = window.matchMedia(query) - update() - media.addEventListener('change', update) - }) - onBeforeUnmount(() => media?.removeEventListener('change', update)) - return matches -} diff --git a/web/app/composables/useSnackbar.ts b/web/app/composables/useSnackbar.ts deleted file mode 100644 index a2b8c02..0000000 --- a/web/app/composables/useSnackbar.ts +++ /dev/null @@ -1,18 +0,0 @@ -const DURATION_MS = 5000 -let timer: ReturnType | undefined - -/** App-wide transient message (one at a time). The M3Snackbar in the layouts shows it. */ -export function useSnackbar() { - const message = useState('grus.snackbar', () => '') - - function dismiss() { - clearTimeout(timer) - message.value = '' - } - function show(text: string) { - clearTimeout(timer) - message.value = text - timer = setTimeout(dismiss, DURATION_MS) - } - return { message, show, dismiss } -} diff --git a/web/app/layouts/default.vue b/web/app/layouts/default.vue index 20d90bb..a90582a 100644 --- a/web/app/layouts/default.vue +++ b/web/app/layouts/default.vue @@ -1,82 +1,24 @@ diff --git a/web/app/lib/icons.ts b/web/app/lib/icons.ts deleted file mode 100644 index 3f28ce9..0000000 --- a/web/app/lib/icons.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { - mdiAlertCircleOutline, - mdiArrowLeft, - mdiAlertOutline, - mdiCheckCircleOutline, - mdiContentSaveOutline, - mdiClose, - mdiCubeOutline, - mdiInformationOutline, - mdiLayersOutline, - mdiMenu, - mdiTagMultipleOutline, - mdiTimelineTextOutline, - mdiTrayFull, - mdiTranslate, - mdiViewDashboardOutline, - mdiWrenchOutline, - mdiWeatherNight, - mdiWeatherSunny, -} from '@mdi/js' - -/** - * SVG paths (24x24 viewBox) of the icons the interface uses, keyed by their Material Design Icons name. - * Add an entry here when a page needs a new icon; only the listed icons end up in the bundle. - */ -export const ICONS: Readonly> = { - 'mdi-alert-circle-outline': mdiAlertCircleOutline, - 'mdi-alert-outline': mdiAlertOutline, - 'mdi-arrow-left': mdiArrowLeft, - 'mdi-check-circle-outline': mdiCheckCircleOutline, - 'mdi-content-save-outline': mdiContentSaveOutline, - 'mdi-close': mdiClose, - 'mdi-cube-outline': mdiCubeOutline, - 'mdi-information-outline': mdiInformationOutline, - 'mdi-layers-outline': mdiLayersOutline, - 'mdi-menu': mdiMenu, - 'mdi-tag-multiple-outline': mdiTagMultipleOutline, - 'mdi-timeline-text-outline': mdiTimelineTextOutline, - 'mdi-tray-full': mdiTrayFull, - 'mdi-translate': mdiTranslate, - 'mdi-view-dashboard-outline': mdiViewDashboardOutline, - 'mdi-weather-night': mdiWeatherNight, - 'mdi-weather-sunny': mdiWeatherSunny, - 'mdi-wrench-outline': mdiWrenchOutline, -} - -/** Path data for an icon name. Unknown names render an empty glyph instead of breaking the page. */ -export function iconPath(name: string): string { - return ICONS[name] ?? '' -} diff --git a/web/app/lib/problem.test.ts b/web/app/lib/problem.test.ts deleted file mode 100644 index 9360b5b..0000000 --- a/web/app/lib/problem.test.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { ApiError, NetworkError, problemFromBody, toClientError, toTransportError } from './problem' - -describe('problemFromBody', () => { - it('keeps the RFC 9457 fields of a problem document', () => { - const err = problemFromBody(409, 'Conflict', { - type: 'about:blank', - title: 'Conflict', - status: 409, - detail: 'pool is in maintenance', - }) - expect(err).toBeInstanceOf(ApiError) - expect(err.status).toBe(409) - expect(err.problem.title).toBe('Conflict') - expect(err.message).toBe('pool is in maintenance') - }) - - it('falls back to a generic problem for a non-problem body', () => { - const err = problemFromBody(502, 'Bad Gateway', 'upstream down') - expect(err.status).toBe(502) - expect(err.problem.title).toBe('Bad Gateway') - expect(err.problem.type).toBe('about:blank') - expect(err.errors).toEqual([]) - }) - - it('uses the HTTP status when the status is missing', () => { - expect(problemFromBody(500, '', {}).problem.title).toBe('HTTP 500') - }) - - it('exposes validation errors by location and message', () => { - const err = problemFromBody(422, 'Unprocessable Entity', { - title: 'Unprocessable Entity', - status: 422, - errors: [{ location: 'body.scaling.max', message: 'must be >= min' }], - }) - expect(err.errors).toEqual([{ location: 'body.scaling.max', message: 'must be >= min' }]) - }) -}) - -describe('toClientError', () => { - it('maps a thrown error with a response to an ApiError', () => { - const thrown = { response: { status: 404, statusText: 'Not Found', _data: { title: 'Not Found', status: 404 } } } - const err = toClientError(thrown) - expect(err).toBeInstanceOf(ApiError) - expect((err as ApiError).status).toBe(404) - }) - - it('maps an error without a response to a NetworkError', () => { - expect(toClientError(new TypeError('fetch failed'))).toBeInstanceOf(NetworkError) - }) - - it('passes known client errors through unchanged', () => { - const known = new NetworkError('gone') - expect(toClientError(known)).toBe(known) - }) -}) - -describe('toTransportError', () => { - it('carries status, title and problem of an ApiError', () => { - const problem = { type: 'about:blank', title: 'Conflict', status: 409, detail: 'Pool is busy' } - expect(toTransportError(new ApiError(problem))).toEqual({ - status: 409, - statusText: 'Conflict', - message: 'Pool is busy', - data: { problem }, - }) - }) - - it('marks a NetworkError as a bad gateway with network data', () => { - const transported = toTransportError(new NetworkError()) - expect(transported.status).toBe(502) - expect(transported.data).toEqual({ network: true }) - }) -}) - -describe('toClientError with transported data', () => { - it('rebuilds the ApiError from the data of a wrapped error', () => { - const problem = { type: 'about:blank', title: 'Not Found', status: 404, detail: 'No pool lobby' } - const wrapped = Object.assign(new Error('wrapped'), { data: { problem } }) - const err = toClientError(wrapped) - expect(err).toBeInstanceOf(ApiError) - expect((err as ApiError).problem.detail).toBe('No pool lobby') - }) - - it('rebuilds a NetworkError from network data', () => { - expect(toClientError({ data: { network: true } })).toBeInstanceOf(NetworkError) - }) - - it('ignores data that is not a transported problem', () => { - const thrown = { data: { problem: 'text' }, response: { status: 500, statusText: 'Server Error', _data: {} } } - expect((toClientError(thrown) as ApiError).status).toBe(500) - }) -}) diff --git a/web/app/lib/problem.ts b/web/app/lib/problem.ts index 0a6c411..da5dc69 100644 --- a/web/app/lib/problem.ts +++ b/web/app/lib/problem.ts @@ -1,108 +1,10 @@ -/** RFC 9457 problem details as the Grus API sends them (application/problem+json). */ -export interface ProblemDetails { - type: string - title: string - status: number - detail?: string - instance?: string - /** Field-level errors (validation): where it happened and what is wrong. The submitted value is never shown. */ - errors?: ProblemError[] | null -} - -export interface ProblemError { - location?: string - message?: string -} - -/** An error answer from the API: the problem document, or a generic one when the body was not a problem. */ -export class ApiError extends Error { - readonly status: number - readonly problem: ProblemDetails - - constructor(problem: ProblemDetails) { - super(problem.detail || problem.title) - this.name = 'ApiError' - this.status = problem.status - this.problem = problem - } - - get errors(): ProblemError[] { - return Array.isArray(this.problem.errors) ? this.problem.errors : [] - } -} - -/** The API could not be reached at all (no response). */ -export class NetworkError extends Error { - constructor(message = 'The API could not be reached') { - super(message) - this.name = 'NetworkError' - } -} - -/** Maps a failed response to an ApiError. Bodies that are not problem documents get a generic problem. */ -export function problemFromBody(status: number, statusText: string, body: unknown): ApiError { - const b = typeof body === 'object' && body !== null && !Array.isArray(body) ? (body as Record) : {} - return new ApiError({ - ...b, - type: typeof b.type === 'string' ? b.type : 'about:blank', - title: typeof b.title === 'string' ? b.title : statusText || `HTTP ${status}`, - status: typeof b.status === 'number' ? b.status : status, - detail: typeof b.detail === 'string' ? b.detail : undefined, - errors: Array.isArray(b.errors) ? (b.errors as ProblemError[]) : null, - }) -} - -/** - * Normalises whatever a failed request threw. A thrown error with a response is an API answer; an error that already - * carries the transport data of {@link toTransportError} (for example restored from the SSR payload) is rebuilt from - * it; without either the request never completed (network down, BFF unreachable). - */ -export function toClientError(err: unknown): ApiError | NetworkError { - if (err instanceof ApiError || err instanceof NetworkError) return err - if (typeof err !== 'object' || err === null) return new NetworkError() - const data = (err as { data?: unknown }).data - if (isTransportData(data)) { - return 'problem' in data ? new ApiError(data.problem) : new NetworkError() - } - if ('response' in err) { - const response = (err as { response?: { status?: unknown, statusText?: unknown, _data?: unknown } }).response - if (response && typeof response.status === 'number') { - return problemFromBody( - response.status, - typeof response.statusText === 'string' ? response.statusText : '', - response._data, - ) - } - } - return new NetworkError() -} - -/** What travels in the `data` of a Nuxt error so the client can rebuild the original ApiError or NetworkError. */ -export type TransportData = { problem: ProblemDetails } | { network: true } - -/** Input for Nuxt's createError: status and text for the error page, the original error as data. */ -export interface TransportError { - status: number - statusText: string - message: string - data: TransportData -} - -/** - * Turns a client error into createError input. Nuxt masks every server-side error that was not raised with an HTTP - * status as "500 Internal Server Error" and drops its data, so API problems must travel this way to survive SSR. - */ -export function toTransportError(err: ApiError | NetworkError): TransportError { - if (err instanceof ApiError) { - return { status: err.status, statusText: err.problem.title, message: err.message, data: { problem: err.problem } } - } - return { status: 502, statusText: 'Bad Gateway', message: err.message, data: { network: true } } -} - -function isTransportData(value: unknown): value is TransportData { - if (typeof value !== 'object' || value === null) return false - if ('network' in value) return (value as { network: unknown }).network === true - if (!('problem' in value)) return false - const problem = (value as { problem: unknown }).problem - return typeof problem === 'object' && problem !== null && typeof (problem as { status?: unknown }).status === 'number' -} +// The RFC 9457 helpers live in Pavo. Re-exported so that existing imports keep working and both sides share the same +// error classes (instanceof checks in M3Problem and in the pages). +export { + ApiError, + NetworkError, + problemFromBody, + toClientError, + toTransportError, +} from '@onelitefeathernet/pavo/problem' +export type { ProblemDetails, ProblemError, TransportData, TransportError } from '@onelitefeathernet/pavo/problem' diff --git a/web/app/lib/theme.test.ts b/web/app/lib/theme.test.ts deleted file mode 100644 index 42754ad..0000000 --- a/web/app/lib/theme.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { parseTheme, resolveTheme } from './theme' - -describe('theme', () => { - it('prefers the stored choice over the system preference', () => { - expect(resolveTheme('light', true)).toBe('light') - expect(resolveTheme('dark', false)).toBe('dark') - }) - - it('follows the system preference without a choice', () => { - expect(resolveTheme(null, true)).toBe('dark') - expect(resolveTheme(undefined, false)).toBe('light') - }) - - it('ignores unknown stored values', () => { - expect(parseTheme('purple')).toBeNull() - expect(resolveTheme('purple', true)).toBe('dark') - }) -}) diff --git a/web/app/lib/theme.ts b/web/app/lib/theme.ts deleted file mode 100644 index 4cbdc3f..0000000 --- a/web/app/lib/theme.ts +++ /dev/null @@ -1,12 +0,0 @@ -export type ThemeName = 'light' | 'dark' - -export const THEME_KEY = 'grus.theme' - -export function parseTheme(value: string | null | undefined): ThemeName | null { - return value === 'light' || value === 'dark' ? value : null -} - -/** The theme to show: an explicit choice wins over the system preference. */ -export function resolveTheme(stored: string | null | undefined, systemDark: boolean): ThemeName { - return parseTheme(stored) ?? (systemDark ? 'dark' : 'light') -} diff --git a/web/app/pages/events/index.vue b/web/app/pages/events/index.vue index 07e6710..12e9a5f 100644 --- a/web/app/pages/events/index.vue +++ b/web/app/pages/events/index.vue @@ -1,6 +1,6 @@