Repository navigation
feat(templates): add Year in Review developer template - #265
Conversation
A 'my year in code' card: the year large at the top with a name next to it, up to three big stats in a row (a value over a short label), and an optional one-line highlight. A stat with no value is left out and the others share the row, an empty highlight hides, and long values shrink and then end in an ellipsis. Neutral colors are mixed from the background and text colors so it reads on light backgrounds too. Closes codercops#248
anurag629
left a comment
There was a problem hiding this comment.
Thanks @Saifjafri212213, really thorough work. Check, all 1260 tests and the build pass on top of dev, and the default, white, pale accent, one stat, no stats, long values and FY2026-27 renders all look right.
One thing before I merge: with a long name in capitals, for example MAXIMILIANO WOLFGANG RODRIGUEZ, the year gets squeezed and its last digit runs into the name with no gap, because the year span can still shrink. Adding flexShrink: 0 to the year keeps its width and the 36px gap, and the name then wraps next to it (I tried it locally). A test for it would be good too.
With a long name in capitals the year was squeezed until its last digit ran into the name. Stop the year from shrinking so it keeps its width and the gap, and the name wraps beside it.
|
Thanks for the review, @anurag629, and for the fix. Done in 4f32227. I reproduced it first with I also added a test for it (it fails without the change). All 1261 tests, the type check and |
anurag629
left a comment
There was a problem hiding this comment.
Thanks @Saifjafri212213, that does it. The long name keeps its gap now, and check, all 1272 tests and the build pass on top of dev.
What and why
Adds the Year in Review developer template (
developer-year-review), for "my year in code" posts in December and January.1,248overcommits), and an optional one-line highlight at the bottom with a small accent bar.…. If a value of wide capitals still doesn't fit, it ends in an ellipsis rather than being clipped.2026; an empty year falls back to it. A longer year such asFY2026-27uses a smaller size.Fields:
name,year,stat1Valueandstat1Labeltostat3Valueandstat3Label,highlight, andbgColor,accentColor,textColorfromcommonFields. Re-exported insrc/templates/developer/index.tsand registered in the Developer block ofsrc/templates/registry.ts.Closes #248
How I tested this
tests/templates/developer-year-review.test.ts(49 tests): the defaults, the fields, stats (shared row, a missing, empty or spaces-only value, order, no row when there are none, an empty label, truncation, one size for all values, shrinking and growing, the ellipsis guard, numbers and line breaks), the highlight (hidden for empty, spaces, tabs and missing; truncation), the year and name (hidden name, year fallback, smaller size for a long year, truncation), odd input (null, numbers, objects, nothing filled in), layout (1200x630, Inter, display flex on every div, no grid, deterministic, only characters the fonts have), and contrast on five colour setups (dark, white, white with a pale accent, cream with a dark accent, dark with a dark accent)./create/developer?template=developer-year-review) with Chrome: the template shows in the gallery, the live preview updates as I edit, and Download PNG gives a 1200x630 PNG. No console errors or warnings. The screenshots below are from the server image API (/api/og).npm run check(0 errors, 0 warnings, same hints asdev) and the full suite: 1260/1260.AI assistance
An AI coding assistant helped write the template and the tests. I read through it, ran the checks above myself and looked at every rendered image.
Screenshots
Default colours
White background
White background, pale accent
Two stats share the row
Long values, name and labels
No highlight, no name
Checklist
width: '1200px', height: '630px'divhasdisplay: 'flex', inline styles only, flexbox onlyMath.random()or dates inrenderdescriptionand 5 tagscommonFields(bgColor, accentColor, textColor)dev, includes screenshots, saysCloses #248Notes for reviewers
/api/ogtreat an empty value as missing and use the template's default (this is how the shared URL builder and API work for every template). So to hide a stat or the highlight in the downloaded image or an image URL, use a single space. Screenshots 4 and 6 were made that way. I left the shared behaviour alone.