feat(themes): add new themes 'onyx', 'nord', and 'paper' to palette

This commit is contained in:
shay
2026-04-16 12:18:26 -04:00
parent 5d9dd9aba8
commit 7c48e599dc
4 changed files with 83 additions and 6 deletions
BIN
View File
Binary file not shown.
+18 -1
View File
@@ -19,7 +19,8 @@ from flask import Flask, jsonify, request, Response
from .db import init_db, get_user, DUMMY_USERNAME, REQUIRED_FIELDS
from .data.processor import generate_widgets_from_github
from .widgets import compose_widget
from .models import AchievementData
from .widgets import compose_widget, render_achievements_widget
from .config import ENABLED_WIDGETS, WIDGET_ORDER
@@ -58,6 +59,7 @@ def generate():
widget_order = body.get("widget_order") or WIDGET_ORDER
custom_tags = body.get("custom_tags")
hidden_languages = body.get("hidden_languages")
achievements_raw = body.get("achievements") or []
fmt = body.get("format", "svg")
github_data, used_dummy = _load_with_fallback(username)
@@ -70,6 +72,21 @@ def generate():
enabled=enabled,
)
# Render achievements if provided and enabled
if "achievements" in enabled and achievements_raw:
achs = [
AchievementData(
title=a.get("title", ""),
subtitle=a.get("subtitle", ""),
event_date=a.get("event_date", ""),
icon=a.get("icon", "trophy"),
)
for a in achievements_raw
if a.get("title")
]
if achs:
widgets["achievements"] = render_achievements_widget(achs, theme)
ordered = [w for w in widget_order if w in enabled and w in widgets and widgets[w]]
display_name = username if not used_dummy else username
composite = compose_widget(
+50 -2
View File
@@ -1,7 +1,8 @@
"""Theme definitions and color palettes."""
THEMES = {
"dark": {
# --- Dark themes ---
"dark": { # kept for backwards compat; "midnight" is the alias
"bg": "#121820",
"card_bg": "#1a2230",
"card_border": "#2a3444",
@@ -15,7 +16,36 @@ THEMES = {
"pink": "#f778ba",
"grid": "#1e2836",
},
"light": {
"onyx": { # high-contrast neon on pure black
"bg": "#09090b",
"card_bg": "#18181b",
"card_border": "#27272a",
"text": "#fafafa",
"text_secondary": "#a1a1aa",
"accent": "#a78bfa",
"green": "#4ade80",
"orange": "#fb923c",
"red": "#f87171",
"purple": "#c084fc",
"pink": "#f472b6",
"grid": "#27272a",
},
"nord": { # muted pastel on slate-blue — clearly cooler
"bg": "#1e2433",
"card_bg": "#2a3142",
"card_border": "#3d4659",
"text": "#e5e9f0",
"text_secondary": "#8892a4",
"accent": "#88c0d0",
"green": "#a3be8c",
"orange": "#ebcb8b",
"red": "#bf616a",
"purple": "#b48ead",
"pink": "#d08770",
"grid": "#333d50",
},
# --- Light themes ---
"light": { # kept for backwards compat; "clean" is the alias
"bg": "#ffffff",
"card_bg": "#f6f8fa",
"card_border": "#d8dee4",
@@ -29,8 +59,26 @@ THEMES = {
"pink": "#bf3989",
"grid": "#eaeef2",
},
"paper": {
"bg": "#faf8f5",
"card_bg": "#f5f0eb",
"card_border": "#e0d8cf",
"text": "#3d3529",
"text_secondary": "#7a7062",
"accent": "#b45309",
"green": "#4d7c0f",
"orange": "#a16207",
"red": "#b91c1c",
"purple": "#7e22ce",
"pink": "#be185d",
"grid": "#ebe5dd",
},
}
# Aliases so the frontend can use friendly names
THEMES["midnight"] = THEMES["dark"]
THEMES["clean"] = THEMES["light"]
TAG_COLORS = {
"ml-engineer": "#bc8cff",
"frontend": "#58a6ff",
+15 -3
View File
@@ -8,13 +8,25 @@ from ..utils import card_wrapper
def render_impact_widget(weeks: list[ImpactWeek], theme_name: str = "dark", period: str = "6mo") -> str:
"""Renders the impact timeline chart widget."""
t = THEMES[theme_name]
if not weeks:
return ""
w, h = 380, 200
chart_x, chart_y = 40, 8
chart_w, chart_h = 316, 82
if not weeks:
# Render an empty chart so the widget still appears
inner = f'''
<line x1="{chart_x}" y1="{chart_y + chart_h}" x2="{chart_x + chart_w}" y2="{chart_y + chart_h}" stroke="{t["grid"]}" stroke-width="0.5"/>
<text x="{chart_x + chart_w / 2}" y="{chart_y + chart_h / 2 + 4}" text-anchor="middle"
font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
font-size="11" fill="{t["text_secondary"]}">No contribution data yet</text>
<g transform="translate(20, {chart_y + chart_h + 46})">
<text x="0" y="0" font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
font-size="13" font-weight="700" fill="{t["text"]}">0</text>
<text x="0" y="14" font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
font-size="9" fill="{t["text_secondary"]}">commits over {period}</text>
</g>'''
return card_wrapper(inner, w, h, t, "Impact Timeline")
max_commits = max((wk.commits for wk in weeks), default=1) or 1
n = len(weeks)