Admin-teksten en merklogo: Weergavenaam, Wachtwoord wijzigen, Eerste account aanmaken, logo per thema
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
@@ -10,6 +10,7 @@ describe('resolveTheme', () => {
|
||||
|
||||
expect(path.basename(theme.css)).toBe('none.css');
|
||||
expect(theme.favicon).toBeNull();
|
||||
expect(theme.logo).toBeNull();
|
||||
expect(fs.readFileSync(theme.css, 'utf-8')).not.toMatch(/--[a-z-]+\s*:/);
|
||||
});
|
||||
|
||||
@@ -21,6 +22,25 @@ describe('resolveTheme', () => {
|
||||
expect(theme.favicon !== null && fs.existsSync(theme.favicon)).toBe(true);
|
||||
});
|
||||
|
||||
it('ships the asf brand logo for both colour modes', () => {
|
||||
const { logo } = resolveTheme('asf');
|
||||
|
||||
expect(logo).not.toBeNull();
|
||||
expect(fs.existsSync(logo!.onLight) && fs.existsSync(logo!.onDark)).toBe(true);
|
||||
});
|
||||
|
||||
it('treats a theme with only one logo variant as having no logo', () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'themes-'));
|
||||
try {
|
||||
fs.mkdirSync(path.join(dir, 'half'));
|
||||
fs.writeFileSync(path.join(dir, 'half', 'theme.css'), '');
|
||||
fs.writeFileSync(path.join(dir, 'half', 'logo-on-light.png'), '');
|
||||
expect(resolveTheme('half', dir).logo).toBeNull();
|
||||
} finally {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it('lists the available themes', () => {
|
||||
expect(availableThemes()).toContain('asf');
|
||||
});
|
||||
|
||||
@@ -6,6 +6,12 @@ export interface ResolvedTheme {
|
||||
css: string;
|
||||
/** Absolute path of the theme favicon, or null when there is no theme or it ships none. */
|
||||
favicon: string | null;
|
||||
/**
|
||||
* Brand logo files: one for light backgrounds (dark ink) and one for dark backgrounds (light
|
||||
* ink), or null when the theme ships none. Both or neither: a logo that is invisible in one
|
||||
* colour mode is worse than none.
|
||||
*/
|
||||
logo: { onLight: string; onDark: string } | null;
|
||||
}
|
||||
|
||||
const THEMES_DIR = import.meta.dirname;
|
||||
@@ -27,7 +33,7 @@ export function availableThemes(dir: string = THEMES_DIR): string[] {
|
||||
export function resolveTheme(name: string | undefined, dir: string = THEMES_DIR): ResolvedTheme {
|
||||
const trimmed = (name ?? '').trim();
|
||||
if (trimmed === '') {
|
||||
return { css: path.join(dir, 'none.css'), favicon: null };
|
||||
return { css: path.join(dir, 'none.css'), favicon: null, logo: null };
|
||||
}
|
||||
|
||||
// The name becomes a path segment: only known theme folders are accepted.
|
||||
@@ -39,8 +45,11 @@ export function resolveTheme(name: string | undefined, dir: string = THEMES_DIR)
|
||||
}
|
||||
|
||||
const favicon = path.join(dir, trimmed, 'favicon.png');
|
||||
const onLight = path.join(dir, trimmed, 'logo-on-light.png');
|
||||
const onDark = path.join(dir, trimmed, 'logo-on-dark.png');
|
||||
return {
|
||||
css: path.join(dir, trimmed, 'theme.css'),
|
||||
favicon: fs.existsSync(favicon) ? favicon : null,
|
||||
logo: fs.existsSync(onLight) && fs.existsSync(onDark) ? { onLight, onDark } : null,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user