Repository navigation
Conversation
📚 Storybook for 5eefa1a: 📦 Build files for 5eefa1a:
🎭 Playwright reports for 5eefa1a: 🖼️ VRT report for 5eefa1a:
|
There was a problem hiding this comment.
Code Review
This pull request refactors the layout of the 'Your visitor groups' PDF widget to render audience cards section-by-section in a grid, ensuring that sections align horizontally across cards. It introduces several new sub-components (PDFAudienceCardHeader, PDFAudienceCardSection, PDFAudienceCitiesRow, PDFAudienceTopContentRow, and PDFAudienceTileNoData), extracts shared styles, and removes the monolithic PDFYourVisitorGroupsTile component. Additionally, it updates PDFTypography to support a custom hyphenationCallback and adds comprehensive unit tests for the new components. Feedback on the changes suggests using a safer unique key combining the title and index in PDFAudienceTopContentRow to prevent duplicate key warnings when rendering top content pages.
…/dashboard/AudienceTilesWidget/PDFAudienceTopContentRow.tsx Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
Size Change: 0 B Total Size: 3.49 MB ℹ️ View Unchanged
|
…oups PDF screenshots.
benbowler
left a comment
There was a problem hiding this comment.
Thanks @mehidi258. The section grid fixes the dividers and the card bottoms, but the section titles still drift when one card has less data than another, which is the case QA flagged in item 1. Details inline.
Note for QA: item 2 from the QA feedback (long city names overlapping) was flagged as a potential follow-up ticket, but it is fixed in this PR. When this comes back to QA, please also check long city names, including names with no spaces such as "Vacoas-Phoenix", across three cards.
| row: { | ||
| flexGrow: 1, | ||
| flexDirection: 'row', | ||
| alignItems: 'center', |
There was a problem hiding this comment.
Because each section fills a cell stretched to the tallest card's section and then centres its content, a section with less content sits lower in its cell. With one card missing cities or with fewer top content rows, the "Cities with the most visitors" and "Top content by pageviews" titles no longer line up across the cards:
This is from a PDF rendered from this branch with three cards: full data, no cities and one page, and no data with both Partial data badges. Can we top-align the section content within the cell so the titles line up, while keeping the dividers where they are now?
There was a problem hiding this comment.
Thanks for checking on this @benbowler, Section content is now top-aligned, so the titles line up. Dividers stay where they were.
| cityName: { | ||
| maxLines: 1, | ||
| textOverflow: 'ellipsis', | ||
| paddingRight: 11, |
There was a problem hiding this comment.
11 here, backed by "about 10.4px wide" in the comment, reads as a measured value. If this is the ellipsis width at the title small size, shouldn't it come from a specific value in the PDF design and go through our scaling helper (scalePDFValue / createPDFStyles), or be derived from the type scale, rather than being a hardcoded measurement?
There was a problem hiding this comment.
Thanks for the flag @benbowler , The padding is now one em of the city name's font size, taken from the type scale (PDF_TYPOGRAPHY.title.small.fontSize) rather than a hardcoded size.
| // A long city name truncates to one line with an ellipsis. `@react-pdf` | ||
| // wraps text by default, so `maxLines` caps it at one line. It draws the | ||
| // ellipsis after the last character that fits, so the padding keeps room | ||
| // for the ellipsis, about 10.4px wide at this size, inside the city. |
There was a problem hiding this comment.
Is there a better way to explain this? It is a long comment for one style block; ideally the naming and a short note carry it.
There was a problem hiding this comment.
Shortened to one line, and the style names carry the rest. this applies for all the similar feedbacks.
| { /* | ||
| * A name with a space keeps wrapping at its spaces: | ||
| * `@react-pdf` closes up the spaces on a line it | ||
| * breaks between characters. | ||
| */ } |
There was a problem hiding this comment.
Is there a better way to explain this? This inline JSX comment is hard to follow without the splitIntoCharacters docblock above.
| // The cards are laid out a section at a time: each section is a row with | ||
| // one cell per card. A row stretches every cell to its tallest one, so each | ||
| // section lines up across the cards whatever its content. |
There was a problem hiding this comment.
Is there a better way to explain this? This and the comments on columns, cardLayer and card below are long and describe the layout in prose; could the structure explain itself through naming with a single short comment on the grid?
| } ); | ||
| } ); | ||
|
|
||
| it( 'passes the hyphenation callback to the Text', () => { |
There was a problem hiding this comment.
Test titles should start with "should ..." per docs/context/js/tests.md, e.g. it( 'should pass the hyphenation callback to the Text' ).
There was a problem hiding this comment.
Thanks @benbowler, Done, updated all the newly added tests to follow guideline.
| import PDFAudienceCardHeader from './PDFAudienceCardHeader'; | ||
|
|
||
| describe( 'PDFAudienceCardHeader', () => { | ||
| it( 'renders the audience name', () => { |
There was a problem hiding this comment.
Test titles should start with "should ..." per docs/context/js/tests.md, e.g. it( 'should ...' ). This applies to all the new tests in this file: renders the audience name, shows the Partial data badge only when ..., fills its cell, so its divider lines up ....
| } | ||
|
|
||
| describe( 'PDFAudienceCitiesRow', () => { | ||
| it( 'renders each top city with its name and percentage', () => { |
There was a problem hiding this comment.
Test titles should start with "should ..." per docs/context/js/tests.md, e.g. it( 'should ...' ). This applies to all the new tests in this file: renders each top city ..., shows a no data message ..., truncates a long city name ..., lets a city name with no space wrap ..., keeps a city name with a space wrapping ....
| } | ||
|
|
||
| describe( 'PDFAudienceTopContentRow', () => { | ||
| it( 'renders each top content row with its title and pageviews', () => { |
There was a problem hiding this comment.
Test titles should start with "should ..." per docs/context/js/tests.md, e.g. it( 'should ...' ). This applies to all the new tests in this file: renders each top content row ..., shows a no data message ..., shows the Partial data badge only when ..., fills its cell and drops the divider ..., links each top content title ..., renders each top content title as plain text ....
| expect( json.split( 'Partial data' ).length - 1 ).toBe( 1 ); | ||
| } ); | ||
|
|
||
| it( 'renders the four metric rows in order, with the pageviews share label', () => { |
There was a problem hiding this comment.
Test titles should start with "should ..." per docs/context/js/tests.md. Same for lays the cards out a section at a time ... below.
tofumatt
left a comment
There was a problem hiding this comment.
I'm starting my merge review on this change in anticipation of it being code-reviewed so we can merge it quickly for the release.
The ACs for this issue are straightforward and the IB is very minimal.
Why is this PR 1,400 additions and 700 lines removed? There are a lot of seemingly unrelated changes here for a follow-up release issue.
Additionally: this PR needs to be branched off main as it's a release issue. When I targeted main the commits-to-be-merged went up to 94 instead of 5.
So I think this entire PR needs to be re-thought for the release, please create a new one that addresses only the QA feedback and is based off main.
There was a problem hiding this comment.
This whole file doesn't seem well-localised at all. How do these functions behave in Thai or Chinese? And why introduce this logic at all for the changes requested in the AC of this issue?
|
|
||
| describe( 'AudienceTilesWidget PDF', () => { | ||
| it( 'renders the heading and two cards for two audiences', () => { | ||
| it( 'should render the heading and two cards for two audiences', () => { |
There was a problem hiding this comment.
I understand that this is requested of the test spec naming, but making all of these changes really inflates this diff. Please be mindful of these types of changes in the future for release issues.
Summary
Related issue(s):
Follow-up to #13893 for the QA feedback.
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist