mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
feat(generator): scaffold + move widgets/themes/models/utils/processor/config
- Add generator/requirements.txt and generator/pytest.ini - git mv src/widgets, themes, models, utils, data/processor.py, config.py into generator/src/ - Fix relative imports in processor.py (moved up one level: .. → .) - Append service-specific env vars (PORT, DB paths, FETCHER_URL, etc.) to generator/src/config.py - git rm retired src/db, src/data/__init__.py, src/__init__.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
cb3ace8dcd
commit
3525144aeb
@@ -0,0 +1,52 @@
|
||||
"""Collaborators widget rendering."""
|
||||
|
||||
from ..models import CollaboratorData
|
||||
from ..themes import THEMES
|
||||
from ..utils import escape, card_wrapper
|
||||
|
||||
|
||||
def render_collaborators_widget(collabs: list[CollaboratorData], theme_name: str = "dark", settings: dict | None = None) -> str:
|
||||
"""Renders the top collaborators widget with avatars and contribution bars.
|
||||
|
||||
Settings:
|
||||
max_count (int): Number of collaborators to show (default 5)
|
||||
bar_color (str): Hex color for the contribution bars (default theme purple)
|
||||
"""
|
||||
t = THEMES[theme_name]
|
||||
s = settings or {}
|
||||
max_count = min(max(int(s.get("max_count", 5)), 1), 10)
|
||||
bar_color = s.get("bar_color") or t["purple"]
|
||||
items = ""
|
||||
|
||||
for i, c in enumerate(collabs[:max_count]):
|
||||
y = i * 50
|
||||
avatar_el = ""
|
||||
|
||||
if c.avatar_b64:
|
||||
avatar_el = f'''<image x="-18" y="-18" width="36" height="36" href="data:image/png;base64,{c.avatar_b64}" clip-path="url(#avatarClip)"/>'''
|
||||
else:
|
||||
hue = hash(c.username) % 360
|
||||
avatar_el = f'''
|
||||
<circle cx="0" cy="0" r="18" fill="hsl({hue}, 50%, 40%)"/>
|
||||
<text x="0" y="1" text-anchor="middle" dominant-baseline="middle"
|
||||
font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
|
||||
font-size="14" font-weight="600" fill="white">{escape(c.username[0].upper())}</text>'''
|
||||
|
||||
bar_max = max((x.shared_commits for x in collabs[:max_count]), default=1) or 1
|
||||
bar_w = c.shared_commits / bar_max * 120
|
||||
|
||||
items += f'''
|
||||
<g transform="translate(36, {y + 20})">
|
||||
{avatar_el}
|
||||
<text x="28" y="-2" font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
|
||||
font-size="13" font-weight="600" fill="{t["text"]}">{escape(c.username)}</text>
|
||||
<text x="28" y="14" font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
|
||||
font-size="10" fill="{t["text_secondary"]}">{c.shared_repos} repos · {c.shared_commits} commits</text>
|
||||
<rect x="200" y="-6" width="130" height="8" rx="4" fill="{t["grid"]}"/>
|
||||
<rect x="200" y="-6" width="{bar_w}" height="8" rx="4" fill="{bar_color}" opacity="0.8">
|
||||
<animate attributeName="width" from="0" to="{bar_w}" dur="0.6s" fill="freeze"/>
|
||||
</rect>
|
||||
</g>'''
|
||||
|
||||
total_h = len(collabs[:max_count]) * 50 + 48
|
||||
return card_wrapper(items, 380, total_h, t, "Top Collaborators")
|
||||
Reference in New Issue
Block a user