CMS: één bannerlijst met Locatie, SLP-thema, thema-schakelaar, documentatie
- Banner-admin: één lijst met Locatie-badge (Boven/Onder), Locatie-keuzeveld in het formulier, "Live" en "Wordt niet getoond" per locatie, aan/uit per rij - Thema slpsoftware: Archivo, bordeaux #7A1414 (WCAG AA licht en donker), <SLP/>-logo, favicon, mail-logo; VITE_THEME in de SLP-builds (test en productie-config) - Thema-schakelaar: eerste klik wisselt altijd het getoonde thema (klasse op <html> als bron van waarheid, gedeelde status, startscript valideert opslag) + tests - Docs: README, docs/cms-themas.md, docs/deploy-en-testomgevingen.md, docs/privacy-gegevens-contactformulier.md, aidlc-docs (offering-banners, bug theme-toggle-first-click) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -50,7 +50,7 @@ describe('resolveTheme', () => {
|
||||
});
|
||||
|
||||
it('lists the available themes', () => {
|
||||
expect(availableThemes()).toContain('asf');
|
||||
expect(availableThemes()).toEqual(expect.arrayContaining(['asf', 'slpsoftware']));
|
||||
});
|
||||
|
||||
it.each(['nope', '../asf', 'asf/../asf', '..', 'ASF', 'asf asf'])('rejects %j loudly, naming the real themes', (name) => {
|
||||
@@ -99,3 +99,35 @@ describe('asf theme tokens', () => {
|
||||
expect(theme).toContain('@fontsource/marcellus');
|
||||
});
|
||||
});
|
||||
|
||||
describe('slpsoftware theme', () => {
|
||||
it('resolves stylesheet, favicon, logo pair and e-mail logo', () => {
|
||||
const theme = resolveTheme('slpsoftware');
|
||||
|
||||
expect(theme.css.replaceAll('\\', '/')).toMatch(/themes\/slpsoftware\/theme\.css$/);
|
||||
expect(fs.existsSync(theme.css)).toBe(true);
|
||||
expect(theme.favicon !== null && fs.existsSync(theme.favicon)).toBe(true);
|
||||
expect(theme.logo).not.toBeNull();
|
||||
for (const f of [theme.logo!.onLight, theme.logo!.onDark, theme.logo!.mail!]) {
|
||||
expect(fs.readFileSync(f).subarray(1, 4).toString()).toBe('PNG');
|
||||
}
|
||||
});
|
||||
|
||||
it('self-hosts Archivo and invents no structural token', () => {
|
||||
const css = fs.readFileSync(path.resolve(__dirname, 'slpsoftware/theme.css'), 'utf-8');
|
||||
const base = fs.readFileSync(path.resolve(__dirname, '../src/index.css'), 'utf-8');
|
||||
const names = (src: string, block: string) => {
|
||||
const m = src.match(new RegExp(`${block}\\s*\\{([^}]*)\\}`));
|
||||
return new Set([...(m?.[1] ?? '').matchAll(/(--[a-z-]+)\s*:/g)].map((x) => x[1]));
|
||||
};
|
||||
|
||||
expect(css).not.toMatch(/https?:\/\//);
|
||||
expect(css).toContain('@fontsource/archivo');
|
||||
for (const block of ['\\:root', '\\.dark']) {
|
||||
const existing = names(base, block);
|
||||
const themed = names(css, block);
|
||||
for (const t of existing) expect(themed, `${block} ${t}`).toContain(t);
|
||||
for (const t of themed) if (!existing.has(t)) expect(t).toMatch(/^--(slp-|font-sans$)/);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
def lum(h):
|
||||
h=h.lstrip('#'); c=[int(h[i:i+2],16)/255 for i in (0,2,4)]
|
||||
c=[x/12.92 if x<=0.03928 else ((x+0.055)/1.055)**2.4 for x in c]
|
||||
return .2126*c[0]+.7152*c[1]+.0722*c[2]
|
||||
def cr(a,b):
|
||||
la,lb=sorted([lum(a),lum(b)],reverse=True); return (la+.05)/(lb+.05)
|
||||
L=dict(bg='#ffffff',fg='#1a1a1a',card='#f7f7f7',primary='#7a1414',pf='#ffffff',muted='#f4f4f5',mfg='#5c5c5c',accent='#f6e9e9',afg='#7a1414',destr='#c62828',dfg='#ffffff',ring='#7a1414')
|
||||
D=dict(bg='#141414',fg='#f5f5f5',card='#1e1e1e',primary='#e0646c',pf='#141414',muted='#2a2a2a',mfg='#b0b0b0',accent='#3a1f21',afg='#f0a0a6',destr='#ff7b72',dfg='#141414',ring='#e0646c')
|
||||
for n,t in (('light',L),('dark',D)):
|
||||
print(n)
|
||||
for lab,a,b,m in [('foreground/background','fg','bg',4.5),('card-foreground/card','fg','card',4.5),('primary-foreground/primary','pf','primary',4.5),('primary(link)/background','primary','bg',4.5),('primary/card','primary','card',4.5),('muted-foreground/background','mfg','bg',4.5),('muted-foreground/card','mfg','card',4.5),('muted-foreground/muted','mfg','muted',4.5),('accent-foreground/accent','afg','accent',4.5),('destructive-foreground/destructive','dfg','destr',4.5),('destructive/background','destr','bg',4.5),('ring/background','ring','bg',3),('ring/card','ring','card',3)]:
|
||||
r=cr(t[a],t[b]); print(f' {lab:38s}{r:6.2f} {"OK" if r>=m else "FAIL"} (min {m})')
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
@@ -0,0 +1,8 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-20 0 3658 824" role="img" aria-label="SLP Software">
|
||||
<path fill="#7a1414" transform="translate(0 756) scale(1 -1)" d="M565 -6 63 194V327L565 527V399L197 260L565 121Z"/>
|
||||
<path fill="#1a1a1a" transform="translate(649 756) scale(1 -1)" d="M360 -12Q295 -12 238.0 -0.5Q181 11 137.5 37.0Q94 63 69.0 105.5Q44 148 44 210Q44 214 44.0 219.0Q44 224 45 227H218Q218 224 217.5 219.5Q217 215 217 212Q217 180 233.5 160.5Q250 141 280.0 132.5Q310 124 350 124Q372 124 391.0 126.0Q410 128 425.0 133.0Q440 138 451.5 145.5Q463 153 468.5 163.5Q474 174 474 188Q474 211 456.5 226.0Q439 241 409.5 251.0Q380 261 343.0 270.0Q306 279 266.0 289.0Q226 299 189.0 314.0Q152 329 122.5 352.0Q93 375 75.5 409.5Q58 444 58 493Q58 547 81.0 586.5Q104 626 144.5 651.0Q185 676 238.0 687.5Q291 699 351 699Q410 699 461.5 687.0Q513 675 553.0 649.5Q593 624 615.5 585.5Q638 547 639 493V481H467V488Q467 511 454.5 528.5Q442 546 417.0 556.5Q392 567 355 567Q318 567 292.5 560.0Q267 553 253.5 540.0Q240 527 240 509Q240 487 257.5 473.0Q275 459 305.0 449.0Q335 439 372.0 430.5Q409 422 448.5 412.5Q488 403 525.0 388.5Q562 374 592.0 351.5Q622 329 639.5 296.0Q657 263 657 216Q657 134 618.5 84.0Q580 34 512.5 11.0Q445 -12 360 -12Z"/>
|
||||
<path fill="#1a1a1a" transform="translate(1346 756) scale(1 -1)" d="M75 0V687H254V147H603V0Z"/>
|
||||
<path fill="#1a1a1a" transform="translate(1969 756) scale(1 -1)" d="M75 0V687H453Q523 687 572.5 658.5Q622 630 648.5 579.5Q675 529 675 461Q675 391 647.5 340.0Q620 289 569.5 260.5Q519 232 449 232H254V0ZM254 370H407Q449 370 471.0 393.5Q493 417 493 459Q493 489 483.5 508.0Q474 527 455.0 537.5Q436 548 407 548H254Z"/>
|
||||
<path fill="#7a1414" transform="translate(2667 756) scale(1 -1)" d="M0 -48 196 736H302L106 -48Z"/>
|
||||
<path fill="#7a1414" transform="translate(2969 756) scale(1 -1)" d="M84 -6V121L452 260L84 399V527L586 327V194Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,100 @@
|
||||
"""
|
||||
Builds the SLP Software brand logo: logo-on-light.png, logo-on-dark.png, logo-mail.png and logo.svg.
|
||||
|
||||
The mark is the text <SLP/> in Archivo ExtraBold; the angle brackets and slash are bordeaux accents,
|
||||
"SLP" is ink. Displayed 40 px high in the admin; PNGs are rendered at 3x (about 120 px high).
|
||||
|
||||
Needs: pip install pillow fonttools brotli; and `pnpm install` in frontend/ (font comes from @fontsource/archivo).
|
||||
Run from this folder: python make-logo.py
|
||||
"""
|
||||
import io
|
||||
import os
|
||||
from fontTools.ttLib import TTFont
|
||||
from fontTools.pens.svgPathPen import SVGPathPen
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
SCALE = 3
|
||||
H = 40 * SCALE
|
||||
PAD = 2 * SCALE
|
||||
FONT_WOFF2 = "../../node_modules/@fontsource/archivo/files/archivo-latin-800-normal.woff2"
|
||||
TTF = "archivo-800.tmp.ttf"
|
||||
PARTS = [("<", "accent"), ("SLP", "ink"), ("/>", "accent")]
|
||||
VARIANTS = {
|
||||
"logo-on-light.png": {"ink": (26, 26, 26), "accent": (122, 20, 20)},
|
||||
"logo-on-dark.png": {"ink": (245, 245, 245), "accent": (224, 100, 108)},
|
||||
}
|
||||
|
||||
f = TTFont(FONT_WOFF2)
|
||||
f.flavor = None
|
||||
f.save(TTF)
|
||||
|
||||
# Pick the pixel size so that the ink bounding box of the whole text is about H - 2*PAD high.
|
||||
size = 100
|
||||
probe = ImageFont.truetype(TTF, size)
|
||||
text = "".join(p for p, _ in PARTS)
|
||||
b = probe.getbbox(text)
|
||||
size = round(size * (H - 2 * PAD) / (b[3] - b[1]))
|
||||
font = ImageFont.truetype(TTF, size)
|
||||
full = font.getbbox(text)
|
||||
asc_top, asc_bot = full[1], full[3]
|
||||
|
||||
def render(colors):
|
||||
# Draw the parts one after another using advance widths (keeps the font's own kerning-free spacing).
|
||||
width = round(font.getlength(text)) + 2 * PAD + 4
|
||||
img = Image.new("RGBA", (width, 2 * H), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(img)
|
||||
x = PAD
|
||||
for part, role in PARTS:
|
||||
d.text((x, PAD - asc_top), part, font=font, fill=colors[role] + (255,))
|
||||
x += font.getlength(part)
|
||||
img = img.crop(img.getchannel("A").getbbox())
|
||||
out = Image.new("RGBA", (img.width + 2 * PAD, img.height + 2 * PAD), (0, 0, 0, 0))
|
||||
out.alpha_composite(img, (PAD, PAD))
|
||||
return out
|
||||
|
||||
for name, colors in VARIANTS.items():
|
||||
im = render(colors)
|
||||
im.save(name, optimize=True)
|
||||
print(f"{name} {im.width}x{im.height}")
|
||||
|
||||
# logo-mail.png: the light variant on a white rounded badge (same approach as themes/asf/make-mail-logo.py).
|
||||
src = Image.open("logo-on-light.png").convert("RGBA")
|
||||
src = src.crop(src.getchannel("A").getbbox())
|
||||
CONTENT_H, MPAD, RADIUS = 40 * SCALE, 8 * SCALE, 8 * SCALE
|
||||
logo = src.resize((round(src.width * CONTENT_H / src.height), CONTENT_H), Image.LANCZOS)
|
||||
w, h = logo.width + 2 * MPAD, CONTENT_H + 2 * MPAD
|
||||
badge = Image.new("RGBA", (w, h), (0, 0, 0, 0))
|
||||
ImageDraw.Draw(badge).rounded_rectangle((0, 0, w - 1, h - 1), radius=RADIUS, fill=(255, 255, 255, 255))
|
||||
badge.alpha_composite(logo, (MPAD, MPAD))
|
||||
badge.save("logo-mail.png", optimize=True)
|
||||
print(f"logo-mail.png {w}x{h}")
|
||||
|
||||
# logo.svg: text converted to paths (archive/source; the build uses the PNGs).
|
||||
gs = f.getGlyphSet()
|
||||
cmap = f.getBestCmap()
|
||||
upm = f["head"].unitsPerEm
|
||||
hmtx = f["hmtx"]
|
||||
paths, x = [], 0
|
||||
ymin, ymax = 10**9, -10**9
|
||||
from fontTools.pens.boundsPen import BoundsPen
|
||||
for part, role in PARTS:
|
||||
for ch in part:
|
||||
g = cmap[ord(ch)]
|
||||
pen = SVGPathPen(gs)
|
||||
gs[g].draw(pen)
|
||||
bp = BoundsPen(gs)
|
||||
gs[g].draw(bp)
|
||||
if bp.bounds:
|
||||
ymin, ymax = min(ymin, bp.bounds[1]), max(ymax, bp.bounds[3])
|
||||
paths.append((pen.getCommands(), x, role))
|
||||
x += hmtx[g][0]
|
||||
pad = 20
|
||||
vb_h = ymax - ymin + 2 * pad
|
||||
fill = {"ink": "#1a1a1a", "accent": "#7a1414"}
|
||||
body = "\n".join(
|
||||
f' <path fill="{fill[r]}" transform="translate({px} {ymax + pad}) scale(1 -1)" d="{d}"/>' for d, px, r in paths
|
||||
)
|
||||
svg = f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="{-pad} 0 {x + 2 * pad} {vb_h}" role="img" aria-label="SLP Software">\n{body}\n</svg>\n'
|
||||
open("logo.svg", "w", encoding="utf-8", newline="\n").write(svg)
|
||||
print("logo.svg", len(svg), "bytes")
|
||||
os.remove(TTF)
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Theme "slpsoftware" - SLP Software.
|
||||
*
|
||||
* Re-declares the admin design tokens only (colours, radius, font); no layout or component changes.
|
||||
* Brand: bordeaux #7A1414 (website variant B) as primary/ring/accent basis on a white, neutral surface.
|
||||
* Font: Archivo, self-hosted through @fontsource (the admin CSP is font-src 'self').
|
||||
* Selected at build time with VITE_THEME=slpsoftware.
|
||||
*
|
||||
* Contrast (WCAG 2.x, computed by contrast.py next to this file; AA = 4.5:1 text, 3:1 UI/large):
|
||||
*
|
||||
* Pair Light Dark
|
||||
* foreground / background 17.40 16.90
|
||||
* card-foreground / card 16.25 15.29
|
||||
* primary-foreground / primary 10.84 5.45
|
||||
* primary (links) / background 10.84 5.45
|
||||
* primary / card 10.12 4.93
|
||||
* muted-foreground / background 6.69 8.49
|
||||
* muted-foreground / card 6.24 7.69
|
||||
* muted-foreground / muted 6.08 6.62
|
||||
* accent-foreground / accent 9.16 7.36
|
||||
* destructive-foreground / destructive 5.62 7.31
|
||||
* destructive / background 5.62 7.31
|
||||
* ring / background (min 3.0) 10.84 5.45
|
||||
* ring / card (min 3.0) 10.12 4.93
|
||||
*
|
||||
* All pairs pass AA in both modes. Dark mode has no website counterpart: its primary is a lighter,
|
||||
* derived bordeaux (#e0646c) so button text and links stay above 4.5:1 on the dark surfaces.
|
||||
*/
|
||||
@import '@fontsource/archivo/latin-400.css';
|
||||
@import '@fontsource/archivo/latin-500.css';
|
||||
@import '@fontsource/archivo/latin-600.css';
|
||||
@import '@fontsource/archivo/latin-700.css';
|
||||
|
||||
:root {
|
||||
--slp-bordeaux: #7a1414;
|
||||
--slp-ink: #1a1a1a;
|
||||
--slp-ink-2: #5c5c5c;
|
||||
--slp-surface: #f7f7f7;
|
||||
--slp-tint: #f6e9e9;
|
||||
--slp-error: #c62828;
|
||||
--slp-line: #e4e4e7;
|
||||
|
||||
--slp-font-body: 'Archivo', system-ui, 'Segoe UI', Roboto, sans-serif;
|
||||
|
||||
--background: #ffffff;
|
||||
--foreground: var(--slp-ink);
|
||||
|
||||
--card: var(--slp-surface);
|
||||
--card-foreground: var(--slp-ink);
|
||||
|
||||
--popover: #ffffff;
|
||||
--popover-foreground: var(--slp-ink);
|
||||
|
||||
--primary: var(--slp-bordeaux);
|
||||
--primary-foreground: #ffffff;
|
||||
|
||||
--secondary: #f4f4f5;
|
||||
--secondary-foreground: var(--slp-ink);
|
||||
|
||||
--muted: #f4f4f5;
|
||||
--muted-foreground: var(--slp-ink-2);
|
||||
|
||||
--accent: var(--slp-tint);
|
||||
--accent-foreground: var(--slp-bordeaux);
|
||||
|
||||
--destructive: var(--slp-error);
|
||||
--destructive-foreground: #ffffff;
|
||||
|
||||
--border: var(--slp-line);
|
||||
--input: var(--slp-line);
|
||||
--ring: var(--slp-bordeaux);
|
||||
|
||||
--radius: 0.375rem;
|
||||
|
||||
--font-sans: var(--slp-font-body);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: #141414;
|
||||
--foreground: #f5f5f5;
|
||||
|
||||
--card: #1e1e1e;
|
||||
--card-foreground: #f5f5f5;
|
||||
|
||||
--popover: #1e1e1e;
|
||||
--popover-foreground: #f5f5f5;
|
||||
|
||||
--primary: #e0646c;
|
||||
--primary-foreground: #141414;
|
||||
|
||||
--secondary: #2a2a2a;
|
||||
--secondary-foreground: #f5f5f5;
|
||||
|
||||
--muted: #2a2a2a;
|
||||
--muted-foreground: #b0b0b0;
|
||||
|
||||
--accent: #3a1f21;
|
||||
--accent-foreground: #f0a0a6;
|
||||
|
||||
--destructive: #ff7b72;
|
||||
--destructive-foreground: #141414;
|
||||
|
||||
--border: #333333;
|
||||
--input: #333333;
|
||||
--ring: #e0646c;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: var(--slp-font-body);
|
||||
}
|
||||
Reference in New Issue
Block a user