@michael/web-common (0.2.0)
Installation
@michael:registry=npm config set @michael:registry=npm install @michael/web-common@0.2.0"@michael/web-common": "0.2.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, andsafe-mode.tsis?safe, which leaves custom themes out for a tab. - Theme builder parts (
components/themes/): the theme list with import, the editor (seeds, every token, contrast report, custom CSS), colour fields, collapsible builder sections, the CSS dialog, and the safe-mode banner. The page that holds them, and its preview, are the app's. - Components (
components/common/,components/settings/): status strips, the decision dialog shell, folds (Disclosure,FoldTransition), the code editor (a textarea over highlighted code), copy button, the standalone screen (CenterStage), strips under a top bar, help links, and the settings row, switch, and segmented control. - 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). - 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;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.2.0"
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"
});
<!-- 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, apply the stored mode and palette (applyTheme from
themes/theme). 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.
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 ../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. -
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 |
|---|---|
| @eslint/js | 10.0.1 |
| @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 |
|---|---|
| quasar | ^2.35.0 |
| vite | ^8.3.0 |
| vue | ^3.5.43 |
| vue-router | ^5.4.0 |