You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PDF report follows a Figma design. The design is drawn on a 1180px-wide board, but the PDF page is only 612pt wide. So every size in the design has to be scaled down to fit the page.
Right now each widget scales its own sizes by hand, and they don't do it the same way. Some widgets use half the Figma size. The header, the footer, and the shared theme tokens use the full size. No single place sets the scale, so the report doesn't match the design, and every new widget guesses the sizes again.
Set the scale in one place, and apply it through one shared helper. A widget writes its styles with the real Figma sizes and passes them to the helper. The helper scales the sizes down and builds the final styles with StyleSheet.create. Every PDF widget uses the same helper, so the report matches the design and new widgets reuse the helper instead of guessing.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
The Figma-to-point scale is defined in one place, as the page width divided by the Figma board width, 612 / 1180 (about 0.5186). Nothing else hardcodes the ratio.
Each PDF report widget writes its styles with raw Figma pixel sizes and passes them to the shared helper. The helper scales the sizes and builds the final styles, so no widget hardcodes a pre-scaled number.
The helper scales these length properties, and no others:
The helper leaves every other property unchanged. It never scales lineHeight, fontWeight, maxLines, flex, flexGrow, flexShrink, aspectRatio, opacity, or zIndex, and it never changes colors, font families, or any text value.
The helper scales a property only when its value is a number. A percent like 100% stays the same, and a negative number keeps its minus sign.
The width and height of an icon Svg are scaled by the same ratio. The shapes drawn inside the Svg and the page size stay the same.
Each PDF report widget matches the Figma design at the page width.
Add a Set such as PDF_SCALED_PROPERTIES holding the length property names the acceptance criteria lists.
Add a helper such as scalePDFValue( value: number ) that returns value * PDF_SCALE.
Add a wrapper such as createPDFStyles around StyleSheet.create that takes a styles object and returns the same shape. For each named style, build a new style object from its entries:
the property is in PDF_SCALED_PROPERTIES and its value is a number: multiply the value by PDF_SCALE.
any other property, or a value that is not a number such as '100%': keep the value.
Pass the rebuilt styles to StyleSheet.create and return the result.
Build styles with createPDFStyles in place of StyleSheet.create, and set each numeric length to its Figma design value.
In the <Page>size, use PDF_PAGE_WIDTH in place of 612.
Keep the page padding unscaled: remove paddingTop, paddingBottom, and paddingHorizontal from the page style, and set padding to PDF_PAGE_PADDING on the <Page> instead:
Keep the header's marginTop, marginHorizontal, and paddingHorizontal unscaled: remove them from the header style, and apply them on the header <View> through a constant such as headerPageBleed:
Set the ChangeArrowSvg and the LegendSwatchSvgwidth and height to their raw Figma value wrapped in scalePDFValue, keeping each viewBox and the inner Path and Line.
If an in-flight PDF ticket adds another report widget, build its styles with createPDFStyles and wrap any Svg size or inline length with scalePDFValue.
createPDFStyles multiplies a length by PDF_SCALE for one property from each scaled group the acceptance criteria lists: fontSize, letterSpacing, a margin, a padding, width, height, top, a gap, a border width, borderRadius, and flexBasis.
createPDFStyles leaves each never-scaled property unchanged: lineHeight, fontWeight, maxLines, flex, flexGrow, flexShrink, aspectRatio, opacity, zIndex, a color, and a font family.
createPDFStyles leaves a percent like '100%' unchanged, and keeps the minus sign on a negative length.
Update the default card "padding" and "borderRadius" assertions to the values createPDFStyles now produces. Set each expected value to the raw Figma value multiplied by PDF_SCALE, not a fixed decimal.
Update the "columnGap" and "paddingHorizontal" assertions to the values createPDFStyles now produces. Set each expected value to the raw Figma value multiplied by PDF_SCALE, not a fixed decimal.
Feature Description
The PDF report follows a Figma design. The design is drawn on a 1180px-wide board, but the PDF page is only 612pt wide. So every size in the design has to be scaled down to fit the page.
Right now each widget scales its own sizes by hand, and they don't do it the same way. Some widgets use half the Figma size. The header, the footer, and the shared theme tokens use the full size. No single place sets the scale, so the report doesn't match the design, and every new widget guesses the sizes again.
Set the scale in one place, and apply it through one shared helper. A widget writes its styles with the real Figma sizes and passes them to the helper. The helper scales the sizes down and builds the final styles with
StyleSheet.create. Every PDF widget uses the same helper, so the report matches the design and new widgets reuse the helper instead of guessing.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
612 / 1180(about0.5186). Nothing else hardcodes the ratio.fontSize,letterSpacing.margin,marginHorizontal,marginVertical,marginTop,marginRight,marginBottom,marginLeft.padding,paddingHorizontal,paddingVertical,paddingTop,paddingRight,paddingBottom,paddingLeft.width,height,minWidth,maxWidth,minHeight,maxHeight.top,right,bottom,left.gap,rowGap,columnGap.borderWidth,borderTopWidth,borderRightWidth,borderBottomWidth,borderLeftWidth.borderRadius,borderTopLeftRadius,borderTopRightRadius,borderBottomRightRadius,borderBottomLeftRadius.flexBasis.lineHeight,fontWeight,maxLines,flex,flexGrow,flexShrink,aspectRatio,opacity, orzIndex, and it never changes colors, font families, or any text value.100%stays the same, and a negative number keeps its minus sign.Svgare scaled by the same ratio. The shapes drawn inside theSvgand the page size stay the same.Implementation Brief
Create
assets/js/components/pdf-export/pdf-scale.tsAdd the page width, the Figma board width, the scale built from them, and the page padding:
Add a
Setsuch asPDF_SCALED_PROPERTIESholding the length property names the acceptance criteria lists.Add a helper such as
scalePDFValue( value: number )that returnsvalue * PDF_SCALE.Add a wrapper such as
createPDFStylesaroundStyleSheet.createthat takes a styles object and returns the same shape. For each named style, build a new style object from its entries:PDF_SCALED_PROPERTIESand its value is a number: multiply the value byPDF_SCALE.'100%': keep the value.StyleSheet.createand return the result.Update
assets/js/components/pdf-export/shared-react-pdf-components/DashboardReport.tsxBuild
styleswithcreatePDFStylesin place ofStyleSheet.create, and set each numeric length to its Figma design value.In the
<Page>size, usePDF_PAGE_WIDTHin place of612.Keep the page padding unscaled: remove
paddingTop,paddingBottom, andpaddingHorizontalfrom thepagestyle, and setpaddingtoPDF_PAGE_PADDINGon the<Page>instead:Update
assets/js/components/pdf-export/shared-react-pdf-components/PDFHeader.tsxThe same
createPDFStyleschange forstyles.Keep the header's
marginTop,marginHorizontal, andpaddingHorizontalunscaled: remove them from theheaderstyle, and apply them on the header<View>through a constant such asheaderPageBleed:Set the chevron
Svgwidthandheightto their raw Figma value wrapped inscalePDFValue, keeping theviewBox.Update
assets/js/components/pdf-export/shared-react-pdf-components/PDFSiteKitLogo.tsxcreatePDFStyleschange forstyles.Svgwidthandheightto their raw Figma value wrapped inscalePDFValue, keeping theviewBoxand inner paths.Update
assets/js/components/pdf-export/section-icons.tsmakeIcon, wrap theSvgwidthandheight(size) withscalePDFValue, keeping theviewBoxand the innerRectandPathshapes.Update
assets/js/components/pdf-export/shared-react-pdf-components/PDFHeaderSectionChip.tsxcreatePDFStyleschange forstyles.Update
assets/js/components/pdf-export/shared-react-pdf-components/PDFEmailReportingNotice.tsxcreatePDFStyleschange forstyles.Svgwidthandheightto their raw Figma value wrapped inscalePDFValue, keeping theviewBox.Update
assets/js/components/pdf-export/shared-react-pdf-components/PDFMetricTile.tsxcreatePDFStyleschange fortileStyles.Update
assets/js/components/pdf-export/shared-react-pdf-components/PDFMetricChartTile.tsxcreatePDFStyleschange forstyles.ChangeArrowSvgand theLegendSwatchSvgwidthandheightto their raw Figma value wrapped inscalePDFValue, keeping eachviewBoxand the innerPathandLine.Update
assets/js/components/pdf-export/shared-react-pdf-components/PDFFooter.tsxcreatePDFStyleschange forstyles.Update
assets/js/components/pdf-export/shared-react-pdf-components/PDFTable.tsxcreatePDFStyleschange forstyles.Update
assets/js/components/pdf-export/shared-react-pdf-components/PDFWidgetSection.tsxcreatePDFStyleschange forstyles.Update
assets/js/modules/analytics-4/components/dashboard/DashboardAllTrafficWidgetGA4/indexPDF.tsxcreatePDFStyleschange forstyles.Update
assets/js/modules/analytics-4/components/module/ModulePopularPagesWidgetGA4/ModulePopularPagesWidgetGA4PDF.tsxcreatePDFStyleschange forstyles.cardStylelength (borderRadius,paddingVertical,paddingHorizontal) withscalePDFValueat its Figma value.Update
assets/js/modules/search-console/components/dashboard/SearchFunnelWidgetGA4/indexPDF.tsxcreatePDFStyleschange forstyles.Update any later PDF report widget the same way
createPDFStylesand wrap anySvgsize or inline length withscalePDFValue.Test Coverage
assets/js/components/pdf-export/pdf-scale.test.tscreatePDFStylesmultiplies a length byPDF_SCALEfor one property from each scaled group the acceptance criteria lists:fontSize,letterSpacing, a margin, a padding,width,height,top, a gap, a border width,borderRadius, andflexBasis.createPDFStylesleaves each never-scaled property unchanged:lineHeight,fontWeight,maxLines,flex,flexGrow,flexShrink,aspectRatio,opacity,zIndex, a color, and a font family.createPDFStylesleaves a percent like'100%'unchanged, and keeps the minus sign on a negative length.scalePDFValuemultiplies a number byPDF_SCALE.assets/js/components/pdf-export/shared-react-pdf-components/PDFWidgetSection.test.tsx"padding"and"borderRadius"assertions to the valuescreatePDFStylesnow produces. Set each expected value to the raw Figma value multiplied byPDF_SCALE, not a fixed decimal.assets/js/components/pdf-export/shared-react-pdf-components/PDFTable.test.tsx"columnGap"and"paddingHorizontal"assertions to the valuescreatePDFStylesnow produces. Set each expected value to the raw Figma value multiplied byPDF_SCALE, not a fixed decimal.assets/js/components/pdf-export/shared-react-pdf-components/PDFHeader.test.tsx"marginTop":-24,"marginHorizontal":-24, and"paddingHorizontal":24.marginBottom,paddingTop, andpaddingBottomequal their Figma value multiplied byPDF_SCALE.SvgwidthisscalePDFValue( 10 ).assets/js/components/pdf-export/shared-react-pdf-components/DashboardReport.test.tsx"padding":24, and the<Page>sizewidth isPDF_PAGE_WIDTH.QA Brief
Changelog entry