diff --git a/generator/src/widgets/languages.py b/generator/src/widgets/languages.py index 401a82a..00bb9a6 100644 --- a/generator/src/widgets/languages.py +++ b/generator/src/widgets/languages.py @@ -40,12 +40,18 @@ def render_languages_widget(languages: list[LanguageData], theme_name: str = "da for lang in langs: lang.percentage = round(lang.percentage * factor, 1) - # Calculate center position to align with legend - legend_start = 20 - legend_height = len(langs) * 22 - cy = legend_start + legend_height / 2 cx, r = 60, 44 inner_r = 28 + # The donut is 2 * (r + stroke-width/2) = 104px tall, but the legend block + # is only 22px per language. Centering the donut on the legend alone put + # its top above the card body whenever the legend was shorter than the + # donut (<= 3 languages), overlapping the card title. Center the donut and + # the legend on the body's midline instead; at >= 4 languages this is + # identical to the old geometry. + legend_height = len(langs) * 22 + rows_h = max(legend_height + 40, 120) + cy = rows_h / 2 + legend_start = (rows_h - legend_height) / 2 circumference = 2 * math.pi * r arcs = "" @@ -102,7 +108,6 @@ def render_languages_widget(languages: list[LanguageData], theme_name: str = "da # title="Languages", which adds a 36px translate to inner. The 36 is # already baked into the card height (rows_h + 36); the attribution # adds another 16 on top, positioned 8px from the bottom of the card. - rows_h = max(len(langs) * 22 + 40, 120) footer_h = 16 card_h = rows_h + 36 + footer_h inner += f'''