Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,23 @@
.googlesitekit-plugin {

.googlesitekit-category-filter-chips {
margin-top: 32px;
background-color: $c-base;

// Padding gives the chips breathing room over the content scrolling
// beneath them while stuck; the margins offset it so the resting
// layout is unchanged.
margin-block: 24px -8px;
padding-block: 8px;
position: sticky;

// Sits directly below the sticky feature discovery tab bar.
top: calc(var(--googlesitekit-feature-discovery-sticky-top) + var(--googlesitekit-feature-discovery-tab-bar-height));
z-index: 10;

body.googlesitekit-showing-feature-tour &,
body.googlesitekit-showing-tooltip & {
position: static;
}

.googlesitekit-chip-multi-select {
gap: 10px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@
--googlesitekit-feature-discovery-padding-m: 36px;
--googlesitekit-feature-discovery-padding-l: 48px;
}

// The tab bar sticks directly below the sticky Site Kit header, and the
// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.


body.admin-bar & {

@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;
}
Comment on lines +38 to +48

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
@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
  1. The repository style guide prioritizes concrete CSS correctness, including avoiding invalid or conflicting style declarations. (link)
  2. 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.

}
}

.googlesitekit-feature-discovery__header {
Expand All @@ -40,6 +61,18 @@
padding-inline: var(--googlesitekit-feature-discovery-padding-m);
}

.googlesitekit-feature-discovery__tab-bar {
background-color: $c-base;
position: sticky;
top: var(--googlesitekit-feature-discovery-sticky-top);
z-index: 10;

body.googlesitekit-showing-feature-tour &,
body.googlesitekit-showing-tooltip & {
position: static;
}
}

.googlesitekit-feature-discovery__content {
min-block-size: 546px;
padding-block: 0 var(--googlesitekit-feature-discovery-padding-l);
Expand Down
Loading