The reference design is the devplace Next.js main branch, not the terminal branch the previous commit tracked. Swap the token values to that design language: deep indigo page (#271b5b) over near-black indigo cards (#13112a/#1a1736), #11101f hairlines, purple-tinted text ramp (#e9e4ff/#c8c3e5/#9b93c9), burnt-orange primary accent (#b73f1e) with a raspberry hover (#af3050) and a rust-to-plum brand gradient, white on-accent text, soft rounded radii (8/12/16px), the reference's diffuse soft/medium/strong shadows, a warm accent glow, and Trebuchet MS as the UI font (system font - the vendored JetBrains Mono files are removed along with their base.html link). Follow-through updated to match: theme-color meta + PWA manifest (#271b5b), offline page, avatar fallback SVG, statistics chart palette (brand ramp), chat light-theme overrides, OG image + app icons regenerated in the new palette, and the /docs/styles-colors guide. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def avatar_url(style: str, seed: str, size: int = 128) -> str:
|
|
return f"/avatar/{style}/{seed}?size={size}"
|
|
|
|
|
|
def avatar_seed(user) -> str:
|
|
if not user:
|
|
return ""
|
|
return user.get("avatar_seed") or user.get("username") or ""
|
|
|
|
|
|
def generate_avatar_svg(seed: str) -> str:
|
|
try:
|
|
from multiavatar.multiavatar import multiavatar
|
|
|
|
svg = multiavatar(seed, None, None)
|
|
if svg and svg.strip().startswith("<svg"):
|
|
return svg
|
|
except Exception as e:
|
|
logger.exception(e)
|
|
logger.warning(f"Avatar generation failed for {seed}: {e}")
|
|
initial = seed[:1].upper() if seed else "?"
|
|
return (
|
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">'
|
|
f'<rect width="100" height="100" rx="50" fill="#b73f1e"/>'
|
|
f'<text x="50" y="65" text-anchor="middle" fill="white" font-size="40" font-weight="700" font-family="sans-serif">{initial}</text></svg>'
|
|
)
|