Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

landing: Style the announcement banner consistently across pages.

Aman Agrawal131a3289b62a
diff --git a/web/src/portico/header.ts b/web/src/portico/header.ts
index 3874942456c..9bd901d7848 100644
--- a/web/src/portico/header.ts
+++ b/web/src/portico/header.ts
@@ -3,6 +3,33 @@ import $ from "jquery";
const EXTRA_SUBMENU_BOTTOM_PADDING = 16;
$(() => {
+ // The closed mobile menu lands below the banner for free via
+ // top: auto in CSS. When the user opens the menu, we keep the
+ // banner visible above it: push the open panel down by the
+ // banner's actual rendered height so it survives the announcement
+ // wrapping onto multiple lines on narrow viewports. The observer
+ // is only attached while the menu is open, so the steady-state
+ // page pays nothing for it.
+ const banner = document.querySelector<HTMLElement>("#navbar-custom-message");
+ const mobile_menu = document.querySelector<HTMLDetailsElement>(".top-menu-mobile");
+ if (banner && mobile_menu) {
+ const update_banner_height = (): void => {
+ document.documentElement.style.setProperty(
+ "--announcement-banner-height",
+ `${banner.offsetHeight}px`,
+ );
+ };
+ const observer = new ResizeObserver(update_banner_height);
+ mobile_menu.addEventListener("toggle", () => {
+ if (mobile_menu.open) {
+ update_banner_height();
+ observer.observe(banner);
+ } else {
+ observer.disconnect();
+ }
+ });
+ }
+
function on_tab_menu_selection_change(changed_element?: HTMLElement): void {
// Pass event to open menu and if it is undefined, we close the menu.
if (!changed_element) {
diff --git a/web/styles/portico/legacy_portico.css b/web/styles/portico/legacy_portico.css
index e4cec671cc9..412e185527f 100644
--- a/web/styles/portico/legacy_portico.css
+++ b/web/styles/portico/legacy_portico.css
@@ -1469,28 +1469,6 @@ label.label-title {
margin-bottom: 20px;
}
-#navbar-custom-message {
- font-size: 1rem;
- background: linear-gradient(
- 145deg,
- hsl(191deg 56% 55%),
- hsl(169deg 65% 42%)
- );
- color: hsl(0deg 0% 100%);
- font-weight: 600;
- text-align: center;
- position: relative;
- top: 0;
- padding: 10px;
- border-bottom: 1px solid hsl(177deg 52% 55%);
- z-index: 5;
-
- & a {
- color: hsl(0deg 0% 100%);
- text-decoration: underline;
- }
-}
-
.text-image-in-row {
display: flex;
justify-content: space-between;
diff --git a/web/styles/portico/marketing_page.css b/web/styles/portico/marketing_page.css
index d28ede3ad15..4b0bd281261 100644
--- a/web/styles/portico/marketing_page.css
+++ b/web/styles/portico/marketing_page.css
@@ -981,28 +981,6 @@ label.label-title {
margin-bottom: 20px;
}
-#navbar-custom-message {
- font-size: 1rem;
- background: linear-gradient(
- 145deg,
- hsl(191deg 56% 55%),
- hsl(169deg 65% 42%)
- );
- color: hsl(0deg 0% 100%);
- font-weight: 600;
- text-align: center;
- position: relative;
- top: 0;
- padding: 10px;
- border-bottom: 1px solid hsl(177deg 52% 55%);
- z-index: 5;
-
- & a {
- color: hsl(0deg 0% 100%);
- text-decoration: underline;
- }
-}
-
.text-image-in-row {
display: flex;
justify-content: space-between;
diff --git a/web/styles/portico/navbar.css b/web/styles/portico/navbar.css
index 59dec981b96..a98bf024dca 100644
--- a/web/styles/portico/navbar.css
+++ b/web/styles/portico/navbar.css
@@ -3,6 +3,56 @@
(16px top/bottom) and line-height (28px): 16 + 28 + 16 = 60px.
Keep this variable in sync with those values. */
--navbar-height: 60px;
+ --announcement-banner-background: hsl(216deg 90% 82%);
+ --announcement-banner-foreground: hsl(240deg 100% 5.9%);
+ --announcement-banner-border: hsl(240deg 100% 5.9% / 12%);
+ --announcement-banner-link-underline: hsl(240deg 100% 5.9% / 80%);
+}
+
+/* Suppress rubber-band overscroll on marketing pages: the banner is
+ sticky and in-flow while .top-menu is fixed, so during overscroll
+ above scroll: 0 the banner briefly drifts down with the document
+ while the navbar stays pinned, exposing a gap and visually
+ overlapping the navbar's top edge. */
+html {
+ overscroll-behavior-y: none;
+}
+
+/* Announcement banner above the marketing nav, shown when
+ LANDING_PAGE_NAVBAR_MESSAGE is configured. Lives in navbar.css
+ (loaded by every marketing-page bundle, including landing-page-hello)
+ so /hello renders it identically to /plans, /why-zulip, etc.
+
+ position: sticky keeps the banner in flow — so .top-menu's
+ `position: fixed; top: auto` still resolves to "just below this
+ banner" — while pinning the banner to the viewport top on scroll.
+ z-index 11 sits above .top-menu (z-index 10) so the two sit
+ flush during scroll without flicker. */
+#navbar-custom-message {
+ position: sticky;
+ top: 0;
+ z-index: 11;
+ padding: 10px;
+ text-align: center;
+ font-size: 1.125rem; /* 18px at 16px/1rem */
+ font-weight: 450;
+ letter-spacing: 0.01em;
+ background: var(--announcement-banner-background);
+ color: var(--announcement-banner-foreground);
+ border-bottom: 1px solid var(--announcement-banner-border);
+
+ & a {
+ color: var(--announcement-banner-foreground);
+ text-decoration: underline;
+ text-decoration-color: var(--announcement-banner-link-underline);
+ text-decoration-thickness: 2px;
+ text-underline-offset: 2px;
+ transition: text-decoration-color 0.2s;
+ }
+
+ & a:hover {
+ text-decoration-color: var(--announcement-banner-foreground);
+ }
}
details summary::-webkit-details-marker {
@@ -418,8 +468,12 @@ details summary::-webkit-details-marker {
backdrop-filter: blur(10px);
z-index: 20;
+ /* No `top` — defaults to auto, which resolves to the static
+ position (just below the sticky banner when one is present,
+ or at the viewport top otherwise). Same trick as .top-menu
+ above. The [open] state below pins to top: 0 so the expanded
+ panel covers the full viewport. */
position: fixed;
- top: 0;
left: 0;
right: 0;
height: var(--navbar-height);
@@ -439,12 +493,25 @@ details summary::-webkit-details-marker {
}
.top-menu-mobile[open] {
+ top: 0;
bottom: 0;
height: 100%;
background: hsl(240deg 100% 5.9% / 80%);
backdrop-filter: blur(20px);
}
+/* When a banner is present, keep it visible above the open menu by
+ pushing the panel down by the banner's actual rendered height.
+ --announcement-banner-height is set by header.ts only while the menu is open
+ (via a ResizeObserver scoped to that interval), so the offset
+ stays accurate when the announcement wraps onto multiple lines on
+ narrow viewports without paying for an observer the rest of the
+ time. The 42px fallback covers the first frame before JS runs. */
+:has(#navbar-custom-message) .top-menu-mobile[open] {
+ top: var(--announcement-banner-height, 42px);
+ height: calc(100% - var(--announcement-banner-height, 42px));
+}
+
.top-menu-mobile-items-group-1,
.top-menu-mobile-items-group-2 {
display: flex;