From f863965ac9402082d4d59f457f391f61acc4a7a6 Mon Sep 17 00:00:00 2001 From: MattIPv4 Date: Thu, 19 Nov 2026 17:17:11 +0000 Subject: [PATCH 1/5] feat: animate in the Carbon Ads Top Bar --- apps/site/components/CarbonAds/TopBar.tsx | 6 ++--- .../components/CarbonAds/index.module.css | 24 ++++++++++++------- apps/site/tests/e2e/carbon-ads.spec.ts | 11 ++++----- docs/carbon-ads.md | 4 +++- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/apps/site/components/CarbonAds/TopBar.tsx b/apps/site/components/CarbonAds/TopBar.tsx index b6d06d65b4dc5..4f6999eddad0b 100644 --- a/apps/site/components/CarbonAds/TopBar.tsx +++ b/apps/site/components/CarbonAds/TopBar.tsx @@ -7,12 +7,10 @@ import type { FC } from 'react'; import styles from './index.module.css'; const CarbonTopBar: FC = () => { - const { ad, loading, ref } = useCarbonAd('CWBI6KJY'); + const { ad, ref } = useCarbonAd('CWBI6KJY'); if (!ad) { - return loading ? ( - ); }; diff --git a/apps/site/components/CarbonAds/index.module.css b/apps/site/components/CarbonAds/index.module.css index b68e4cd4f42a5..76e3f9bc0a354 100644 --- a/apps/site/components/CarbonAds/index.module.css +++ b/apps/site/components/CarbonAds/index.module.css @@ -29,9 +29,8 @@ .topBar { @apply animate-fade-and-slide-down mb-4 - flex - items-center - gap-3 + grid + grid-rows-1 overflow-hidden rounded-md px-4 @@ -41,6 +40,13 @@ lg:min-h-14; } +.topBarContent { + @apply flex + min-h-0 + items-center + gap-3; +} + .topBarLink { @apply flex flex-1 diff --git a/docs/carbon-ads.md b/docs/carbon-ads.md index cd7fa50d65eb3..d1d4f7e387d02 100644 --- a/docs/carbon-ads.md +++ b/docs/carbon-ads.md @@ -31,7 +31,7 @@ Learn (`/learn`) and the API docs (`/api`, `/docs`) are separate applications an - `apps/site/components/CarbonAds/TopBar.tsx` and `apps/site/components/CarbonAds/Sidebar.tsx` render each format. Neither reserves space while loading. When there is no ad (empty response, invalid data, network error or ad blocker) nothing is shown. - The ad request itself records the impression. The `statview` beacon is sent once per page view after at least 50% of the ad was visible for one continuous second. Clicks go through `statlink`. -Once an ad is available, the Top Bar uses the announcement banner's `animate-fade-and-slide-down` animation to fade and slide in. Visitors who prefer reduced motion see it immediately, without the animation. +Once an ad is available, the Top Bar uses the announcement banner's `animate-fade-and-slide-down` animation to expand, fade and slide in, taking up no space until the animation starts. Visitors who prefer reduced motion see it immediately, without the animation. ## Staging and production From 26a049ef32b2c51e4fd6ea8319ca9fcdd12a7dde Mon Sep 17 00:00:00 2001 From: MattIPv4 Date: Thu, 19 Nov 2026 20:15:36 +0000 Subject: [PATCH 5/5] fix: collapse surrounding space before the Carbon Ads Top Bar animates in --- .changeset/main-gap-variable.md | 5 +++++ apps/site/components/CarbonAds/index.module.css | 6 ++++++ apps/site/layouts/layouts.module.css | 6 +++--- docs/carbon-ads.md | 2 +- packages/ui-components/src/styles/animations.css | 5 +++-- packages/ui-components/src/styles/markdown.css | 6 ++++-- 6 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 .changeset/main-gap-variable.md diff --git a/.changeset/main-gap-variable.md b/.changeset/main-gap-variable.md new file mode 100644 index 0000000000000..2087ea7ca9cdb --- /dev/null +++ b/.changeset/main-gap-variable.md @@ -0,0 +1,5 @@ +--- +'@node-core/ui-components': patch +--- + +Expose the `main` gap as `--main-gap`, and let `animate-fade-and-slide-down` collapse surrounding space via `--fade-and-slide-down-offset`. diff --git a/apps/site/components/CarbonAds/index.module.css b/apps/site/components/CarbonAds/index.module.css index 76e3f9bc0a354..0814a3d01595a 100644 --- a/apps/site/components/CarbonAds/index.module.css +++ b/apps/site/components/CarbonAds/index.module.css @@ -36,8 +36,14 @@ px-4 py-2 text-sm + [--fade-and-slide-down-offset:var(--main-gap)] motion-reduce:animate-none lg:min-h-14; + + /* Until it animates in, it also cancels the parent's gap, and the margin it adds to a following heading */ + &:first-child:has(+ :is(h1, h2, h3, h4, h5, h6)) { + @apply [--fade-and-slide-down-offset:calc(var(--main-gap)+--spacing(4))]; + } } .topBarContent { diff --git a/apps/site/layouts/layouts.module.css b/apps/site/layouts/layouts.module.css index a2b8a89315dea..25b7b23695776 100644 --- a/apps/site/layouts/layouts.module.css +++ b/apps/site/layouts/layouts.module.css @@ -105,9 +105,9 @@ main { @apply max-w-7xl - gap-4 px-4 py-12 + [--main-gap:--spacing(4)] md:px-14 lg:px-28; } @@ -166,8 +166,8 @@ dark:border-l-neutral-900; main { - @apply gap-4 - wrap-anywhere; + @apply wrap-anywhere + [--main-gap:--spacing(4)]; } } diff --git a/docs/carbon-ads.md b/docs/carbon-ads.md index d1d4f7e387d02..8300acfcd4f1f 100644 --- a/docs/carbon-ads.md +++ b/docs/carbon-ads.md @@ -31,7 +31,7 @@ Learn (`/learn`) and the API docs (`/api`, `/docs`) are separate applications an - `apps/site/components/CarbonAds/TopBar.tsx` and `apps/site/components/CarbonAds/Sidebar.tsx` render each format. Neither reserves space while loading. When there is no ad (empty response, invalid data, network error or ad blocker) nothing is shown. - The ad request itself records the impression. The `statview` beacon is sent once per page view after at least 50% of the ad was visible for one continuous second. Clicks go through `statlink`. -Once an ad is available, the Top Bar uses the announcement banner's `animate-fade-and-slide-down` animation to expand, fade and slide in, taking up no space until the animation starts. Visitors who prefer reduced motion see it immediately, without the animation. +Once an ad is available, the Top Bar uses the announcement banner's `animate-fade-and-slide-down` animation to expand, fade and slide in. It takes up no space until then, including the parent's gap (from the `--main-gap` variable on `main`) and the margin it adds to a following heading. Visitors who prefer reduced motion see it immediately, without the animation. ## Staging and production diff --git a/packages/ui-components/src/styles/animations.css b/packages/ui-components/src/styles/animations.css index b8a82be5249a4..5149103c21584 100644 --- a/packages/ui-components/src/styles/animations.css +++ b/packages/ui-components/src/styles/animations.css @@ -89,11 +89,12 @@ } } - /* Expands a grid with a single `min-h-0` row from nothing, ending at the element's own spacing */ + /* Expands a grid with a single `min-h-0` row from nothing, ending at the element's own spacing. + * `--fade-and-slide-down-offset` also collapses any space around it, such as the parent's gap */ @keyframes fade-and-slide-down { from { grid-template-rows: 0fr; - margin-bottom: 0; + margin-bottom: calc(-1 * var(--fade-and-slide-down-offset, 0px)); min-height: 0; opacity: 0; padding-block: 0; diff --git a/packages/ui-components/src/styles/markdown.css b/packages/ui-components/src/styles/markdown.css index 40e76dc283b6c..0a30ba05b2f57 100644 --- a/packages/ui-components/src/styles/markdown.css +++ b/packages/ui-components/src/styles/markdown.css @@ -1,9 +1,11 @@ +/* The gap is a variable, so that children can account for it */ main { - @apply max-ml:gap-4 + @apply max-ml:[--main-gap:--spacing(4)] flex w-full flex-col - gap-6; + gap-(--main-gap) + [--main-gap:--spacing(6)]; hr { @apply w-full