Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces sticky positioning and layout adjustments for the feature discovery tab bar and category filter chips. Feedback on these changes highlights that the media query calculations result in invalid CSS (e.g., '769pxpx') and should be updated to use media query range syntax. Additionally, it is recommended to avoid hardcoding the tab bar height to 57px to prevent layout issues when text wraps, suggesting instead to wrap both elements in a single sticky parent container.
| @media (min-width: $width-tablet + 1 + px) { | ||
| --googlesitekit-feature-discovery-sticky-top: 114px; | ||
| } | ||
|
|
||
| @media (min-width: $bp-wpAdminBarTablet) { | ||
| --googlesitekit-feature-discovery-sticky-top: 100px; | ||
| } | ||
|
|
||
| @media (min-width: $width-desktop + 1 + px) { | ||
| --googlesitekit-feature-discovery-sticky-top: 116px; | ||
| } |
There was a problem hiding this comment.
Using $width-tablet + 1 + px and $width-desktop + 1 + px results in invalid CSS values like 769pxpx and 961pxpx because Sass automatically adds the unit of the first operand when adding a unitless number, and then concatenates the px string. This causes the browser to ignore these media queries entirely.
Additionally, we should use media query range syntax (e.g., width > $width-tablet) instead of traditional min/max declarations to comply with Stylelint configurations that enforce range syntax.
| @media (min-width: $width-tablet + 1 + px) { | |
| --googlesitekit-feature-discovery-sticky-top: 114px; | |
| } | |
| @media (min-width: $bp-wpAdminBarTablet) { | |
| --googlesitekit-feature-discovery-sticky-top: 100px; | |
| } | |
| @media (min-width: $width-desktop + 1 + px) { | |
| --googlesitekit-feature-discovery-sticky-top: 116px; | |
| } | |
| @media (width > $width-tablet) { | |
| --googlesitekit-feature-discovery-sticky-top: 114px; | |
| } | |
| @media (width >= $bp-wpAdminBarTablet) { | |
| --googlesitekit-feature-discovery-sticky-top: 100px; | |
| } | |
| @media (width > $width-desktop) { | |
| --googlesitekit-feature-discovery-sticky-top: 116px; | |
| } |
References
- The repository style guide prioritizes concrete CSS correctness, including avoiding invalid or conflicting style declarations. (link)
- Use media query range syntax (e.g.,
height >= 540px) instead of traditional min/max declarations (e.g.,min-height: 540px) in SCSS to comply with Stylelint configurations that enforce range syntax.
| // All services category chips stick below the tab bar. Offsets match | ||
| // `.googlesitekit-navigation`, which sticks below the same header. | ||
| --googlesitekit-feature-discovery-sticky-top: 68px; | ||
| --googlesitekit-feature-discovery-tab-bar-height: 57px; // 56px tabs + 1px border. |
There was a problem hiding this comment.
Hardcoding the tab bar height to 57px is fragile because tab labels can wrap to multiple lines on smaller screens or when translated into other languages (which often have longer strings). If the tab bar height increases, the category chips will overlap the tab bar.
Instead of calculating offsets with hardcoded heights, a more robust approach is to wrap both the tab bar and the category filter chips in a single parent container (e.g., .googlesitekit-feature-discovery__sticky-header) and make that parent container position: sticky. This allows the elements to flow naturally and adapt to any dynamic height changes without needing manual calculations.
📚 Storybook for bf1809f: 📦 Build files for bf1809f:
🖼️ VRT report for bf1809f:
🎭 Playwright reports for a1e3350: |
|
Size Change: 0 B Total Size: 3.49 MB ℹ️ View Unchanged
|
Summary
This is a PoC, do not merge.
Related issue(s):
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