From f6cf62a686c1b95ac90dc6d896b7e11d73d59edc Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Wed, 14 Jan 2026 13:46:47 +0100 Subject: [PATCH] Standardise toggle chevrons across the app (#3904) --- .changeset/rare-ties-find.md | 5 ++ packages/gitbook/e2e/internal.spec.ts | 10 ++-- .../CodeBlock/ClientCodeBlock.tsx | 4 +- .../DocumentView/Expandable/Expandable.tsx | 7 +-- .../src/components/Header/HeaderLink.tsx | 7 ++- .../src/components/Header/HeaderLinkMore.tsx | 10 ++-- .../src/components/Header/SpacesDropdown.tsx | 6 +-- .../PageActions/PageActionsDropdown.tsx | 9 +--- .../components/Search/SearchScopeControl.tsx | 6 +-- .../SiteSections/SiteSectionList.tsx | 15 +++--- .../SiteSections/SiteSectionTabs.tsx | 4 +- .../TableOfContents/ToggleableLinkItem.tsx | 54 ++++++------------- .../components/primitives/DropdownMenu.tsx | 23 +------- .../components/primitives/ToggleChevron.tsx | 44 +++++++++++++++ .../src/components/primitives/index.ts | 1 + 15 files changed, 102 insertions(+), 103 deletions(-) create mode 100644 .changeset/rare-ties-find.md create mode 100644 packages/gitbook/src/components/primitives/ToggleChevron.tsx diff --git a/.changeset/rare-ties-find.md b/.changeset/rare-ties-find.md new file mode 100644 index 000000000..3c7de54c2 --- /dev/null +++ b/.changeset/rare-ties-find.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Standardise toggle chevrons across the app diff --git a/packages/gitbook/e2e/internal.spec.ts b/packages/gitbook/e2e/internal.spec.ts index e3e1aa076..ad403bae4 100644 --- a/packages/gitbook/e2e/internal.spec.ts +++ b/packages/gitbook/e2e/internal.spec.ts @@ -273,10 +273,10 @@ const testCases: TestsCase[] = [ await expect(navigationLink).not.toBeVisible(); // Find and click the chevron element that is next to "Editor" in the TOC - // It is a span inside the link + // It is a button inside the link const editorChevron = page .getByRole('link', { name: 'Editor' }) - .locator('span'); + .locator('button'); await editorChevron.click(); // Verify "Navigation" link becomes visible after expansion @@ -295,10 +295,10 @@ const testCases: TestsCase[] = [ await expect(navigationLink).not.toBeVisible(); // Find and click the chevron element that is next to "Editor" in the TOC - // It is a span inside the link + // It is a button inside the link const editorChevron = page .getByRole('link', { name: 'Editor' }) - .locator('span'); + .locator('button'); await editorChevron.click(); // At this stage the link should still not be visible @@ -307,7 +307,7 @@ const testCases: TestsCase[] = [ // Then we click 'Content Structure' chevron to expand further const contentStructureChevron = page .getByRole('link', { name: 'Content Structure' }) - .locator('span'); + .locator('button'); await contentStructureChevron.click(); // Verify "Spaces" link becomes visible after expansion diff --git a/packages/gitbook/src/components/DocumentView/CodeBlock/ClientCodeBlock.tsx b/packages/gitbook/src/components/DocumentView/CodeBlock/ClientCodeBlock.tsx index b9d79be41..09219f191 100644 --- a/packages/gitbook/src/components/DocumentView/CodeBlock/ClientCodeBlock.tsx +++ b/packages/gitbook/src/components/DocumentView/CodeBlock/ClientCodeBlock.tsx @@ -6,7 +6,7 @@ import { useEffect, useId, useMemo, useRef, useState } from 'react'; import { useAdaptiveVisitor } from '@/components/Adaptive'; import { useInViewportListener } from '@/components/hooks/useInViewportListener'; import { useScrollListener } from '@/components/hooks/useScrollListener'; -import { Button } from '@/components/primitives'; +import { Button, ToggleChevron } from '@/components/primitives'; import { t, useLanguage } from '@/intl/client'; import { tcls } from '@/lib/tailwind'; import { useDebounceCallback } from 'usehooks-ts'; @@ -183,7 +183,7 @@ function CodeBlockExpandable(props: {
); diff --git a/packages/gitbook/src/components/Header/SpacesDropdown.tsx b/packages/gitbook/src/components/Header/SpacesDropdown.tsx index 4224ea26f..d4a628dbe 100644 --- a/packages/gitbook/src/components/Header/SpacesDropdown.tsx +++ b/packages/gitbook/src/components/Header/SpacesDropdown.tsx @@ -4,8 +4,8 @@ import { useMemo } from 'react'; import type { GitBookSiteContext } from '@/lib/context'; import { getSiteSpaceURL } from '@/lib/sites'; import { tcls } from '@/lib/tailwind'; -import { Button, type ButtonProps } from '../primitives'; -import { DropdownChevron, DropdownMenu } from '../primitives/DropdownMenu'; +import { Button, type ButtonProps, ToggleChevron } from '../primitives'; +import { DropdownMenu } from '../primitives/DropdownMenu'; import { SpacesDropdownMenuItems } from './SpacesDropdownMenuItem'; // Memoized regex for checking if a string starts with an emoji @@ -37,7 +37,7 @@ export function SpacesDropdown(props: { data-testid="space-dropdown-button" size="small" variant={variant} - trailing={} + trailing={} className={tcls('bg-tint-base', className)} > {siteSpace.title} diff --git a/packages/gitbook/src/components/PageActions/PageActionsDropdown.tsx b/packages/gitbook/src/components/PageActions/PageActionsDropdown.tsx index f713d38ba..2a041ea74 100644 --- a/packages/gitbook/src/components/PageActions/PageActionsDropdown.tsx +++ b/packages/gitbook/src/components/PageActions/PageActionsDropdown.tsx @@ -4,9 +4,9 @@ import { Button, ButtonGroup } from '@/components/primitives/Button'; import { DropdownMenu, DropdownMenuSeparator } from '@/components/primitives/DropdownMenu'; import { tString, useLanguage } from '@/intl/client'; import type { GitSyncState, SiteCustomizationSettings } from '@gitbook/api'; -import { Icon } from '@gitbook/icons'; import React, { useRef } from 'react'; import { useAI } from '../AI'; +import { ToggleChevron } from '../primitives'; import { ActionCopyMCPURL, ActionCopyMarkdown, @@ -57,12 +57,7 @@ export function PageActionsDropdown(props: PageActionsDropdownProps) { className="!min-w-60 max-w-max" button={