LB-1651: Add granular caption options and color customization to Art Creator grid stats#3634
LB-1651: Add granular caption options and color customization to Art Creator grid stats#3634Gopal7387 wants to merge 15 commits intometabrainz:masterfrom
Conversation
604e3c7 to
bb6e42d
Compare
|
I made some changes to the caption layout so it looks like the original plan. Now the strip is set up like a 2×2 grid(small 4 squares):
Each of these squares can be turned on or off by itself. The layout still looks neat. Tidy no matter which ones are turned on. |
|
Looks good (just looking at the screenshot, I haven't tested any behaviour). Some notes:
|
…resh-releases style
|
Hey @Aerozol Here is what I did:
Let me know if I need to make any changes, to the captions or anything else. |
|
Nice work, the UI looks good to me :) |
|
@anshg1214 |
|
I've deployed your PR on test.listenbrainz.org.
Can we find a way to align the test for Release name and artist name better? Most of the titles are being cut off. |
|
Hi @anshg1214 🙂 |
|
Thanks for deploying to test ansh! A few notes from me:
In general I think it needs to be smarter and move elements around based on what's been enabled, not just hide and show parts. If I've only selected 'release title' then it should be at the bottom left, with a smaller background. Currently there's no point in a user disabling anything, since it looks the same just with less info. Does that make sense? No notes on the colour UI, nice one! But when I download the file the background is always black (text colours download fine). |
…cro for correct reflow
…re fill-opacity in preview
|
Hi @anshg1214 can you redeploy on test.listenbrainz.org when you have a moment? I made changes based on Aerozol's feedback. |
|
I've deployed the latest version to test.LB. You can always use mock data in your backend to test things like these. |
|
Hi @Aerozol |
… combos - Pass show_release and show_artist through art_api.py → simple-grid.svg → macro - Compute bar_height (15 or 30px) based on max visible rows in either column - Compute text_limit (32 or 18 chars) based on whether left column is active - Vertically center single-row items within half-height bar - Fix gap: right column anchors at x+5 when left column is absent
|
Hi @Aerozol , pushed a new commit addressing latest feedback: Half-height bar (15px) when only a single row of caption info is visible |




Summary
This update adds a feature to customize captions on the Album Grid stats template. Users can now turn on or off each caption field. Choose their own colors.
Changes
Backend
The
listen_countinfo from user release stats is now sent to the cover art image pipeline incover_art_generator.py.The
/1/art/grid-stats/endpoint inart_api.pynow accepts two query parameters:caption-text-colorandcaption-bg-color.These color values are passed on to the SVG template.
SVG Templates
Each caption element now has its own CSS class:
.caption-rank.caption-release.caption-artist.caption-listen-countinmacros.j2.The
loop.indexis sent as the rank to therender_image_linkmacro insimple-grid.svg.The inline
fillcolor from query parameters is applied to eachtspanand backgroundrect.Frontend
The single "Show caption" toggle is replaced with four toggles: Show Rank, Show Release Title, Show Artist, Show Listen Count.
Users can now pick their own caption text color and background color.
The
showCaptionoption is now based on the options:showRank || showRelease || showArtist || showListenCount.The color options are sent to the grid-stats API URL as query parameters.
The
ToggleOptioncomponent is refactored into a controlled component withcheckedandonChangeprops.Preview.tsxnow accepts visibility for each field via CSS class targeting.Defaults
Show Rank: off
Show Release on
Show Artist: on
Show Listen Count: off
Caption text color: #ffffff
Caption background color: #0000007a
Not included
Testing
Each field can be toggled on or off independently. Shows or hides the correct caption element.
The color pickers update the preview in time.
The color values are passed as query parameters to the API and rendered inline in the SVG.
AI Usage
I got some help from AI during this implementation. It helped with understanding the data flow across Python, Jinja2 and React and, with debugging some SVG rendering issues. I understood every change before committing it. The architecture decisions are entirely based on my thinking, and also file choices and PR structure are my own.