Mail-logo als vooraf samengestelde witte badge (geen grijze plaat); succes-toast bij rolwijziging
- themes/asf/logo-mail.png (+ make-mail-logo.py), geleverd als /admin/brand-logo-mail.png; ASF Email:LogoUrl wijst ernaar - Renderer: plaat weggehaald, licht logo 56px, dark-swap naar LogoDarkUrl blijft - UsersPage: toast na geslaagde rolwijziging (nl+en, ook Owner-bevestiging) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
One-off tool: builds logo-mail.png, the logo for e-mail headers, from logo-on-light.png.
|
||||
|
||||
Mail clients that invert colours themselves (the Gmail and Outlook apps) turn a dark logo on a transparent
|
||||
background into a dark logo on a dark header. A white rounded badge baked into the PNG is the same in every client:
|
||||
on the white mail card it disappears into the page, on a dark header it is a tidy white badge.
|
||||
|
||||
Run from this folder with Pillow installed: python make-mail-logo.py
|
||||
Displayed height in the mail is 56 px; the file is 3x that for sharp rendering on high-density screens.
|
||||
"""
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
SCALE = 3
|
||||
CONTENT_H = 40 * SCALE # the logo itself, 40 px high when displayed
|
||||
PAD = 8 * SCALE # white margin around it
|
||||
RADIUS = 8 * SCALE
|
||||
|
||||
src = Image.open("logo-on-light.png").convert("RGBA")
|
||||
src = src.crop(src.getchannel("A").getbbox()) # drop the transparent margin of the original
|
||||
logo = src.resize((round(src.width * CONTENT_H / src.height), CONTENT_H), Image.LANCZOS)
|
||||
|
||||
w, h = logo.width + 2 * PAD, CONTENT_H + 2 * PAD
|
||||
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, (PAD, PAD))
|
||||
badge.save("logo-mail.png", optimize=True)
|
||||
print(f"logo-mail.png {w}x{h} (display height {h // SCALE}px)")
|
||||
@@ -29,6 +29,14 @@ describe('resolveTheme', () => {
|
||||
expect(fs.existsSync(logo!.onLight) && fs.existsSync(logo!.onDark)).toBe(true);
|
||||
});
|
||||
|
||||
it('ships the asf e-mail logo (white badge) next to the others', () => {
|
||||
const { logo } = resolveTheme('asf');
|
||||
|
||||
expect(logo?.mail).not.toBeNull();
|
||||
expect(fs.existsSync(logo!.mail!)).toBe(true);
|
||||
expect(fs.readFileSync(logo!.mail!).subarray(1, 4).toString()).toBe('PNG');
|
||||
});
|
||||
|
||||
it('treats a theme with only one logo variant as having no logo', () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'themes-'));
|
||||
try {
|
||||
|
||||
@@ -11,7 +11,7 @@ export interface ResolvedTheme {
|
||||
* 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;
|
||||
logo: { onLight: string; onDark: string; mail: string | null } | null;
|
||||
}
|
||||
|
||||
const THEMES_DIR = import.meta.dirname;
|
||||
@@ -47,9 +47,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');
|
||||
// Optional: the logo for e-mail headers, on a baked-in white badge (see themes/asf/make-mail-logo.py).
|
||||
const mail = path.join(dir, trimmed, 'logo-mail.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,
|
||||
logo: fs.existsSync(onLight) && fs.existsSync(onDark) ? { onLight, onDark, mail: fs.existsSync(mail) ? mail : null } : null,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user