Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Position the variant picker in the ToC #2632

Merged
merged 37 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
34f8630
New styling and placement for the variant picker
valentin0h Dec 16, 2024
d2fb275
top padding
valentin0h Dec 16, 2024
67b9e41
Bump API version
valentin0h Dec 13, 2024
949987d
Remove compact header
valentin0h Dec 18, 2024
d3eef16
add background test
valentin0h Dec 18, 2024
1b4d94d
less drastic offset
valentin0h Dec 18, 2024
02b4d2c
First pass
zenoachtig Jan 2, 2025
fab72d4
Redo positioning and filled bg
zenoachtig Jan 3, 2025
9c5df67
Fix default list style
zenoachtig Jan 3, 2025
04e977d
Add `sidebar-list-line` and `sidebar-list-pill` styles
zenoachtig Jan 3, 2025
7051e2a
Merge branch 'main' into rnd-5808-sidebar-new-style-settings-gbo
zenoachtig Jan 3, 2025
51719db
Lint
zenoachtig Jan 3, 2025
be7d604
Restyle page aside to use sidebar list styles
zenoachtig Jan 6, 2025
4a7f6a1
Improve padding
zenoachtig Jan 6, 2025
0cf933c
Fix border when there is no page index
zenoachtig Jan 6, 2025
816da18
Accessible styling
zenoachtig Jan 6, 2025
b64a176
Alignment and overflow fixes
zenoachtig Jan 6, 2025
958a7e9
Merge branch 'main' into rnd-5808-sidebar-new-style-settings-gbo
zenoachtig Jan 7, 2025
7104adc
Update TableOfContents.tsx
zenoachtig Jan 7, 2025
5643970
Merge branch 'rnd-5808-sidebar-new-style-settings-gbo' into style-pag…
zenoachtig Jan 7, 2025
0e24084
Better styling for fixed API block aside nav
zenoachtig Jan 7, 2025
9cab85c
Remove comments
zenoachtig Jan 7, 2025
c7f55a5
Fix padding of feedback container
zenoachtig Jan 7, 2025
15b67b0
Merge branch 'style-page-aside' into variant-dropdown-styling
zenoachtig Jan 7, 2025
e3bff9c
Restyle variant selector
zenoachtig Jan 7, 2025
93e1326
If `no-toc`, put variant selector in header
zenoachtig Jan 7, 2025
c0a6afc
Update Header.tsx
zenoachtig Jan 7, 2025
626a6bf
Update Header.tsx
zenoachtig Jan 7, 2025
57c3b0d
Add search box for sidebar-only themes
zenoachtig Jan 8, 2025
c2b7bf4
Merge branch 'main' into variant-dropdown-styling
zenoachtig Jan 8, 2025
0afbb15
Merge branch 'main' into variant-dropdown-styling
zenoachtig Jan 9, 2025
2288883
Changeset
zenoachtig Jan 9, 2025
de74e72
Update packages/gitbook/src/components/RootLayout/CustomizationRootLa…
valentin0h Jan 9, 2025
c0b27d2
Fix no-toc positioning
zenoachtig Jan 9, 2025
231fc90
Merge branch 'main' into variant-dropdown-styling
zenoachtig Jan 9, 2025
5bc13ad
Fix `no-toc` header without variants
zenoachtig Jan 9, 2025
27171da
Merge branch 'variant-dropdown-styling' of https://github.com/Gitbook…
zenoachtig Jan 9, 2025
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
5 changes: 5 additions & 0 deletions .changeset/gorgeous-horses-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gitbook': patch
---

Position the variant picker in the ToC
5 changes: 3 additions & 2 deletions packages/gitbook/src/components/Header/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ export function DropdownChevron() {
'opacity-6',
'size-3',
'ms-1',
'transition-transform',
'group-hover/dropdown:rotate-180',
'transition-all',
'group-hover/dropdown:opacity-11',
'group-focus-within/dropdown:rotate-180',
)}
/>
);
Expand Down
34 changes: 10 additions & 24 deletions packages/gitbook/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ export function Header(props: {
'gap-4',
'lg:gap-8',
'flex',
'h-16',
'items-center',
'justify-between',
'w-full',
'py-3',
'min-h-16',
'sm:h-16',
'page-no-toc:max-[400px]:flex-wrap',
CONTAINER_STYLE,
)}
>
Expand All @@ -93,31 +96,14 @@ export function Header(props: {
)}
/>
<HeaderLogo site={site} space={space} customization={customization} />
{!hasSiteSections && isMultiVariants ? (
<div className="z-20 shrink hidden sm:block">
<SpacesDropdown
className={tcls(
!isCustomizationDefault &&
withTopHeader && [
'bg-header-link/2',
'dark:bg-header-link/2',
'text-header-link/8',
'dark:text-header-link/8',
'ring-1',
'ring-header-link/4',
'dark:ring-header-link/4',
'contrast-more:bg-header-background',
'contrast-more:text-header-link',
'contrast-more:ring-header-link',
],
)}
space={space}
spaces={spaces}
/>
</div>
) : null}
</div>

{isMultiVariants && (
<div className="hidden page-no-toc:flex">
<SpacesDropdown space={space} spaces={spaces} />
</div>
)}

{customization.header.links.length > 0 && (
<HeaderLinks>
{customization.header.links.map((link, index) => {
Expand Down
45 changes: 37 additions & 8 deletions packages/gitbook/src/components/Header/SpacesDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export function SpacesDropdown(props: { space: Space; spaces: Space[]; className

return (
<Dropdown
className={tcls(
'group-hover/dropdown:invisible', // Prevent hover from opening the dropdown, as it's annoying in this context
'group-focus-within/dropdown:group-hover/dropdown:visible', // When the dropdown is already open, it should remain visible when hovered
)}
button={(buttonProps) => (
<div
{...buttonProps}
Expand All @@ -18,29 +22,54 @@ export function SpacesDropdown(props: { space: Space; spaces: Space[]; className
'flex',
'flex-row',
'items-center',
'rounded-2xl',
'transition-all',
'hover:cursor-pointer',

'px-3',
'py-2',
'gap-2',

'rounded-md',
'straight-corners:rounded-none',

'hover:cursor-pointer',
'bg-dark/1',
'dark:bg-light/1',
'bg-light',
'group-hover/dropdown:bg-light-1',
'group-focus-within/dropdown:bg-light-1',
'dark:bg-dark-1',
'dark:group-hover/dropdown:bg-dark-3',
'dark:group-focus-within/dropdown:bg-dark-3',

'text-sm',
'text-dark-4',
'group-hover/dropdown:text-dark',
'group-focus-within/dropdown:text-dark',
'dark:text-light-4',
'dark:group-hover/dropdown:text-light',
'dark:group-focus-within/dropdown:text-light',

'ring-1',
'ring-dark/2',
'group-hover/dropdown:ring-dark/4',
'group-focus-within/dropdown:ring-dark/4',
'dark:ring-light/2',
'dark:group-hover/dropdown:ring-light/4',
'dark:group-focus-within/dropdown:ring-light/4',

'contrast-more:bg-light',
'dark:contrast-more:bg-dark',
'contrast-more:ring-1',
'contrast-more:group-hover/dropdown:ring-2',
'contrast-more:ring-dark',
'contrast-more:group-hover/dropdown:ring-dark',
'contrast-more:group-focus-within/dropdown:ring-dark',
'dark:contrast-more:ring-light',
'dark:contrast-more:bg-dark',
'dark:contrast-more:group-hover/dropdown:ring-light',
'dark:contrast-more:group-focus-within/dropdown:ring-light',

'px-3',
'py-1',
className,
)}
>
<span className="line-clamp-2">{space.title}</span>
<span className={tcls('line-clamp-2', 'grow')}>{space.title}</span>
<DropdownChevron />
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import '@gitbook/icons/style.css';
import './globals.css';

const DEFAULT_TINT_COLOR = '#787878';
const SIDEBAR_TINT_COLOR_LIGHT = '#FFFFFF';
const SIDEBAR_TINT_COLOR_DARK = '#000000';
const SIDEBAR_NO_TINT_COLOR_LIGHT = 'var(--light-2)';
const SIDEBAR_NO_TINT_COLOR_DARK = 'var(--dark-2)';
valentin0h marked this conversation as resolved.
Show resolved Hide resolved

/**
* Layout shared between the content and the PDF renderer.
Expand Down
66 changes: 25 additions & 41 deletions packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,47 +135,31 @@ export async function SpaceLayout(props: {
}
innerHeader={
// displays the search button and/or the space dropdown in the ToC according to the header/variant settings. E.g if there is no header, the search button will be displayed in the ToC.
withVariants || !withTopHeader ? (
<>
{!withTopHeader && (
<div
className={tcls(
'hidden',
'lg:block',
'flex-shrink-0',
'grow-0',
'md:grow',
'sm:max-w-xs',
'lg:max-w-full',
)}
>
<React.Suspense fallback={null}>
<SearchButton>
<span className={tcls('flex-1')}>
{t(
getSpaceLanguage(customization),
customization.aiSearch.enabled
? 'search_or_ask'
: 'search',
)}
</span>
</SearchButton>
</React.Suspense>
</div>
)}
{withVariants && (
<div
className={tcls(
withTopHeader && !sections
? 'sm:hidden'
: ['sm:hidden', 'lg:flex'],
)}
>
<SpacesDropdown space={space} spaces={spaces} />
</div>
)}
</>
) : null
<>
{!withTopHeader && (
<div className={tcls('hidden', 'lg:block')}>
<React.Suspense fallback={null}>
<SearchButton>
<span className={tcls('flex-1')}>
{t(
getSpaceLanguage(customization),
customization.aiSearch.enabled
? 'search_or_ask'
: 'search',
)}
</span>
</SearchButton>
</React.Suspense>
</div>
)}
{withVariants && (
<SpacesDropdown
space={space}
spaces={spaces}
className={tcls('w-full')}
/>
)}
</>
}
headerOffset={headerOffset}
/>
Expand Down
Loading