From 6bd006dc08c83d9de5501a4ea404f6d6591c2c2e Mon Sep 17 00:00:00 2001 From: anthony lio Date: Tue, 1 Dec 2026 11:43:40 +0200 Subject: [PATCH] feat(docs): layout toggle (#53688) ## Problem - docs layout v2 (variant `option-1` of the `docs-ia-mvp-v1` flag) is about to roll out and a reader in the rollout has no way back to the classic layout ## Solution - adds a toggle button bottom of the guide right column so user in the rollout can switch back - adds a dialog that asks for an optional reason when a reader switches back to classic, and stores the reason in `feedback_comments` with `metadata.source = 'docs_layout_switch'` so we relying on existing - adds the `docs_layout_updated` event and stops new experiment exposures for readers who picked a layout | toggle | survey | | -------|------| | image | image | ## Review instructions 1. open [/docs/guides/database/prisma?docs-ia-mvp-v1=option-1](https://docs-git-antlio-feat-docs-layout-switch-v2-supabase.vercel.app/docs/guides/database/prisma?docs-ia-mvp-v1=option-1) 2. click "Switch to classic layout" in the notice and make sure that a dialog asks "What made you switch back?" ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) --- apps/docs/components/Feedback/Feedback.tsx | 6 +- apps/docs/components/GuidesSidebar.legacy.tsx | 2 + apps/docs/components/GuidesSidebar.tsx | 104 +++++++++------- .../DocsLayout/LayoutSwitchButton.test.tsx | 100 ++++++++++++++++ .../DocsLayout/LayoutSwitchButton.tsx | 99 ++++++++++++++++ .../DocsLayout/LayoutSwitchFeedbackDialog.tsx | 112 ++++++++++++++++++ apps/docs/features/IaNav/constants.test.ts | 29 ++++- apps/docs/features/IaNav/constants.ts | 8 +- apps/docs/features/IaNav/layoutChoice.ts | 40 +++++++ .../features/IaNav/useIaNavVariant.test.ts | 79 +++++++++++- apps/docs/features/IaNav/useIaNavVariant.ts | 37 +++++- .../docs/features/docs/GuidesMdx.template.tsx | 10 +- packages/common/constants/local-storage.ts | 2 + packages/common/telemetry-constants.ts | 23 ++++ packages/common/telemetry-event.ts | 1 + 15 files changed, 592 insertions(+), 60 deletions(-) create mode 100644 apps/docs/features/DocsLayout/LayoutSwitchButton.test.tsx create mode 100644 apps/docs/features/DocsLayout/LayoutSwitchButton.tsx create mode 100644 apps/docs/features/DocsLayout/LayoutSwitchFeedbackDialog.tsx create mode 100644 apps/docs/features/IaNav/layoutChoice.ts diff --git a/apps/docs/components/Feedback/Feedback.tsx b/apps/docs/components/Feedback/Feedback.tsx index 1788f007ea6..2ec626559db 100644 --- a/apps/docs/components/Feedback/Feedback.tsx +++ b/apps/docs/components/Feedback/Feedback.tsx @@ -8,6 +8,7 @@ import { Bug, Check, MessageSquareQuote, ThumbsDown, ThumbsUp, X } from 'lucide- import { usePathname } from 'next/navigation' import { forwardRef, + useId, useReducer, useRef, useState, @@ -95,6 +96,7 @@ function Feedback({ className, variant = 'default' }: FeedbackProps) { const pathname = usePathname() ?? '' const sendTelemetryEvent = useSendTelemetryEvent() const isRail = variant === 'rail' + const titleId = useId() const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY const supabase = useConstant(() => @@ -157,9 +159,9 @@ function Feedback({ className, variant = 'default' }: FeedbackProps) { } return ( -
+

Is this helpful? diff --git a/apps/docs/components/GuidesSidebar.legacy.tsx b/apps/docs/components/GuidesSidebar.legacy.tsx index b9daa1dbf1d..3ea3f064967 100644 --- a/apps/docs/components/GuidesSidebar.legacy.tsx +++ b/apps/docs/components/GuidesSidebar.legacy.tsx @@ -4,6 +4,7 @@ import { AiTools } from '~/components/AiTools' import { Feedback } from '~/components/Feedback' import { VideoPreview } from '~/components/VideoPreview' +import { LayoutSwitchButton } from '~/features/DocsLayout/LayoutSwitchButton' import { isFeatureEnabled } from 'common' import { usePathname } from 'next/navigation' import { cn } from 'ui' @@ -59,6 +60,7 @@ const GuidesSidebar = ({ {!hideToc && toc.length !== 0 && ( )} + ) diff --git a/apps/docs/components/GuidesSidebar.tsx b/apps/docs/components/GuidesSidebar.tsx index 70e0ebd128e..8ca79602605 100644 --- a/apps/docs/components/GuidesSidebar.tsx +++ b/apps/docs/components/GuidesSidebar.tsx @@ -3,6 +3,7 @@ import { Feedback } from '~/components/Feedback' import { LegacyGuidesSidebar } from '~/components/GuidesSidebar.legacy' import { VideoPreview } from '~/components/VideoPreview' +import { LayoutSwitchButton } from '~/features/DocsLayout/LayoutSwitchButton' import { useDocsLayoutV2 } from '~/features/DocsLayout/useDocsLayoutV2' import { HeadingSlotCrumb } from '~/layouts/HeadingSlot' import { RightRailPortal } from '~/layouts/RightRail' @@ -37,6 +38,11 @@ interface GuidesSidebarProps extends GuidesRightRailProps { className?: string } +interface GuidePageLinksProps { + editHref?: string + className?: string +} + interface GuideTocProps { toc: TOCItemType[] activeUrl: string | undefined @@ -58,15 +64,10 @@ const GuidesSidebar = ({ className, ...props }: GuidesSidebarProps) => const GuidesRightRail = ({ video, videoTitle, hideToc, editHref }: GuidesRightRailProps) => { const pathname = usePathname() - const sendTelemetryEvent = useSendTelemetryEvent() const { toc } = useTocAnchors() const activeIndex = Math.max(TocPrimitive.useTopActiveIndex(toc), 0) - const showFeedback = isFeatureEnabled('feedback:docs') const tocVideoPreview = `https://img.youtube.com/vi/${video}/0.jpg` - const handlePreferredSourceClick = () => - sendTelemetryEvent({ action: 'preferred_source_clicked', properties: { pageType: 'guide' } }) - return (
@@ -83,51 +84,66 @@ const GuidesRightRail = ({ video, videoTitle, hideToc, editHref }: GuidesRightRa )}
+
) } +const GuidePageLinks = ({ editHref, className }: GuidePageLinksProps) => { + const pathname = usePathname() + const sendTelemetryEvent = useSendTelemetryEvent() + const showFeedback = isFeatureEnabled('feedback:docs') + + const handlePreferredSourceClick = () => + sendTelemetryEvent({ action: 'preferred_source_clicked', properties: { pageType: 'guide' } }) + + return ( + + ) +} + const GuideToc = ({ toc, activeUrl }: GuideTocProps) => (