Harden star chart responsive layout
Browse files- README.md +0 -0
- assets/star-history-mobile-dark.svg +39 -39
- assets/star-history-mobile.svg +39 -39
- docs/assets/star-history-mobile-dark.svg +39 -39
- docs/assets/star-history-mobile.svg +39 -39
- docs/index.html +8 -3
- scripts/build_star_history.py +81 -17
README.md
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
assets/star-history-mobile-dark.svg
CHANGED
|
|
|
|
assets/star-history-mobile.svg
CHANGED
|
|
|
|
docs/assets/star-history-mobile-dark.svg
CHANGED
|
|
|
|
docs/assets/star-history-mobile.svg
CHANGED
|
|
|
|
docs/index.html
CHANGED
|
@@ -1000,12 +1000,17 @@
|
|
| 1000 |
.loop-stage:nth-child(4) { border-left: 0; }
|
| 1001 |
.loop-stage:nth-child(n+4) { border-top: 1px solid var(--line); }
|
| 1002 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1003 |
@media (max-width: 560px) {
|
| 1004 |
html { scroll-padding-top: 74px; }
|
| 1005 |
.nav { min-height: 64px; gap: 8px; }
|
| 1006 |
.links.open { top: 64px; max-height: calc(100vh - 64px); }
|
| 1007 |
-
.project-links .nav-link:first-child { display: none; }
|
| 1008 |
-
.project-links { gap: 6px; }
|
| 1009 |
.nav-link { min-height: 44px; padding-inline: 12px; }
|
| 1010 |
.brand { min-width: 0; gap: 8px; }
|
| 1011 |
.brand .logo { width: 28px; height: 28px; }
|
|
@@ -2022,7 +2027,7 @@
|
|
| 2022 |
</div>
|
| 2023 |
<a class="star-history-chart" href="https://github.com/ChaoYue0307/awesome-loop-engineering" aria-label="Open Awesome Loop Engineering on GitHub">
|
| 2024 |
<picture>
|
| 2025 |
-
<source media="(max-width:
|
| 2026 |
<img src="assets/star-history.svg" alt="GitHub star growth for Awesome Loop Engineering" width="1200" height="560" loading="lazy">
|
| 2027 |
</picture>
|
| 2028 |
</a>
|
|
|
|
| 1000 |
.loop-stage:nth-child(4) { border-left: 0; }
|
| 1001 |
.loop-stage:nth-child(n+4) { border-top: 1px solid var(--line); }
|
| 1002 |
}
|
| 1003 |
+
@media (min-width: 561px) and (max-width: 768px) {
|
| 1004 |
+
.star-history-chart { max-width: 680px; margin-inline: auto; }
|
| 1005 |
+
}
|
| 1006 |
+
@media (max-width: 600px) {
|
| 1007 |
+
.project-links .nav-link:first-child { display: none; }
|
| 1008 |
+
.project-links { gap: 6px; }
|
| 1009 |
+
}
|
| 1010 |
@media (max-width: 560px) {
|
| 1011 |
html { scroll-padding-top: 74px; }
|
| 1012 |
.nav { min-height: 64px; gap: 8px; }
|
| 1013 |
.links.open { top: 64px; max-height: calc(100vh - 64px); }
|
|
|
|
|
|
|
| 1014 |
.nav-link { min-height: 44px; padding-inline: 12px; }
|
| 1015 |
.brand { min-width: 0; gap: 8px; }
|
| 1016 |
.brand .logo { width: 28px; height: 28px; }
|
|
|
|
| 2027 |
</div>
|
| 2028 |
<a class="star-history-chart" href="https://github.com/ChaoYue0307/awesome-loop-engineering" aria-label="Open Awesome Loop Engineering on GitHub">
|
| 2029 |
<picture>
|
| 2030 |
+
<source media="(max-width: 768px)" srcset="assets/star-history-mobile.svg" width="640" height="640">
|
| 2031 |
<img src="assets/star-history.svg" alt="GitHub star growth for Awesome Loop Engineering" width="1200" height="560" loading="lazy">
|
| 2032 |
</picture>
|
| 2033 |
</a>
|
scripts/build_star_history.py
CHANGED
|
@@ -303,6 +303,46 @@ def fmt(value: float) -> str:
|
|
| 303 |
return f"{value:.2f}".rstrip("0").rstrip(".")
|
| 304 |
|
| 305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
def star_path(cx: float, cy: float, outer: float, inner: float) -> str:
|
| 307 |
points: list[str] = []
|
| 308 |
for index in range(10):
|
|
@@ -332,19 +372,19 @@ def chart_svg(repository: str, payload: dict[str, object], theme_name: str, comp
|
|
| 332 |
history_days = (latest.date() - first.date()).days + 1
|
| 333 |
|
| 334 |
if compact:
|
| 335 |
-
width, height =
|
| 336 |
-
frame_x, frame_y, frame_width, frame_height = 16, 16,
|
| 337 |
-
header_x =
|
| 338 |
-
eyebrow_y, title_y =
|
| 339 |
-
subtitle_y, subtitle_gap =
|
| 340 |
-
eyebrow_size, title_size, subtitle_size =
|
| 341 |
-
meta_y =
|
| 342 |
-
plot_left, plot_right, plot_top, plot_bottom =
|
| 343 |
-
y_label_x, x_label_y =
|
| 344 |
-
axis_font, line_width =
|
| 345 |
callout_width, callout_height, callout_font = 142, 40, 18
|
| 346 |
-
footer_line_y, footer_text_y, footer_range_y =
|
| 347 |
-
footer_left, footer_right, footer_font =
|
| 348 |
x_tick_count = 3
|
| 349 |
else:
|
| 350 |
width, height = 1200, 560
|
|
@@ -362,6 +402,30 @@ def chart_svg(repository: str, payload: dict[str, object], theme_name: str, comp
|
|
| 362 |
footer_left, footer_right, footer_font = 78, 1122, 13
|
| 363 |
x_tick_count = 5
|
| 364 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
plot_width = plot_right - plot_left
|
| 366 |
plot_height = plot_bottom - plot_top
|
| 367 |
y_step = nice_step(peak)
|
|
@@ -421,7 +485,7 @@ def chart_svg(repository: str, payload: dict[str, object], theme_name: str, comp
|
|
| 421 |
f' <rect x="{frame_x}" y="{frame_y}" width="{frame_width}" height="{frame_height}" rx="8" fill="{theme.background}" stroke="{theme.border}" stroke-width="2"/>',
|
| 422 |
f' <path d="{star_path(header_x + 7, eyebrow_y - 5, 8 if compact else 7, 3.5 if compact else 3)}" fill="{theme.point}" stroke="{theme.text}" stroke-width="1"/>',
|
| 423 |
f' <text x="{header_x + (24 if compact else 21)}" y="{eyebrow_y}" fill="{theme.brand}" font-size="{eyebrow_size}" font-weight="800">STAR HISTORY</text>',
|
| 424 |
-
f' <text x="{header_x}" y="{title_y}" fill="{theme.text}" font-size="{title_size}" font-weight="760">{
|
| 425 |
]
|
| 426 |
|
| 427 |
if compact:
|
|
@@ -429,7 +493,7 @@ def chart_svg(repository: str, payload: dict[str, object], theme_name: str, comp
|
|
| 429 |
[
|
| 430 |
f' <text x="{header_x}" y="{subtitle_y}" fill="{theme.muted}" font-size="{subtitle_size}">Every star helps more builders discover</text>',
|
| 431 |
f' <text x="{header_x}" y="{subtitle_y + subtitle_gap}" fill="{theme.muted}" font-size="{subtitle_size}">loop engineering.</text>',
|
| 432 |
-
f' <text x="{header_x}" y="{meta_y}" fill="{theme.brand}" font-size="{eyebrow_size}" font-weight="700">{history_days} days of growth</text>',
|
| 433 |
f' <text x="{footer_right}" y="{meta_y}" fill="{theme.muted}" font-size="{eyebrow_size}" text-anchor="end">Updated {escape(date_label(latest))}</text>',
|
| 434 |
]
|
| 435 |
)
|
|
@@ -437,7 +501,7 @@ def chart_svg(repository: str, payload: dict[str, object], theme_name: str, comp
|
|
| 437 |
rows.extend(
|
| 438 |
[
|
| 439 |
f' <text x="{header_x}" y="{subtitle_y}" fill="{theme.muted}" font-size="{subtitle_size}">Every star helps more builders discover loop engineering.</text>',
|
| 440 |
-
f' <text x="{footer_right}" y="{meta_y}" fill="{theme.text}" font-size="28" font-weight="760" text-anchor="end">{history_days}</text>',
|
| 441 |
f' <text x="{footer_right}" y="{meta_y + 25}" fill="{theme.muted}" font-size="12" font-weight="750" text-anchor="end">DAYS OF GROWTH</text>',
|
| 442 |
]
|
| 443 |
)
|
|
@@ -447,7 +511,7 @@ def chart_svg(repository: str, payload: dict[str, object], theme_name: str, comp
|
|
| 447 |
rows.extend(
|
| 448 |
[
|
| 449 |
f' <line x1="{plot_left}" y1="{fmt(y)}" x2="{plot_right}" y2="{fmt(y)}" stroke="{theme.grid}" stroke-width="1" stroke-dasharray="3 9" stroke-linecap="round"/>',
|
| 450 |
-
f' <text x="{y_label_x}" y="{fmt(y + axis_font * 0.38)}" fill="{theme.muted}" font-size="{axis_font}" text-anchor="end">{tick}</text>',
|
| 451 |
]
|
| 452 |
)
|
| 453 |
|
|
@@ -481,7 +545,7 @@ def chart_svg(repository: str, payload: dict[str, object], theme_name: str, comp
|
|
| 481 |
[
|
| 482 |
f' <path d="M {fmt(callout_x + callout_width)} {fmt(callout_y + callout_height / 2)} L {fmt(release_x - (13 if compact else 11))} {fmt(endpoint_y)}" fill="none" stroke="{theme.line}" stroke-width="1.5" stroke-dasharray="3 5" stroke-linecap="round"/>',
|
| 483 |
f' <rect x="{fmt(callout_x)}" y="{fmt(callout_y)}" width="{callout_width}" height="{callout_height}" rx="8" fill="{theme.badge}" stroke="{theme.line}"/>',
|
| 484 |
-
f' <text x="{fmt(callout_x + callout_width / 2)}" y="{fmt(callout_y + callout_height * 0.68)}" fill="{theme.text}" font-size="{callout_font}" font-weight="700" text-anchor="middle">{
|
| 485 |
f' <line x1="{footer_left}" y1="{footer_line_y}" x2="{footer_right}" y2="{footer_line_y}" stroke="{theme.border}"/>',
|
| 486 |
f' <path d="{star_path(footer_left + 7, footer_text_y - 5, 6 if compact else 5, 2.7 if compact else 2.2)}" fill="{theme.point}" stroke="{theme.text}" stroke-width="0.8"/>',
|
| 487 |
f' <text x="{footer_left + 22}" y="{footer_text_y}" fill="{theme.muted}" font-size="{footer_font}">{escape(repository)}</text>',
|
|
|
|
| 303 |
return f"{value:.2f}".rstrip("0").rstrip(".")
|
| 304 |
|
| 305 |
|
| 306 |
+
def compact_number(value: int) -> str:
|
| 307 |
+
"""Keep large axis labels short without hiding the underlying exact count."""
|
| 308 |
+
if abs(value) < 1_000:
|
| 309 |
+
return f"{value:,}"
|
| 310 |
+
for divisor, suffix in ((1_000_000_000, "b"), (1_000_000, "m"), (1_000, "k")):
|
| 311 |
+
if abs(value) >= divisor:
|
| 312 |
+
scaled = value / divisor
|
| 313 |
+
precision = 1 if abs(scaled) < 10 and not scaled.is_integer() else 0
|
| 314 |
+
formatted = f"{scaled:.{precision}f}"
|
| 315 |
+
if precision:
|
| 316 |
+
formatted = formatted.rstrip("0").rstrip(".")
|
| 317 |
+
return formatted + suffix
|
| 318 |
+
return f"{value:,}"
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
def estimated_text_width(value: str, font_size: float, bold: bool = False) -> float:
|
| 322 |
+
"""Estimate rounded UI-font width conservatively for responsive SVG labels."""
|
| 323 |
+
width_in_em = 0.0
|
| 324 |
+
for character in value:
|
| 325 |
+
if character.isspace():
|
| 326 |
+
width_in_em += 0.32
|
| 327 |
+
elif character in "ilI1.,:'|":
|
| 328 |
+
width_in_em += 0.3
|
| 329 |
+
elif character in "mwMW@%&":
|
| 330 |
+
width_in_em += 0.86
|
| 331 |
+
elif character.isupper():
|
| 332 |
+
width_in_em += 0.66
|
| 333 |
+
else:
|
| 334 |
+
width_in_em += 0.56
|
| 335 |
+
weight_factor = 1.04 if bold else 1.0
|
| 336 |
+
return width_in_em * font_size * weight_factor
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
def fit_font_size(value: str, preferred: float, max_width: float, minimum: float) -> float:
|
| 340 |
+
estimated = estimated_text_width(value, preferred, bold=True)
|
| 341 |
+
if estimated <= max_width:
|
| 342 |
+
return preferred
|
| 343 |
+
return max(minimum, preferred * max_width / estimated)
|
| 344 |
+
|
| 345 |
+
|
| 346 |
def star_path(cx: float, cy: float, outer: float, inner: float) -> str:
|
| 347 |
points: list[str] = []
|
| 348 |
for index in range(10):
|
|
|
|
| 372 |
history_days = (latest.date() - first.date()).days + 1
|
| 373 |
|
| 374 |
if compact:
|
| 375 |
+
width, height = 640, 640
|
| 376 |
+
frame_x, frame_y, frame_width, frame_height = 16, 16, 608, 608
|
| 377 |
+
header_x = 44
|
| 378 |
+
eyebrow_y, title_y = 60, 104
|
| 379 |
+
subtitle_y, subtitle_gap = 139, 26
|
| 380 |
+
eyebrow_size, title_size, subtitle_size = 18, 40, 20
|
| 381 |
+
meta_y = 204
|
| 382 |
+
plot_left, plot_right, plot_top, plot_bottom = 72, 594, 238, 493
|
| 383 |
+
y_label_x, x_label_y = 56, 526
|
| 384 |
+
axis_font, line_width = 20, 5
|
| 385 |
callout_width, callout_height, callout_font = 142, 40, 18
|
| 386 |
+
footer_line_y, footer_text_y, footer_range_y = 556, 583, 608
|
| 387 |
+
footer_left, footer_right, footer_font = 44, 594, 18
|
| 388 |
x_tick_count = 3
|
| 389 |
else:
|
| 390 |
width, height = 1200, 560
|
|
|
|
| 402 |
footer_left, footer_right, footer_font = 78, 1122, 13
|
| 403 |
x_tick_count = 5
|
| 404 |
|
| 405 |
+
title_text = f"{total:,} stars and counting"
|
| 406 |
+
title_max_width = (plot_right - header_x) if compact else 760
|
| 407 |
+
title_size = fit_font_size(
|
| 408 |
+
title_text,
|
| 409 |
+
title_size,
|
| 410 |
+
title_max_width,
|
| 411 |
+
28 if compact else 24,
|
| 412 |
+
)
|
| 413 |
+
callout_text = f"{total:,} stars"
|
| 414 |
+
callout_padding = 30 if compact else 26
|
| 415 |
+
callout_width = max(
|
| 416 |
+
callout_width,
|
| 417 |
+
min(
|
| 418 |
+
plot_right - plot_left - 56,
|
| 419 |
+
estimated_text_width(callout_text, callout_font, bold=True) + callout_padding,
|
| 420 |
+
),
|
| 421 |
+
)
|
| 422 |
+
callout_font = fit_font_size(
|
| 423 |
+
callout_text,
|
| 424 |
+
callout_font,
|
| 425 |
+
callout_width - callout_padding,
|
| 426 |
+
13 if compact else 11,
|
| 427 |
+
)
|
| 428 |
+
|
| 429 |
plot_width = plot_right - plot_left
|
| 430 |
plot_height = plot_bottom - plot_top
|
| 431 |
y_step = nice_step(peak)
|
|
|
|
| 485 |
f' <rect x="{frame_x}" y="{frame_y}" width="{frame_width}" height="{frame_height}" rx="8" fill="{theme.background}" stroke="{theme.border}" stroke-width="2"/>',
|
| 486 |
f' <path d="{star_path(header_x + 7, eyebrow_y - 5, 8 if compact else 7, 3.5 if compact else 3)}" fill="{theme.point}" stroke="{theme.text}" stroke-width="1"/>',
|
| 487 |
f' <text x="{header_x + (24 if compact else 21)}" y="{eyebrow_y}" fill="{theme.brand}" font-size="{eyebrow_size}" font-weight="800">STAR HISTORY</text>',
|
| 488 |
+
f' <text x="{header_x}" y="{title_y}" fill="{theme.text}" font-size="{fmt(title_size)}" font-weight="760">{title_text}</text>',
|
| 489 |
]
|
| 490 |
|
| 491 |
if compact:
|
|
|
|
| 493 |
[
|
| 494 |
f' <text x="{header_x}" y="{subtitle_y}" fill="{theme.muted}" font-size="{subtitle_size}">Every star helps more builders discover</text>',
|
| 495 |
f' <text x="{header_x}" y="{subtitle_y + subtitle_gap}" fill="{theme.muted}" font-size="{subtitle_size}">loop engineering.</text>',
|
| 496 |
+
f' <text x="{header_x}" y="{meta_y}" fill="{theme.brand}" font-size="{eyebrow_size}" font-weight="700">{compact_number(history_days)} days of growth</text>',
|
| 497 |
f' <text x="{footer_right}" y="{meta_y}" fill="{theme.muted}" font-size="{eyebrow_size}" text-anchor="end">Updated {escape(date_label(latest))}</text>',
|
| 498 |
]
|
| 499 |
)
|
|
|
|
| 501 |
rows.extend(
|
| 502 |
[
|
| 503 |
f' <text x="{header_x}" y="{subtitle_y}" fill="{theme.muted}" font-size="{subtitle_size}">Every star helps more builders discover loop engineering.</text>',
|
| 504 |
+
f' <text x="{footer_right}" y="{meta_y}" fill="{theme.text}" font-size="28" font-weight="760" text-anchor="end">{history_days:,}</text>',
|
| 505 |
f' <text x="{footer_right}" y="{meta_y + 25}" fill="{theme.muted}" font-size="12" font-weight="750" text-anchor="end">DAYS OF GROWTH</text>',
|
| 506 |
]
|
| 507 |
)
|
|
|
|
| 511 |
rows.extend(
|
| 512 |
[
|
| 513 |
f' <line x1="{plot_left}" y1="{fmt(y)}" x2="{plot_right}" y2="{fmt(y)}" stroke="{theme.grid}" stroke-width="1" stroke-dasharray="3 9" stroke-linecap="round"/>',
|
| 514 |
+
f' <text x="{y_label_x}" y="{fmt(y + axis_font * 0.38)}" fill="{theme.muted}" font-size="{axis_font}" text-anchor="end">{compact_number(tick)}</text>',
|
| 515 |
]
|
| 516 |
)
|
| 517 |
|
|
|
|
| 545 |
[
|
| 546 |
f' <path d="M {fmt(callout_x + callout_width)} {fmt(callout_y + callout_height / 2)} L {fmt(release_x - (13 if compact else 11))} {fmt(endpoint_y)}" fill="none" stroke="{theme.line}" stroke-width="1.5" stroke-dasharray="3 5" stroke-linecap="round"/>',
|
| 547 |
f' <rect x="{fmt(callout_x)}" y="{fmt(callout_y)}" width="{callout_width}" height="{callout_height}" rx="8" fill="{theme.badge}" stroke="{theme.line}"/>',
|
| 548 |
+
f' <text x="{fmt(callout_x + callout_width / 2)}" y="{fmt(callout_y + callout_height * 0.68)}" fill="{theme.text}" font-size="{fmt(callout_font)}" font-weight="700" text-anchor="middle">{callout_text}</text>',
|
| 549 |
f' <line x1="{footer_left}" y1="{footer_line_y}" x2="{footer_right}" y2="{footer_line_y}" stroke="{theme.border}"/>',
|
| 550 |
f' <path d="{star_path(footer_left + 7, footer_text_y - 5, 6 if compact else 5, 2.7 if compact else 2.2)}" fill="{theme.point}" stroke="{theme.text}" stroke-width="0.8"/>',
|
| 551 |
f' <text x="{footer_left + 22}" y="{footer_text_y}" fill="{theme.muted}" font-size="{footer_font}">{escape(repository)}</text>',
|