@michael/web-common (0.7.0)
Installation
@michael:registry=npm config set @michael:registry=npm install @michael/web-common@0.7.0"@michael/web-common": "0.7.0"About this package
web-common
The theme engine, theme builder, stylesheets, and UI building blocks that the sadil.eu Vue 3 + Quasar apps share: Wilco (Kilo-Remote), which they come from, and Pinnace. It ships as source, TypeScript and single-file components and SCSS, with no build step: each app's Vite build compiles it as its own code, and its Vue and Quasar are the app's.
Published as @michael/web-common on the Forgejo npm registry at
code.sadil.eu, where it is public.
What's inside
Paths are under src/; an app imports them without the src/, and .ts
files without their extension: @michael/web-common/ui/fold,
@michael/web-common/components/common/StatusBanner.vue.
- Theme engine (
themes/). Palettes as tokens (tokens.ts), a dark and a light variant each, applied throughdata-theme(mode) anddata-paletteon the root. Graphite (the default) and Phosphor are Sass mixins incss/_theme.scss; the rest areThemeDatainthemes/data/: Monokai Dimmed, and Blueprint, Swiss, Terminal, Chart plotter, and Pro IDE, the palettes of 0.1 rebuilt from their colours as the builder builds themes.theme.tsapplies a mode and palette (applyTheme), mirrors it for the boot script, redraws the favicon in it, and holds custom CSS.derive.tsderives a whole palette from six seed colours,checks.tsholds every palette to WCAG contrast (the tests check all of them),custom.tsreads and writes the builder's themes and their files,css.tsprepares a theme's custom CSS for the app and for a preview,safe-mode.tsis?safe, which leaves custom themes out for a tab, andsettings.tsis what the builder reads and writes (ThemeSettings), read back safely (normalizeThemeSettings), or kept in this browser for an app with no settings store of its own (localThemeSettings). - Theme builder (
components/themes/): the page (ThemeBuilderPage.vue), with the theme list and import, the editor (seeds, every token, contrast report, custom CSS), colour fields, collapsible builder sections, and the CSS dialog, beside a preview: the app's picture of itself, which the page draws in the theme inThemePreviewFrame.vue. Also the safe-mode banner. - Components (
components/common/,components/settings/): status strips, the decision dialog shell, folds (Disclosure,FoldTransition, and the card aDisclosureis drawn as, alone or in rows:.disclosure-card,.disclosure-rowsincss/_disclosure.scss), the code editor (a textarea over highlighted code), the CodeMirror editor (CodeMirrorEditor.vue: CodeMirror 6 mounted by hand, its text as the v-model, which Pinnace's stacks editor builds on), copy button, the standalone screen (CenterStage), strips under a top bar, the connection status (ConnectionStatus), help links, and the settings row, switch, and segmented control. - Status icons (
status/,components/common/StatusIcon.vue,css/_status.scss): one vocabulary of states (StatusState: active, waiting, idle, ready, error, offline, online) that each app maps its own states onto, drawn in four sets that Settings chooses between: Signals, Rings, Playback, Marks (iconSets,iconSetNames). The app provides the chosen set undericonSetKey, from its own settings store or from this browser (localIconSet,status/setting.ts). Signals draws a running state with the app's own glyph,runningGlyphin its options: Wilco's sine (its logo's wave, fromstatus/sine.js) or the sonar pulse. An icon can be stale (faded and still) or secondary (in the secondary colour). They came from Wilco. - UI helpers (
ui/): fold animation, view transitions, menu placement, Quasar dialog buttons, clipboard with a non-secure fallback, swipes, shortcuts, shown/hidden scopes for kept pages, stable computed values, help links (help.ts), and following a list's live edge (follow.ts: pinning the newest entry in view, gliding to an entry, and telling the reader's scrolling from the virtual scroll's own), which Wilco's transcript and Pinnace's logs share.codemirror.tsgives CodeMirror the apps' look: a theme in the tokens, highlighting by the same.tok-*classes Shiki's tokens get, so YAML in an editor is coloured as in a code block, the keys of an editor of code (codeKeys), and its usual parts together (codeSetup). CodeMirror is an optional peer dependency: an app that uses these installs@codemirror/state,view,language,commandsand@lezer/highlightitself, so one copy of each serves the app and this package. - Text (
text/): formatting (format.ts) and Shiki highlighting with grammars loaded on demand (highlight.ts). - Composables (
composables/):useClock,useHoverMenu. - Routing (
router/motion.ts): sheet transitions between pages, withcss/_pages.scss. - Stylesheets (
css/):_theme.scss(Inter, the tokens, Graphite and Phosphor),_base.scss, and a partial per component group, among them_menus.scss: the glass panel of menus, pickers and dialogs, menu items with their muted icons, and the fade of a disabled control.all.scsstakes them all in cascade order. - Build (
build/, imported as@michael/web-common/vite): the Vite plugin, and a patch to Quasar'sQVirtualScroll. - Tests' helpers (
test/): jsdom shims (setup.ts), andmountKept/setupKeptfor components under aShownScope.
Using it in an app
# .npmrc, beside package.json
@michael:registry=https://code.sadil.eu/api/packages/michael/npm/
// package.json: an exact version; peers are vue, quasar, vue-router
"@michael/web-common": "0.3.0"
An app with a linked install (npm's install-strategy=linked, or pnpm)
must also depend on @shikijs/core, @shikijs/engine-javascript, and
@shikijs/langs, at the versions in this package's package.json.
vue-tsc checks a package's .vue files at their linked path in the app's
node_modules, not in the store, so the modules they import resolve
against the app's own dependencies, and the code editor imports the
highlighter. A hoisted install (npm's default) needs nothing more.
Add the plugin to the app's Vite build and to Vitest, with what the package
needs to know about the app (src/config.ts has the whole of it). It
compiles that into the package, serves and emits the theme boot script,
keeps the package out of dependency pre-bundling (which cannot compile
.vue), and has Vitest compile it as source.
// quasar.config.ts (build.vitePlugins), and vitest.config.ts (plugins)
import { webCommon } from "@michael/web-common/vite";
webCommon({
storagePrefix: "pinnace", // localStorage/sessionStorage keys
fileFormat: "pinnace-theme", // exported theme files
palettes: [], // the built-in palettes offered; [] for all
favicon: "<svg …>{plate} {trace}</svg>", // redrawn in each palette
productName: "Pinnace", // "a Pinnace theme file"
uiName: "Pinnace", // "it applies across Pinnace"
runningGlyph: "sonar", // Signals' running glyph: "sine" (Wilco's) or "sonar"
});
<!-- index.html, in <head>: the theme before the first paint -->
<script src="/theme-boot.js"></script>
// quasar.config.ts: the stylesheets, then the app's own
css: ["~@michael/web-common/css/all.scss", "app.scss"],
At startup, and whenever they change, apply the stored mode and palette
(applyTheme from themes/theme, with safeMode from
themes/safe-mode).
The theme builder is a page the app routes to, as theme-builder with an
optional themeId param, and gives its theme settings, how to store them,
and the preview: the app's own components on made-up data. Without a
settings store of its own, an app keeps them in this browser:
<script setup lang="ts">
import ThemeBuilderPage from "@michael/web-common/components/themes/ThemeBuilderPage.vue";
import { localThemeSettings } from "@michael/web-common/themes/settings";
import AppPreview from "../components/AppPreview.vue";
const { settings, storageError, update } = localThemeSettings();
</script>
<template>
<!-- route: { path: "/settings/themes/:themeId?", name: "theme-builder" } -->
<ThemeBuilderPage
:settings="settings"
:update="update"
:storage-error="storageError"
>
<template #preview><AppPreview /></template>
</ThemeBuilderPage>
</template>
Back from the theme list goes to the route named settings, unless the
page is given back. To have the components' help links lead somewhere,
provide helpRouteKey (ui/help) with a function from a page's name to a
route; without it they don't show. An app's icon map can spread icons
(icons.ts), so one name means one glyph.
Wilco
Wilco loads the partials one by one, each just ahead of its own partial
that held those rules, so that every rule kept its place in the cascade
when it moved here (Wilco's web/src/css/app.scss and
docs/web-common.md). _controls.scss comes after Wilco's own controls,
whose glass panel it overrides.
Wording
What the apps' UIs say follows docs/wording.md, on
Google's developer documentation style guide, and so do this package's
own strings.
Checks
npm ci
npm run check # Prettier, ESLint, vue-tsc, Vitest, file sizes
The tests run as an app with an identity of its own (vitest.config.ts),
so they see the configuration path apps use.
Changing web-common
-
Make the change here, with its tests, and run
npm run check. -
Raise
versioninpackage.json: a released version never changes. Breaking changes raise the minor while the major is 0. -
Try it in an app before release:
npm pack, then install the tarball in the app (npm install ../common/web-common/michael-web-common-x.y.z.tgz) and run the app's own checks. Install the tarball rather than linking the folder, which would bring this package's own Vue alongside the app's. -
Publish, with a token that may write packages for the
michaelaccount:npm publish --userconfig <(printf '%s\n' \ '@michael:registry=https://code.sadil.eu/api/packages/michael/npm/' \ "//code.sadil.eu/api/packages/michael/npm/:_authToken=$TOKEN")Wilco's
docs/web-common.mdsays where such a token comes from. -
Tag the commit you published from and push it with
main, so the source of every published version is on the server. Tags carry the package's name, as the monorepo's other packages' do (its AGENTS.md):git tag -a web-common/vX.Y.Z -m X.Y.Z git push origin main web-common/vX.Y.Z -
In each app, set the new exact version,
npm install, and run its checks.
Everything published under the michael account is public, as its
source: keep secrets and anything private out of the package.
Dependencies
Dependencies
| ID | Version |
|---|---|
| @fontsource-variable/inter | 5.3.0 |
| @quasar/extras | 2.1.0 |
| @shikijs/core | 4.5.0 |
| @shikijs/engine-javascript | 4.5.0 |
| @shikijs/langs | 4.5.0 |
Development dependencies
| ID | Version |
|---|---|
| @codemirror/commands | 6.11.1 |
| @codemirror/lang-yaml | 6.1.3 |
| @codemirror/language | 6.13.1 |
| @codemirror/state | 6.7.6 |
| @codemirror/view | 6.43.15 |
| @eslint/js | 10.0.1 |
| @lezer/highlight | 1.2.5 |
| @quasar/vite-plugin | 2.0.2 |
| @types/node | 26.6.4 |
| @vitejs/plugin-vue | 6.0.9 |
| @vue/test-utils | 2.5.1 |
| eslint | 10.12.0 |
| eslint-plugin-vue | 10.11.1 |
| jsdom | 30.1.2 |
| prettier | 3.9.9 |
| quasar | 2.35.0 |
| sass-embedded | 1.105.1 |
| typescript | 6.0.3 |
| typescript-eslint | 8.71.1 |
| vite | 8.3.4 |
| vitest | 5.0.3 |
| vue | 3.5.43 |
| vue-router | 5.4.0 |
| vue-tsc | 3.3.12 |
Peer dependencies
| ID | Version |
|---|---|
| @codemirror/commands | ^6.11.1 |
| @codemirror/language | ^6.13.1 |
| @codemirror/state | ^6.7.6 |
| @codemirror/view | ^6.43.15 |
| @lezer/highlight | ^1.2.5 |
| quasar | ^2.35.0 |
| vite | ^8.3.0 |
| vue | ^3.5.43 |
| vue-router | ^5.4.0 |