Skip to content

Commit b41d4d9

Browse files
lesnik512claude
andauthored
Per-repo social cards for docs-site repos (#23)
* docs: design per-repo social cards Two-panel green/cream 1280x640 og:image for the 7 docs-site repos, built on the project marks: green panel holds the repo mark, cream panel holds name, canonical tagline, and docs URL. Generated into brand/projects/<repo>/social-card.svg|png. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs: implementation plan for per-repo social cards Five TDD tasks: GREEN_MUTED token, fit/wrap text helpers, DOCS_REPOS table + project_social_card, the docs-only render pass, and docs/architecture. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(brand): add GREEN_MUTED token for card taglines * feat(brand): text fit + wrap helpers for cards * feat(brand): DOCS_REPOS + project_social_card composition * feat(brand): render social cards for docs-site repos * docs(brand): document per-repo social cards Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5654935 commit b41d4d9

23 files changed

Lines changed: 772 additions & 2 deletions

File tree

‎architecture/brand-marks.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ project templates reuse the org chevron. `modern-di-faststream` is the only
1515
mark using a partner's literal logo path (FastStream's, recoloured); other
1616
integration cues are redrawn evocations. Outputs: `mark.svg`, `lockup.svg`
1717
(+ `mark-512/1024.png`). Regenerate via `uv run python -m brand.build.render`.
18+
Repos with a live docs site (`projects.py::DOCS_REPOS`, a subset of `MANIFEST`)
19+
additionally get a 1280×640 `social-card.svg|png` — a two-panel og:image
20+
(green mark panel + cream name/tagline/url), built with the same frame +
21+
symbols and the `fit_text`/`wrap_text` helpers. Taglines are the canonical
22+
`profile/README.md` one-liners.

‎brand/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ one gold inner symbol (see `brand/build/projects.py::MANIFEST`). Regenerate
4545
with `uv run python -m brand.build.render`; outputs land in
4646
`brand/projects/<repo>/` as `mark.svg`, `lockup.svg` (+ PNGs). These are
4747
large-format only — every repo's favicon/avatar stays the org mark.
48+
Repos with a docs site also get a `social-card.svg` + `social-card.png`
49+
(1280×640 og:image): the repo mark on a green panel beside its name, tagline,
50+
and docs URL on cream. The docs-site repos are listed in
51+
`brand/build/projects.py::DOCS_REPOS`.
4852

4953
## Deferred (not in this kit)
5054

‎brand/build/projects.py‎

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ def project_lockup(repo: str) -> str:
8181

8282

8383
def render_projects(out_dir: Path | None = None) -> list[Path]:
84-
"""Write mark.svg (+ PNGs) for every repo under out_dir/<repo>/."""
84+
"""Write mark.svg, lockup.svg (+ PNGs) for every repo under out_dir/<repo>/.
85+
86+
Docs-site repos (DOCS_REPOS) also get social-card.svg/png (1280×640)."""
8587
base = out_dir if out_dir is not None else PROJECTS
8688
written: list[Path] = []
8789
for repo in MANIFEST:
@@ -92,5 +94,120 @@ def render_projects(out_dir: Path | None = None) -> list[Path]:
9294
for sz in _PNG_SIZES:
9395
export_png(svg, d / f"mark-{sz}.png", width=sz, height=sz)
9496
(d / "lockup.svg").write_text(project_lockup(repo) + "\n", encoding="utf-8")
97+
if repo in DOCS_REPOS:
98+
card = d / "social-card.svg"
99+
card.write_text(
100+
project_social_card(repo, tagline=DOCS_REPOS[repo]) + "\n",
101+
encoding="utf-8",
102+
)
103+
export_png(card, d / "social-card.png", width=_CARD_W, height=_CARD_H)
95104
written.append(svg)
96105
return written
106+
107+
108+
def _measure(text: str, size: float) -> float:
109+
_, w = outline_text(text, size, x=0, baseline_y=0, anchor="start", color="#000000")
110+
return w
111+
112+
113+
def fit_text(
114+
text: str,
115+
base_size: float,
116+
max_w: float,
117+
*,
118+
color: str,
119+
x: float,
120+
baseline_y: float,
121+
) -> tuple[str, float]:
122+
"""Render `text` left-anchored; shrink the font so its width fits max_w."""
123+
natural = _measure(text, base_size)
124+
size = base_size if natural <= max_w else base_size * max_w / natural
125+
svg, _ = outline_text(
126+
text, size, x=x, baseline_y=baseline_y, anchor="start", color=color
127+
)
128+
return svg, size
129+
130+
131+
def wrap_text(text: str, size: float, max_w: float) -> list[str]:
132+
"""Greedy word-wrap to lines no wider than max_w."""
133+
lines: list[str] = []
134+
cur = ""
135+
for word in text.split():
136+
trial = (cur + " " + word).strip()
137+
if cur and _measure(trial, size) > max_w:
138+
lines.append(cur)
139+
cur = word
140+
else:
141+
cur = trial
142+
if cur:
143+
lines.append(cur)
144+
return lines
145+
146+
147+
DOCS_REPOS: dict[str, str] = {
148+
"modern-di": "powerful DI framework with scopes",
149+
"that-depends": "predecessor DI framework, still actively maintained",
150+
"lite-bootstrap": "lightweight package for bootstrapping new microservices",
151+
"httpware": "HTTP client framework with sync/async clients, middleware chain, and built-in resilience (retry, bulkhead)",
152+
"faststream-redis-timers": "FastStream broker integration for Redis-backed distributed timer scheduling",
153+
"faststream-outbox": "FastStream broker integration for the transactional outbox pattern with Postgres",
154+
"semvertag": "auto-tag your GitHub/GitLab repo with semantic version tags from CI",
155+
}
156+
157+
_CARD_W = 1280
158+
_CARD_H = 640
159+
_PANEL = 460 # green panel width
160+
_TEXT_X = 520 # text column left edge
161+
_TEXT_W = 700 # text column width
162+
_NAME_BASE = 74
163+
_TAG_SIZE = 30
164+
_URL_SIZE = 26
165+
166+
167+
def project_social_card(repo: str, *, tagline: str) -> str:
168+
"""1280x640 og:image: green mark panel + cream name/tagline/url panel."""
169+
panels = (
170+
f'<rect width="{_PANEL}" height="{_CARD_H}" fill="{t.GREEN_SURFACE}"/>'
171+
f'<rect x="{_PANEL}" width="{_CARD_W - _PANEL}" height="{_CARD_H}" fill="{t.CREAM}"/>'
172+
)
173+
frame = g.project_frame(struct=t.CREAM, accent=t.GOLD_DARK)
174+
inner = MANIFEST[repo]()
175+
mark = f'<g transform="translate(80,170) scale(3.0)">{frame}{inner}</g>'
176+
177+
tag_lines = wrap_text(tagline, _TAG_SIZE, _TEXT_W)
178+
n = len(tag_lines)
179+
# block = name + 26 gap + n*38 tagline lines + 44 gap + url(30); centre vertically
180+
block_h = _NAME_BASE + 26 + n * 38 + 44 + 30
181+
top = (_CARD_H - block_h) / 2
182+
name_base = top + _NAME_BASE
183+
name_svg, _ = fit_text(
184+
repo, _NAME_BASE, _TEXT_W, color=t.GREEN_INK, x=_TEXT_X, baseline_y=name_base
185+
)
186+
y = name_base + 26
187+
tag_svg = ""
188+
for line in tag_lines:
189+
y += 38
190+
seg, _ = outline_text(
191+
line,
192+
_TAG_SIZE,
193+
x=_TEXT_X,
194+
baseline_y=y,
195+
anchor="start",
196+
color=t.GREEN_MUTED,
197+
)
198+
tag_svg += seg
199+
y += 44
200+
url_svg, _ = outline_text(
201+
f"{repo}.modern-python.org",
202+
_URL_SIZE,
203+
x=_TEXT_X,
204+
baseline_y=y,
205+
anchor="start",
206+
color=t.GOLD_LIGHT,
207+
letter_spacing=2,
208+
)
209+
return (
210+
f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {_CARD_W} {_CARD_H}" '
211+
f'role="img" aria-label="{repo} — {tagline}">'
212+
f"{panels}{mark}{name_svg}{tag_svg}{url_svg}</svg>"
213+
)

‎brand/build/symbols.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ def terminal(cx: float, cy: float, r: float) -> str:
144144
(chx - reach, cy + hgt),
145145
(chx - reach + th * 1.7, cy),
146146
]
147-
chevron = '<polygon points="' + " ".join(f"{px:.1f},{py:.1f}" for px, py in pts) + f'" fill="{CREAM}"/>'
147+
chevron = (
148+
'<polygon points="'
149+
+ " ".join(f"{px:.1f},{py:.1f}" for px, py in pts)
150+
+ f'" fill="{CREAM}"/>'
151+
)
148152
# bold T
149153
tx = cx + 0.42 * r
150154
half, hbar, stem, h = 0.32 * r, 0.16 * r, 0.16 * r, 0.62 * r

‎brand/build/tokens.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
GOLD_LIGHT = "#c98a00" # gold accent on cream
55
GOLD_DARK = "#f0b528" # gold accent on green/dark
66
CREAM = "#f4f1e8" # light surface; also the light "ink" on green (not pure white)
7+
GREEN_MUTED = "#5b6f63" # desaturated green for tagline text on cream
50.4 KB
Loading

‎brand/projects/faststream-outbox/social-card.svg‎

Lines changed: 1 addition & 0 deletions
Loading
53.8 KB
Loading

‎brand/projects/faststream-redis-timers/social-card.svg‎

Lines changed: 1 addition & 0 deletions
Loading
45.7 KB
Loading

0 commit comments

Comments
 (0)