chore: remove legacy assets package and CSS enforcement script

This commit is contained in:
Gabriel20xx committed 2026-10-15 13:52:39 +00:00
1 parent c9fc3abcad
commit 6be3f90afa
11 files changed
+64 -5387

No files matched your search

@@ -0,0 +1,5 @@
---
"@gabriel20xx/web-ui": patch
---
Fix the primary color chosen in `PrimaryColorPicker` not reaching the app's UI. The choice is now applied through a stylesheet that also targets `[data-theme]` elements, such as the `AppShell` root, so it takes effect immediately everywhere instead of being hidden by those elements' own theme tokens. The picker also sets the `--sc-*` primary, accent, and hover tokens the shared components read.
-1
View File
@@ -21,7 +21,6 @@ The single source of truth for code reused across every project in this workspac
|---|---|---|
| `@gabriel20xx/design-tokens` | CSS | Colors, typography, spacing, radii, shadows, light/dark theme variables. |
| `@gabriel20xx/web-ui` | Svelte | Shared application shell and reusable UI components. The complete public component inventory is documented below. |
| `@gabriel20xx/legacy-assets` | Browser JS/CSS | Legacy client-side assets, kept for a handful of older pages. |
| `repos.gfranz.ch/Gabriel20xx/shared/backend` | Go | Env config, `pgx` pools/transactions, auth persistence, an AuthGuard client (`authclient`), log shipping (`logshipper`), embedded Goose migrations, and the media-family's shared route/table surface (`mediaauth`, `mediacore`, `carriernodeclient`, `syncsocket`). |
| `@gabriel20xx/node-backend` | Node.js | `pg` pool/config/transactions/migrations, auth/session persistence, an AuthGuard client. |
| `gabriel20xx-shared-backend` | Python | `asyncpg` pool/config, auth/session persistence, an AuthGuard client. |
-8
View File
@@ -742,10 +742,6 @@
"resolved": "packages/design-tokens",
"link": true
},
"node_modules/@gabriel20xx/legacy-assets": {
"resolved": "packages/legacy-assets",
"link": true
},
"node_modules/@gabriel20xx/node-backend": {
"resolved": "packages/node-backend",
"link": true
@@ -3109,10 +3105,6 @@
"version": "0.1.1",
"license": "MIT"
},
"packages/legacy-assets": {
"name": "@gabriel20xx/legacy-assets",
"version": "3.0.0"
},
"packages/node-backend": {
"name": "@gabriel20xx/node-backend",
"version": "0.1.1",
-1
View File
@@ -50,7 +50,6 @@
"media:audit:layout": "node scripts/media/audit-inline-layout.mjs",
"media:audit:layout:strict": "node scripts/media/audit-inline-layout.mjs --strict",
"media:clean:test-artifacts": "node scripts/media/clean-test-artifacts.mjs",
"media:enforce:css-design-system": "node scripts/media/enforce-design-system-css.mjs",
"media:enforce:js-mapping": "node scripts/media/enforce-js-mapping.mjs",
"media:enforce:no-skipped-tests": "node scripts/media/enforce-no-skipped-tests.mjs",
"media:lint:all": "node scripts/media/lint-all.mjs",
-15
View File
@@ -1,15 +0,0 @@
{
"extends": ["stylelint-config-standard"],
"ignoreFiles": ["public/css/index.css", "**/*.min.css"],
"rules": {
"at-rule-no-unknown": [true, { "ignoreAtRules": ["layer", "apply", "config"] }],
"selector-class-pattern": null,
"keyframes-name-pattern": null,
"custom-property-pattern": null,
"no-descending-specificity": null,
"import-notation": null,
"comment-empty-line-before": null,
"declaration-property-value-no-unknown": null,
"value-keyword-case": ["lower", { "camelCaseSvgKeywords": true }]
}
}
-16
View File
@@ -1,16 +0,0 @@
# @gabriel20xx/legacy-assets
This package now contains exactly one file: `public/css/index.css`, a static (pre-Tailwind-v4)
theme stylesheet. Its only remaining consumer is `Original/MediaDesktop`'s Electron renderer,
which still uses the old `--color-*` utility-class theme rather than the current `--sc-*`
design-token system in `packages/design-tokens`. It's a `file:` dependency there
(`scripts/copy-assets.mjs` copies `index.css` into `MediaDesktop/public/` at build time) - do not
delete this package without first migrating MediaDesktop off the old stylesheet.
Everything else that used to live here (the pre-SvelteKit `public/js/*` auth/layout/media
utilities, an orphaned `MediaDesktop/assets/icon.png` copy, and the broken monorepo-era
`build:theme` script) was removed: nothing else in the workspace referenced any of it.
Originally `MediaCollection/MediaShared`, moved here to centralize shared components. Both the
`MediaCollection` and `MediaShared` umbrella names are retired - everything here is just part of
`shared` now, workspace-wide.
-13
View File
@@ -1,13 +0,0 @@
{
"name": "@gabriel20xx/legacy-assets",
"version": "3.0.0",
"private": true,
"description": "Legacy pre-SvelteKit theme CSS, kept only for MediaDesktop's Electron renderer (file: dependency)",
"scripts": {
"lint:css": "stylelint \"public/**/*.css\""
},
"exports": {
"./index.css": "./public/css/index.css"
},
"files": ["public/**"]
}
File diff suppressed because it is too large. Load diff
+38 -14
View File
@@ -39,9 +39,10 @@ const paletteByName = Object.fromEntries(PRIMARY_COLOR_PALETTE.map((color) => [c
string,
PaletteColor
>
const primaryVars = ['--color-primary', '--color-accent', '--color-ring']
const foregroundVars = ['--color-primary-fg', '--color-accent-fg']
const primaryVars = ['--color-primary', '--color-accent', '--color-ring', '--sc-primary', '--sc-accent', '--sc-ring']
const foregroundVars = ['--color-primary-fg', '--color-accent-fg', '--sc-primary-fg', '--sc-accent-fg']
const activeUserAttribute = 'data-primary-color-user'
const styleElementId = 'sc-primary-color'
const activeProjects = new Set<string>()
function normalizeUserKey(userKey: string): string {
@@ -67,19 +68,45 @@ function readStoredColor(projectKey: string): string {
}
}
// Moves a #rrggbb color a fraction of the way toward a channel value (0 = black, 255 = white).
function mixHex(hex: string, towards: number, weight: number): string {
const channels = [1, 3, 5].map((start) => parseInt(hex.slice(start, start + 2), 16))
return `#${channels.map((c) => Math.round(c + (towards - c) * weight).toString(16).padStart(2, '0')).join('')}`
}
// The color is written to a stylesheet rather than inline on <html>. Shared and app CSS re-declare these
// tokens on every [data-theme] element (the AppShell root, for one), and that declaration hides the value
// <html> would pass down, so the choice never reached the app's UI. Targeting [data-theme] elements with
// !important makes it win everywhere, and the dark/light split is left to the selectors.
function primaryDeclarations(color: PaletteColor, dark: boolean): string {
const primary = dark ? color.dark : color.light
// Hover is lighter on dark and darker on light, as in the shared theme. It is a hex value, not color-mix(),
// because consumers such as the terminal read these tokens as plain colors.
const hover = dark ? mixHex(primary, 255, 0.15) : mixHex(primary, 0, 0.15)
const foreground = dark ? color.darkFg : '#ffffff'
return [
...primaryVars.map((name) => `${name}: ${primary} !important;`),
`--sc-primary-hover: ${hover} !important;`,
...foregroundVars.map((name) => `${name}: ${foreground} !important;`),
].join(' ')
}
export function applyPrimaryColor(_projectKey: string, colorName: string): void {
if (typeof document === 'undefined') return
const color = paletteByName[colorName]
const root = document.documentElement.style
let style = document.getElementById(styleElementId) as HTMLStyleElement | null
if (!color) {
for (const name of [...primaryVars, ...foregroundVars]) root.removeProperty(name)
style?.remove()
return
}
const dark = document.documentElement.getAttribute('data-theme') === 'dark'
const primary = dark ? color.dark : color.light
const foreground = dark ? color.darkFg : '#ffffff'
for (const name of primaryVars) root.setProperty(name, primary)
for (const name of foregroundVars) root.setProperty(name, foreground)
if (!style) {
style = document.createElement('style')
style.id = styleElementId
document.head.append(style)
}
style.textContent = `:root, [data-theme] { ${primaryDeclarations(color, false)} }
[data-theme='dark'] { ${primaryDeclarations(color, true)} }
`
}
export function setPrimaryColor(projectKey: string, colorName: string): void {
@@ -105,11 +132,8 @@ export function initPrimaryColor(projectKey: string, userKey = ''): () => void {
if (typeof document === 'undefined') return () => undefined
if (userKey) setPrimaryColorUser(userKey)
activeProjects.add(projectKey.trim().toLowerCase() || 'application')
const stored = readStoredColor(projectKey)
applyPrimaryColor(projectKey, stored)
const observer = new MutationObserver(() => applyPrimaryColor(projectKey, readStoredColor(projectKey)))
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] })
return () => observer.disconnect()
applyPrimaryColor(projectKey, readStoredColor(projectKey))
return () => undefined
}
export function storedPrimaryColor(projectKey: string): string {
+21
View File
@@ -703,6 +703,27 @@ html[data-wide-layout='true'] .sc-header {
box-shadow: 0 0 0 3px color-mix(in srgb, var(--sc-ring) 22%, transparent);
}
/* Checkboxes and radios share one look across apps. The box takes each app's primary color,
so it follows that app's light and dark theme. Sizes match the legacy shared sheet. The rule
sits in the base layer so Tailwind utilities (size-*, accent-*) still override it per element. */
@layer base {
input[type='checkbox'],
input[type='radio'] {
accent-color: var(--sc-primary);
width: 1.05rem;
height: 1.05rem;
flex: 0 0 auto;
}
input[type='checkbox'] {
border-radius: 4px;
}
input[type='radio'] {
border-radius: 9999px;
}
}
.sc-form-actions,
.sc-dialog-footer {
display: flex;
-117
View File
@@ -1,117 +0,0 @@
#!/usr/bin/env node
/**
* Enforce design-system CSS constraints for shared theme files.
*
* Rules enforced:
* - Theme CSS must not contain project/service-coupled selector tokens.
* - Theme CSS must not contain route-coupled panel IDs in selectors.
*
* TODO(shared extraction): the original monorepo version of this script also asserted that
* MediaShared/public/css/index.css and MediaDesktop/public/index.css stayed byte-for-byte synced.
* That check is no longer possible from inside this repo: MediaDesktop is now a fully separate
* repo (Original/MediaDesktop) and isn't checked out alongside this one, so there is nothing here
* to diff it against. The desktop-vs-shared theme sync check has been dropped rather than pointed
* at a nonexistent path; if that guarantee still matters, it belongs in MediaDesktop's own CI
* (comparing its vendored shared/ copy's theme file against its own), not here.
*/
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const repoRoot = path.resolve(__dirname, '..', '..');
// MediaShared/public/css/index.css became packages/legacy-assets/public/css/index.css once
// media-backend/webui were folded directly into the shared repo (no more vendored copy).
const sharedThemePath = path.join(
repoRoot,
'packages',
'legacy-assets',
'public',
'css',
'index.css'
);
const bannedSelectorRules = [
{
name: 'project-coupled service token',
regex: /\b(?:kiosk|viewer|moderator|generator|library|contentscanner|downloader|carriernode)-page\b/i,
},
{
name: 'project-coupled state class token',
regex:
/\b(?:viewer|kiosk|moderator|generator|library|contentscanner|downloader|carriernode)-(?:home|page|stage|mode|active|panel)\b/i,
},
{
name: 'project-prefixed keyframe name',
regex:
/@keyframes\s+nc-(?:viewer|kiosk|moderator|generator|library|contentscanner|downloader|carriernode)/i,
},
{
name: 'project-coupled data attribute',
regex:
/\[data-(?:kiosk|viewer|moderator|generator|library|contentscanner|downloader|carriernode)[^\]]*\]/i,
},
{
name: 'route-coupled panel selector',
regex: /#panel-[a-z0-9_-]+/i,
},
];
function readUtf8(filePath) {
return fs.readFileSync(filePath, 'utf8');
}
function stripCssComments(text) {
return text.replace(/\/\*[\s\S]*?\*\//g, '');
}
function findViolations(filePath, content) {
const cleaned = stripCssComments(content);
const lines = cleaned.split(/\r?\n/);
const violations = [];
for (let i = 0; i < lines.length; i += 1) {
const line = lines[i];
for (const rule of bannedSelectorRules) {
if (rule.regex.test(line)) {
violations.push({
filePath,
line: i + 1,
rule: rule.name,
snippet: line.trim(),
});
}
}
}
return violations;
}
function main() {
if (!fs.existsSync(sharedThemePath)) {
console.error('[enforce-design-system-css] Missing expected theme file:');
console.error(` - ${path.relative(repoRoot, sharedThemePath)}`);
process.exit(1);
}
const sharedTheme = readUtf8(sharedThemePath);
const allViolations = findViolations(sharedThemePath, sharedTheme);
if (allViolations.length > 0) {
console.error('[enforce-design-system-css] Design-system CSS violations found:');
for (const v of allViolations) {
const rel = path.isAbsolute(v.filePath) ? path.relative(repoRoot, v.filePath) : v.filePath;
console.error(` - ${rel}:${v.line} [${v.rule}] ${v.snippet}`);
}
console.error('[enforce-design-system-css] Fix violations before running lint/test.');
process.exit(1);
}
console.log(
'[enforce-design-system-css] OK: shared theme is free of project-coupled selectors.'
);
}
main();