Tidy the structure the audit found
- The colour defaults have one source, server/src/themeDefaults.js, read by the server and the admin; the build stops if src/index.css disagrees with it - server/src/admin-schema.js split into admin-schema/, one file per entity plus columns.js (the registry checked identical) - loadOwned() in shape.js replaces the same three loads on four detail routes (every public route checked identical); one NO_STORE - One OrgLogo component for the org lists and the chapter map; an organization's own page now shows the same initials as the lists - One localISO() for the viewer's calendar day, in place of three - Boot refuses a descriptor dropdown value the table's CHECK doesn't allow, instead of it failing on save - Deleted the unused Other.tsx and white-background logo; chapters.ts is useCommunity.ts; isSuper() in the Panel; stale comments and docs corrected Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
048c7599ce
commit
f934b1dd93
44 changed files with 1187 additions and 1170 deletions
|
|
@ -2,7 +2,10 @@ import { defineConfig, type HtmlTagDescriptor, type Plugin } from 'vite'
|
|||
import react from '@vitejs/plugin-react'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
import siteConfiguration from './site.json'
|
||||
import { THEME_DEFAULTS } from './server/src/themeDefaults.js'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
|
|
@ -10,6 +13,7 @@ export default defineConfig({
|
|||
react(),
|
||||
tailwindcss(),
|
||||
siteConfigurationPlugin(siteConfiguration),
|
||||
themeDefaultsCheck(),
|
||||
],
|
||||
server: {
|
||||
proxy: {
|
||||
|
|
@ -198,3 +202,38 @@ function siteConfigurationPlugin(config: SiteConfiguration): Plugin {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
/* The colour tokens exist twice: as data in server/src/themeDefaults.js
|
||||
(the admin's defaults, the contrast check) and as CSS in
|
||||
src/index.css (what pages draw with). This stops the build, and the
|
||||
dev server, when the two disagree, naming each difference. */
|
||||
function themeDefaultsCheck(): Plugin {
|
||||
const read = (css: string, block: RegExp) => {
|
||||
const body = block.exec(css)?.[1] ?? ''
|
||||
return Object.fromEntries(
|
||||
[...body.matchAll(/--color-([a-z-]+):\s*(#[0-9a-f]{6})/gi)].map((m) => [m[1], m[2].toLowerCase()]),
|
||||
)
|
||||
}
|
||||
return {
|
||||
name: 'theme-defaults-check',
|
||||
buildStart() {
|
||||
const css = readFileSync('src/index.css', 'utf8')
|
||||
const light = read(css, /@theme\s*\{([\s\S]*?)\n\}/)
|
||||
const dark = read(css, /:root\[data-theme="dark"\]\s*\{([\s\S]*?)\}/)
|
||||
const problems: string[] = []
|
||||
for (const [token, [lightHex, darkHex]] of Object.entries(THEME_DEFAULTS) as [string, string[]][]) {
|
||||
if (light[token] !== lightHex.toLowerCase())
|
||||
problems.push(`--color-${token} light: index.css ${light[token] ?? 'missing'}, themeDefaults.js ${lightHex}`)
|
||||
// A token index.css doesn't redefine for dark keeps its light value.
|
||||
const cssDark = dark[token] ?? light[token]
|
||||
if (cssDark !== darkHex.toLowerCase())
|
||||
problems.push(`--color-${token} dark: index.css ${cssDark ?? 'missing'}, themeDefaults.js ${darkHex}`)
|
||||
}
|
||||
if (problems.length) {
|
||||
this.error(
|
||||
`Colour tokens disagree between src/index.css and server/src/themeDefaults.js:\n ${problems.join('\n ')}`,
|
||||
)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue