Compare commits

..

7 Commits

Author SHA1 Message Date
Nolann B. 262749a0b1 Copy the current spec's server in OpenAPI endpoint URLs (#4794) 2026-11-16 20:12:40 +01:00
Peter White b145bfcdff Stop caching site search results (#4782) 2026-11-16 16:43:30 +01:00
Peter White 1c718491bd Follow the API's cache lifetime for site data (#4790) 2026-11-16 14:10:44 +01:00
Viktor Renkema 8dd308bd90 Ignore categories when resolving tag assignments (#4736) 2026-11-16 10:49:18 +01:00
Peter White c09da2ec1a Show H3 headings in the page outline (#4787) 2026-11-16 10:47:57 +01:00
conico974 9fcde5f487 Reduce memory and CPU use of the OpenNext workers (#4788)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:17:23 +01:00
conico974 c85d84fc1d Store 'use cache' entries in R2 again (#4789)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:15:41 +01:00
149 changed files with 2818 additions and 2997 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Fix `'use cache'` entries never being stored in or read from R2 and the regional cache on Cloudflare.
@@ -0,0 +1,5 @@
---
"@gitbook/icons": minor
---
Add a `@gitbook/icons/validateIconName` entry that validates icon names without loading the icon labels and search terms.
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Reduce memory and CPU use of the OpenNext workers: minify the middleware, resolve the site context once per request, cache parsed OpenAPI descriptions across a spec, drop the redis client and the unused force-revalidate route from the server bundle.
@@ -0,0 +1,5 @@
---
"@gitbook/react-openapi": patch
---
Copy the current spec's server in OpenAPI endpoint URLs instead of a server kept from a previously visited page.
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Show H3 headings in the page outline.
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Stop caching site search results in the framework cache, so every search reaches the API.
-5
View File
@@ -1,5 +0,0 @@
---
"gitbook": patch
---
Ship short semantic class names instead of Tailwind utility strings on the sidebar, buttons, header, page layout and document blocks, shrinking HTML and RSC payloads.
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Follow the API's cache lifetime for site data, so a site preview shows layout changes soon after they are saved.
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Ignore tag category references when displaying assigned tags and update filters.
+10
View File
@@ -59,6 +59,16 @@ Run a specific test file:
cd packages/gitbook && bun test src/lib/cache.test.ts
```
## Bumping Next.js or OpenNext
Type checks and unit tests miss runtime regressions: OpenNext 4.1.15 changed the composable cache key format, and every `'use cache'` call silently missed for days. Before committing a bump of `next`, `@opennextjs/aws` or `@opennextjs/cloudflare`, run both runtimes locally from `packages/gitbook`:
1. **Next**: `bun run build:local && bun run start`, then load several distinct pages under `http://localhost:3000/url/gitbook.com/docs`.
2. **OpenNext**: `bun run build:cloudflare`, delete `openNext/customWorkers/.wrangler` (stale cache hits otherwise skip the server), then run `bun run dev:cf:server` and `bun run dev:cf:middleware` and load several distinct pages under `http://127.0.0.1:8771/url/gitbook.com/docs`.
3. Diff the changed OpenNext versions' adapters that call our overrides in `openNext/` (incremental, composable and tag cache, queue), e.g. with `npm pack` of the old and new versions.
The bump is safe when every page returns 200 on both runtimes and the server logs show no cache errors (grep `Failed to` and `regional cache`). Report the pages checked and the log result in the PR.
## Changesets
After committing code changes, create a changeset for the affected package:
+28 -20
View File
@@ -1751,7 +1751,7 @@ const testCases: TestsCase[] = [
name: 'Navigation to shared space',
url: '',
run: async (page) => {
const sharedSpaceLink = page.locator('a.link');
const sharedSpaceLink = page.locator('a.underline');
await sharedSpaceLink.click();
await expect(
page.getByRole('heading', { level: 1, name: 'shared' })
@@ -1772,7 +1772,7 @@ const testCases: TestsCase[] = [
name: 'Navigation to shared space',
url: '',
run: async (page) => {
await page.locator('a.link').click();
await page.locator('a.underline').click();
await expect(
page.getByRole('heading', { level: 1, name: 'shared' })
).toBeVisible();
@@ -2308,10 +2308,10 @@ const testCases: TestsCase[] = [
},
run: async (page) => {
const alphaUserPage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Alpha users' });
const betaUserPage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Beta users' });
await expect(alphaUserPage).toBeVisible();
await expect(betaUserPage).toHaveCount(0);
@@ -2335,10 +2335,10 @@ const testCases: TestsCase[] = [
},
run: async (page) => {
const alphaUserPage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Alpha users' });
const betaUserPage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Beta users' });
await expect(betaUserPage).toBeVisible();
await expect(alphaUserPage).toHaveCount(0);
@@ -2363,10 +2363,10 @@ const testCases: TestsCase[] = [
},
run: async (page) => {
const alphaUserPage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Alpha users' });
const betaUserPage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Beta users' });
await expect(alphaUserPage).toBeVisible();
await expect(betaUserPage).toBeVisible();
@@ -2383,12 +2383,14 @@ const testCases: TestsCase[] = [
url: '',
run: async (page) => {
const welcomePage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Welcome Page' });
const alphaUserPage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Alpha User' });
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
const betaUserPage = page
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Beta User' });
await expect(welcomePage).toBeVisible();
await expect(alphaUserPage).toHaveCount(0);
@@ -2420,12 +2422,14 @@ const testCases: TestsCase[] = [
url: '',
run: async (page) => {
const welcomePage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Welcome Page' });
const alphaUserPage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Alpha User' });
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
const betaUserPage = page
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Beta User' });
await expect(welcomePage).toBeVisible();
await expect(alphaUserPage).toBeVisible();
@@ -2457,12 +2461,14 @@ const testCases: TestsCase[] = [
url: '',
run: async (page) => {
const welcomePage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Welcome Page' });
const alphaUserPage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Alpha User' });
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
const betaUserPage = page
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Beta User' });
await expect(welcomePage).toBeVisible();
await expect(betaUserPage).toBeVisible();
@@ -2495,12 +2501,14 @@ const testCases: TestsCase[] = [
url: '',
run: async (page) => {
const welcomePage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Welcome Page' });
const alphaUserPage = page
.locator('a.toclink')
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Alpha User' });
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
const betaUserPage = page
.locator('a[class*="group\\/toclink"]')
.filter({ hasText: 'Beta User' });
await expect(welcomePage).toBeVisible();
await expect(betaUserPage).toBeVisible();
+12
View File
@@ -1,6 +1,7 @@
// @ts-check
import { networkInterfaces } from 'node:os';
import { fileURLToPath } from 'node:url';
// Next blocks its dev client and HMR when a physical device opens the server over a LAN address.
// Needed to hydrate the dev client on physical phones/tablets over the internal network
@@ -119,6 +120,17 @@ const nextConfig = {
],
},
webpack(config, { isServer }) {
if (isServer) {
// mcp-handler only needs redis for SSE, which we disable: keep the client out of the server bundle.
config.resolve.alias = {
...config.resolve.alias,
redis$: fileURLToPath(new URL('./src/lib/mcp/redis-stub.ts', import.meta.url)),
};
}
return config;
},
async headers() {
return [
{
@@ -3,6 +3,7 @@
"name": "gitbook-open-v2",
"compatibility_date": "2026-04-02",
"keep_names": false,
"minify": true,
"compatibility_flags": [
"nodejs_compat",
"allow_importable_env",
@@ -0,0 +1,23 @@
import { describe, expect, it } from 'bun:test';
import { createHash } from 'node:crypto';
import { GitbookIncrementalCache } from './incrementalCache';
describe('GitbookIncrementalCache.getR2Key', () => {
const cache = new GitbookIncrementalCache();
it('accepts the hashed composable key passed by OpenNext', () => {
const storageKey = createHash('sha256').update('["build-id","action",[]]').digest('hex');
const key = cache.getR2Key(storageKey, 'composable');
const hash = createHash('sha256').update(storageKey).digest('hex');
expect(key).toBe(`incremental-cache/dataCache/${hash}.composable`);
});
it('maps distinct composable keys to distinct R2 keys', () => {
expect(cache.getR2Key('a'.repeat(64), 'composable')).not.toBe(
cache.getR2Key('b'.repeat(64), 'composable')
);
});
});
@@ -118,15 +118,8 @@ export class GitbookIncrementalCache implements IncrementalCache {
}
}
// Utility function to generate keys for R2/Cache API
getR2Key(initialKey: string, cacheType: CacheEntryType = 'cache'): string {
let key = initialKey;
if (cacheType === 'composable') {
// For composable cache, we need to discard the build ID from the key
const [_buildId, ...restOfTheKey] = JSON.parse(initialKey);
key = JSON.stringify([...restOfTheKey]);
}
// OpenNext pre-hashes composable keys with the build ID in them: no reuse across deploys.
getR2Key(key: string, cacheType: CacheEntryType = 'cache'): string {
const hash = createHash('sha256').update(key).digest('hex');
return `${DEFAULT_PREFIX}/${cacheType === 'cache' ? process.env?.NEXT_BUILD_ID : 'dataCache'}/${hash}.${cacheType}`.replace(
/\/+/g,
+1 -1
View File
@@ -135,7 +135,7 @@
"e2e": "playwright test e2e/internal.spec.ts e2e/cookie-banner.spec.ts e2e/pdf.spec.ts e2e/select.spec.ts e2e/tabs-overflow.spec.ts --project=chromium",
"e2e-customers": "playwright test e2e/customers.spec.ts --project=chromium",
"e2e-style-perf": "playwright test e2e/style-perf.spec.ts --project=chromium --reporter=list",
"unit": "bun run generate:assets && bun test {src,packages} --preload ./tests/preload-bun.ts",
"unit": "bun run generate:assets && bun test {src,packages,openNext} --preload ./tests/preload-bun.ts",
"e2e-browserless": "bun test ./tests/",
"typecheck": "tsc --noEmit"
},
@@ -50,6 +50,7 @@ export async function handleMcpRequest(
streamableHttpEndpoint: context.linker.toPathInSite(endpoint),
maxDuration: 60,
verboseLogs: true,
// SSE needs redis, which next.config.mjs stubs out of the server bundle.
disableSse: true,
}
);
+21 -2
View File
@@ -1,5 +1,6 @@
import { jwtDecode } from 'jwt-decode';
import { forbidden, notFound } from 'next/navigation';
import { cache } from 'react';
import rison from 'rison';
import type { SiteAPIToken } from '@gitbook/api';
@@ -27,7 +28,17 @@ export type RouteParams = RouteLayoutParams & {
/**
* Get the static context when rendering statically a site.
*/
export async function getStaticSiteContext(params: RouteLayoutParams) {
export function getStaticSiteContext(params: RouteLayoutParams) {
return getStaticSiteContextCached(params.mode, params.siteURL, params.siteData);
}
// Layouts, pages and their metadata functions each resolve the context: share it per request.
// Keyed on the raw strings as `params` objects aren't guaranteed to be the same reference.
const getStaticSiteContextCached = cache((mode: string, siteURL: string, siteData: string) =>
resolveStaticSiteContext({ mode, siteURL, siteData })
);
async function resolveStaticSiteContext(params: RouteLayoutParams) {
const siteURL = getSiteURLFromParams(params);
const siteURLData = getSiteURLDataFromParams(params);
@@ -57,7 +68,15 @@ export async function getStaticSiteContext(params: RouteLayoutParams) {
* Get the site context when rendering dynamically.
* The context will depend on the request.
*/
export async function getDynamicSiteContext(params: RouteLayoutParams) {
export function getDynamicSiteContext(params: RouteLayoutParams) {
return getDynamicSiteContextCached(params.mode, params.siteURL, params.siteData);
}
const getDynamicSiteContextCached = cache((mode: string, siteURL: string, siteData: string) =>
resolveDynamicSiteContext({ mode, siteURL, siteData })
);
async function resolveDynamicSiteContext(params: RouteLayoutParams) {
const siteURL = getSiteURLFromParams(params);
const siteURLData = getSiteURLDataFromParams(params);
@@ -13,7 +13,6 @@ import { LinkStyles } from '../primitives/styles';
import { ANNOUNCEMENT_CSS_CLASS, ANNOUNCEMENT_STORAGE_KEY } from './constants';
import { tString, useLanguage } from '@/intl/client';
import { setLocalStorageItem } from '@/lib/browser';
import { cx } from '@/lib/classnames';
import type { ResolvedContentRef } from '@/lib/references';
import { getLocalizedMessage, getLocalizedTitle } from '@/lib/sites';
import { tcls } from '@/lib/tailwind';
@@ -39,16 +38,20 @@ export function AnnouncementBanner(props: {
const style = BANNER_STYLES[announcement.style];
return (
<div data-gb-announcement-banner className="announcement" data-nosnippet="">
<div className="chrome-shift">
<div className={cx(CONTAINER_STYLE, 'relative')}>
<div
data-gb-announcement-banner
className="pb-2 pt-4 theme-bold:bg-header-background"
data-nosnippet=""
>
<div className="lg:chat-open:pr-(--ai-chat-width) transition-all duration-300 motion-reduce:transition-none">
<div className={tcls('relative', CONTAINER_STYLE)}>
<Tag
href={contentRef?.href ?? ''}
className={cx(
'announcement-box',
`announcement-${announcement.style}`,
closeable && 'announcement-closeable',
hasLink && 'announcement-linked'
className={tcls(
'flex w-full items-start justify-center overflow-hidden circular-corners:rounded-xl rounded-md straight-corners:rounded-none px-4 py-3 text-neutral-strong text-sm theme-bold:ring-1 theme-gradient:ring-1 ring-inset transition-colors',
style.container,
closeable && 'pr-12',
hasLink && style.hover
)}
insights={
announcement.link
@@ -62,7 +65,10 @@ export function AnnouncementBanner(props: {
: undefined
}
>
<Icon icon={style.icon as IconName} className="announcement-icon" />
<Icon
icon={style.icon as IconName}
className={`mr-3 mt-0.5 size-4 shrink-0 ${style.iconColor}`}
/>
<div>
{message}
{hasLink ? (
@@ -79,7 +85,7 @@ export function AnnouncementBanner(props: {
? 'arrow-up-right'
: 'chevron-right'
}
className="mb-0.5 inline size-3"
className={tcls('mb-0.5 inline size-3')}
/>
</div>
) : null}
@@ -117,23 +123,35 @@ function dismissAnnouncement() {
const BANNER_STYLES = {
info: {
container: 'bg-info ring-info-subtle',
hover: 'hover:bg-info-hover active:bg-info-active',
icon: 'circle-info',
close: 'hover:ring-info-subtle',
iconColor: 'text-info-subtle',
close: 'hover:bg-tint-base hover:ring-info-subtle',
link: '',
},
warning: {
container: 'bg-warning decoration-warning/6 ring-warning-subtle',
hover: 'hover:bg-warning-hover',
icon: 'circle-exclamation',
close: 'hover:ring-warning-subtle',
iconColor: 'text-warning-subtle',
close: 'hover:bg-tint-base hover:ring-warning-subtle',
link: 'links-default:text-warning hover:links-default:text-warning-strong links-default:decoration-warning/6 links-accent:decoration-warning',
},
danger: {
container: 'bg-danger decoration-danger/6 ring-danger-subtle',
hover: 'hover:bg-danger-hover',
icon: 'triangle-exclamation',
close: 'hover:ring-danger-subtle',
iconColor: 'text-danger-subtle',
close: 'hover:bg-tint-base hover:ring-danger-subtle',
link: 'links-default:text-danger hover:links-default:text-danger-strong links-default:decoration-danger/6 links-accent:decoration-danger',
},
success: {
container: 'bg-success decoration-success/6 ring-success-subtle',
hover: 'hover:bg-success-hover',
icon: 'circle-check',
close: 'hover:ring-success-subtle',
iconColor: 'text-success-subtle',
close: 'hover:bg-tint-base hover:ring-success-subtle',
link: 'links-default:text-success hover:links-default:text-success-strong links-default:decoration-success/6 links-accent:decoration-success',
},
};
@@ -19,7 +19,7 @@ export function AnnotationPopover(props: { children: React.ReactNode; body: Reac
>
<dfn
data-annotation=""
className="cursor-help not-italic underline decoration-dotted decoration-1 underline-offset-2"
className="not-italic cursor-help underline decoration-dotted decoration-1 underline-offset-2"
// oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- we want to be able to focus the definition to open the tooltip
tabIndex={0}
>
@@ -34,7 +34,7 @@ import {
SkeletonParagraph,
SkeletonUpdate,
} from '@/components/primitives';
import type { ClassValue } from '@/lib/classnames';
import type { ClassValue } from '@/lib/tailwind';
import { nullIfNever } from '@/lib/typescript';
export interface BlockProps<Block extends DocumentBlock> extends DocumentContextProps {
@@ -0,0 +1,18 @@
@reference "../RootLayout/globals.css";
/* This file can be the first stylesheet a route loads, and layer order follows first
appearance. Without this, `components` would be created here and Tailwind's `base`
only later, letting preflight's `padding: 0` and `border: 0` win over the rules below. */
@layer theme, base, components, utilities;
/* Every block on every page carries these, so they live here rather than in each class attribute. */
@layer components {
.gb-block {
@apply decoration-primary/6;
}
/* Lists opt out: a long list is expected to break across printed pages. */
.gb-block:not(.gb-block-list) {
@apply print:break-inside-avoid;
}
}
@@ -1,10 +1,11 @@
import type { DocumentBlock, JSONDocument } from '@gitbook/api';
import { CONTENT_STYLE } from '../layout';
import { CONTENT_STYLE, CONTENT_STYLE_REDUCED } from '../layout';
import { Block } from './Block';
import './Blocks.css';
import type { DocumentContextProps } from './DocumentView';
import { isBlockOffscreen } from './utils';
import { type ClassValue, cx } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
/**
* Renders a list of blocks with a wrapper element.
@@ -24,7 +25,7 @@ export function Blocks<TBlock extends DocumentBlock, Tag extends React.ElementTy
const { tag: Tag = 'div', style, wrapperProps, ...blocksProps } = props;
return (
<Tag {...wrapperProps} className={cx(style)}>
<Tag {...wrapperProps} className={tcls(style)}>
<UnwrappedBlocks {...blocksProps} />
</Tag>
);
@@ -93,9 +94,9 @@ export function UnwrappedBlocks<TBlock extends DocumentBlock>(props: UnwrappedBl
key={node.key || `${node.type}-${index}`}
block={node}
style={[
// `gb-block` carries the reduced content width.
'gb-block',
FULL_WIDTH_BLOCKS.has(node.type) && CONTENT_STYLE,
FULL_WIDTH_BLOCKS.has(node.type) ? CONTENT_STYLE : CONTENT_STYLE_REDUCED,
LIST_BLOCKS.has(node.type) && 'gb-block-list',
blockStyle,
]}
@@ -10,15 +10,15 @@ import type {
import type { DocumentContextProps } from './DocumentView';
import { Inlines } from './Inlines';
import { getCommentAnchorProps } from './utils';
import { type ClassValue, cx } from '@/lib/classnames';
import { getNodeFragmentByName, isNodeEmpty } from '@/lib/document';
import { type ClassValue, tcls } from '@/lib/tailwind';
export type CaptionAlign = NonNullable<DocumentBlockImages['data']['align']>;
const captionAlignStyles = {
center: 'gb-caption-center',
left: 'gb-caption-left',
right: 'gb-caption-right',
center: 'mx-auto',
left: 'mr-auto ml-0',
right: 'mr-0 ml-auto',
} satisfies Record<CaptionAlign, ClassValue>;
/**
@@ -51,10 +51,17 @@ export function Caption(
withBorder = false,
withFrame = false,
wrapperStyle = [
'gb-caption-media',
fit && 'gb-caption-fit',
withBorder && 'gb-caption-bordered',
withFrame && 'gb-caption-framed',
'relative',
'overflow-hidden',
'after:block',
'after:absolute',
'after:-inset-0',
'after:pointer-events-none',
fit ? 'w-fit' : null,
withBorder
? 'rounded-corners:rounded-sm circular-corners:rounded-2xl after:border-tint-subtle after:border after:rounded circular-corners:after:rounded-2xl rounded-corners:after:rounded-sm dark:after:mix-blend-plus-lighter after:pointer-events-none'
: null,
withFrame && 'p-2',
],
style,
align = 'center',
@@ -72,16 +79,23 @@ export function Caption(
isNodeEmpty(captionParagraph)
) {
return (
<div {...anchorProps} className={cx(style, wrapperStyle)}>
<div {...anchorProps} className={tcls(style, wrapperStyle)}>
{children}
</div>
);
}
return (
<picture {...anchorProps} className={cx('gb-caption', style)}>
<div className={cx(wrapperStyle, captionAlignStyles[align])}>{children}</div>
<figcaption className={cx('gb-caption-text', withFrame && 'gb-caption-text-framed')}>
<picture {...anchorProps} className={tcls('relative', style)}>
<div className={tcls(wrapperStyle, captionAlignStyles[align])}>{children}</div>
<figcaption
className={tcls(
'text-xs',
'text-center',
'text-tint',
withFrame ? 'mt-0.5 mb-2.5' : 'mt-2'
)}
>
<Inlines
nodes={captionParagraph.nodes}
document={document}
@@ -7,7 +7,7 @@ import { useTrackEvent } from '@/components/Insights';
import { Button } from '@/components/primitives';
import { isAIChatEnabled } from '@/components/utils/isAIChatEnabled';
import { t, useLanguage } from '@/intl/client';
import { type ClassValue, cx } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
export function AskAICodeButton(props: {
codeId: string;
@@ -50,7 +50,7 @@ export function AskAICodeButton(props: {
variant="secondary"
icon={<AIChatIcon state="default" trademark={config.trademark} className="" />}
onClick={onClick}
className={cx(style, 'codeblock-button-ask')}
className={tcls(style, 'translate-y-0!', 'print:hidden', '[[data-ai-chat]_&]:hidden')}
>
{t(language, 'ask')}
</Button>
@@ -9,7 +9,6 @@ import { getCommentKeyAttributes } from '../utils/commentAnchors';
import { AskAICodeButton } from './AskAICodeButton';
import { CopyCodeButton } from './CopyCodeButton';
import type { HighlightLine, HighlightTheme, HighlightToken } from './highlight-tokens';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
type CodeBlockRendererProps = Pick<BlockProps<DocumentBlockCode>, 'block' | 'style'> & {
@@ -56,16 +55,28 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
id={codeId}
{...getCommentKeyAttributes(commentKey)}
aria-busy={ariaBusy}
className={cx('shiki codeblock', !embedded && 'codeblock-framed', tcls(style))}
className={tcls(
'group/codeblock shiki relative flex shrink flex-col overflow-hidden print:overflow-visible',
!embedded &&
'circular-corners:rounded-2xl rounded-corners:rounded-xl straight-corners:rounded-xs',
!embedded &&
'[&:has([data-codeblock-focus]:focus)]:ring-2 [&:has([data-codeblock-focus]:focus)]:ring-primary-hover',
style
)}
/* Sets the code theme's mode (light or dark) for the site's theme mode (light or dark).
* Used to style UI elements (scrollbars, form controls) correctly and apply the right default to "plain" code blocks. */
data-color-scheme={`${theme.themes.light.type} ${theme.themes.dark.type}`}
>
<span data-codeblock-focus tabIndex={-1} aria-hidden className="codeblock-focus" />
<div className="codeblock-header">
<span
data-codeblock-focus
tabIndex={-1}
aria-hidden
className="pointer-events-none absolute size-0 outline-none"
/>
<div className="flex items-center justify-start gap-2 text-sm">
{withTitle ? (
<div
className="codeblock-title"
className="straight-corners:rounded-t-xs relative top-px z-20 inline-flex items-center justify-center border border-b-0 border-tint-subtle bg-tint-subtle px-3 py-2 text-xs leading-none tracking-wide text-tint theme-bold-tint:bg-tint-base theme-muted:bg-tint-base rounded-corners:rounded-t-lg circular-corners:rounded-t-xl contrast-more:border-tint contrast-more:bg-tint-base [html.theme-bold.sidebar-filled_&]:bg-tint-base"
style={{
backgroundColor: bg?.color,
...bg?.vars,
@@ -77,12 +88,12 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
</div>
) : null}
</div>
<div className="codeblock-body">
<div className="relative flex min-h-0 flex-col">
{!embedded ? (
<div
className={cx(
'codeblock-actions',
isSingleLine && 'codeblock-actions-centered'
className={tcls(
'absolute right-2 z-2 flex items-center gap-1.5 font-sans leading-none opacity-0 group-hover/codeblock:opacity-11 has-[button:focus-visible]:opacity-11',
isSingleLine ? 'inset-y-0' : 'top-2'
)}
>
{!isPrint ? (
@@ -90,17 +101,21 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
codeId={codeId}
title={title}
syntax={block.data.syntax}
style="codeblock-button"
style="backdrop-blur-md"
/>
) : null}
<CopyCodeButton codeId={codeId} style="codeblock-button" />
<CopyCodeButton codeId={codeId} style="backdrop-blur-md" />
</div>
) : null}
<pre
className={cx(
'codeblock-pre',
embedded ? 'codeblock-pre-embedded' : 'codeblock-pre-framed',
withTitle && 'codeblock-pre-titled'
className={tcls(
'relative overflow-auto py-2.5 text-tint-strong print:overflow-visible',
embedded
? 'bg-tint-base'
: 'border border-tint-subtle bg-tint-subtle theme-bold-tint:bg-tint-base theme-muted:bg-tint-base contrast-more:border-tint contrast-more:bg-tint-base',
!embedded &&
'circular-corners:rounded-2xl rounded-corners:rounded-xl straight-corners:rounded-xs depth-subtle:shadow-xs',
withTitle && 'rounded-ss-none!'
)}
style={{
backgroundColor: codeBackground?.color,
@@ -109,7 +124,13 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
...fg?.vars,
}}
>
<code className={cx('codeblock-code', withWrap && 'codeblock-code-wrap')}>
<code
className={tcls(
'table max-h-full w-fit min-w-full [counter-reset:line] print:max-h-none print:whitespace-pre-wrap',
withWrap && 'whitespace-pre-wrap',
'[[aria-expanded=false]_&]:mask-b-from-50%'
)}
>
{theme.lines.map((line, index) => (
<CodeHighlightLine
bg={codeBackground}
@@ -146,9 +167,9 @@ function CodeHighlightLine(props: {
};
return (
<span
className={cx(
className={tcls(
'highlight-line',
embeddedPlainLine && 'highlight-line-plain',
embeddedPlainLine && 'bg-transparent! hover:bg-tint-subtle!',
line.diff === 'added' && 'diff-added',
line.diff === 'deleted' && 'diff-deleted',
line.highlighted && 'highlighted'
@@ -4,7 +4,7 @@ import { getCodeTextFromId } from './utils';
import { useCopyToClipboard } from '@/components/hooks';
import { Button } from '@/components/primitives';
import { t, useLanguage } from '@/intl/client';
import { type ClassValue, cx } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
/**
* Client component to copy the code of a code block.
@@ -26,7 +26,12 @@ export function CopyCodeButton(props: { codeId: string; style: ClassValue }) {
return (
<>
<Button size="xsmall" variant="secondary" onClick={onClick} className={cx(style)}>
<Button
size="xsmall"
variant="secondary"
onClick={onClick}
className={tcls(style, 'translate-y-0!', 'print:hidden')}
>
{t(language, copied ? 'code_copied' : 'code_copy')}
</Button>
{/* A label swap on the focused button isn't announced, the live region is. */}
@@ -5,7 +5,6 @@ import { type DocumentBlockColumns, type Length, VerticalAlignment } from '@gitb
import type { BlockProps } from '../Block';
import { Blocks } from '../Blocks';
import { getCommentMarkerProps } from '../utils';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
export function Columns(props: BlockProps<DocumentBlockColumns>) {
@@ -41,7 +40,10 @@ export function Columns(props: BlockProps<DocumentBlockColumns>) {
<div
// The app doesn't allow comments inside columns.
{...getCommentMarkerProps(context, 'data-comment-ignore')}
className={cx('column-set', tcls(style))}
className={tcls(
'grid w-full @2xl:grid-flow-col @2xl:grid-cols-[repeat(var(--grid-slices),minmax(0,1fr))] grid-cols-1 @2xl:grid-rows-1 gap-x-8 gap-y-4',
style
)}
style={{ '--grid-slices': COLUMN_DIVISIONS } as React.CSSProperties}
>
{block.nodes.map((columnBlock, index) => {
@@ -63,8 +65,7 @@ export function Columns(props: BlockProps<DocumentBlockColumns>) {
document={document}
ancestorBlocks={[...ancestorBlocks, block, columnBlock]}
context={context}
// `*:max-w-full` stays a utility to beat the blocks' own `max-w-*`.
style="group/column column-set-body *:max-w-full"
style="group/column w-full space-y-4 *:max-w-full"
/>
</Column>
);
@@ -82,10 +83,13 @@ export function Column(props: {
const { className, style } = transformLengthToCSS(width) ?? {};
return (
<div
className={cx(
'column-set-item',
verticalAlignment === VerticalAlignment.Middle && 'column-set-item-middle',
verticalAlignment === VerticalAlignment.Bottom && 'column-set-item-bottom',
className={tcls(
'flex flex-col',
'@container/column',
(verticalAlignment === VerticalAlignment.Top || !verticalAlignment) &&
'justify-start',
verticalAlignment === VerticalAlignment.Middle && 'justify-center',
verticalAlignment === VerticalAlignment.Bottom && 'justify-end',
className
)}
style={style}
@@ -103,7 +107,7 @@ export function transformLengthToCSS(length: Length) {
}
if (length.unit === '%') {
return {
className: 'column-set-item-sized',
className: '@2xl:flex-shrink-0 @2xl:[grid-column:var(--grid-col)]',
style: {
'--grid-col': `auto / span ${Math.round(length.value * 0.01 * COLUMN_DIVISIONS)}`,
} as React.CSSProperties,
@@ -1,10 +1,10 @@
import type { DocumentBlockDivider } from '@gitbook/api';
import type { BlockProps } from './Block';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
export function Divider(props: BlockProps<DocumentBlockDivider>) {
const { style } = props;
return <hr className={cx(style, 'border-tint-subtle')} />;
return <hr className={tcls(style, 'border-tint-subtle')} />;
}
@@ -2,8 +2,8 @@ import type { JSONDocument } from '@gitbook/api';
import { BlockSkeleton } from './Block';
import { Blocks } from './Blocks';
import type { ClassValue } from '@/lib/classnames';
import type { GitBookAnyContext } from '@/lib/context';
import type { ClassValue } from '@/lib/tailwind';
export interface DocumentContext {
/**
@@ -3,7 +3,7 @@
import React from 'react';
import { useHash } from '@/components/hooks';
import { type ClassValue, cx } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
/**
* Details component rendered on client so it can expand dependent on url hash changes.
@@ -50,7 +50,27 @@ export function Details(props: {
id={id}
data-block-key={props.commentKey}
open={props.open || openFromHash}
className={cx('expandable', className)}
className={tcls(
className,
'group/expandable',
'bg-tint-base',
'border',
'border-b-0',
'border-tint-subtle',
//all
'mt-0!',
'mb-0',
//select first child
'first:mt-5!',
'first:rounded-t-lg',
//select first in group
'[:not(&)_+_&]:mt-5!',
'[:not(&)_+_&]:rounded-t-lg',
//select last in group
'[&:not(:has(+_&))]:mb-5',
'[&:not(:has(+_&))]:rounded-b-lg',
'[&:not(:has(+_&))]:border-b'
)}
>
{children}
</details>
@@ -10,7 +10,6 @@ import { Details } from './Details';
import { ToggleChevron } from '@/components/primitives';
import { getSpaceLanguage, tString } from '@/intl/server';
import { defaultLanguage } from '@/intl/translations';
import { cx } from '@/lib/classnames';
import { getNodeFragmentByType } from '@/lib/document';
import { tcls } from '@/lib/tailwind';
@@ -41,16 +40,37 @@ export async function Expandable(props: BlockProps<DocumentBlockExpandable>) {
id={id}
{...getCommentKeyProp(context, block.key)}
open={context.mode === 'print' || isDefaultExpanded}
className={tcls(style)}
className={tcls('scroll-mt-(--content-scroll-margin)', style)}
>
<summary
{...getCommentAnchorProps(context, titleParagraph.key)}
className={cx('expandable-summary', showHashLink && 'expandable-summary-anchored')}
className={tcls(
'cursor-pointer',
'px-4',
// Reserve room for the anchor icon pinned to the right edge
showHashLink && 'pr-10',
'py-4',
'relative',
'list-none',
'select-none',
'transition-colors',
'text-tint',
'group-hover/expandable:text-tint-strong',
'group-open/expandable:text-tint-strong',
'[&::-webkit-details-marker]:hidden'
)}
>
<ToggleChevron
orientation="right-to-down"
open={context.mode === 'print'}
className="expandable-chevron"
className={tcls(
'inline-block',
'size-3',
'mr-3',
'mb-1',
'shrink-0',
'group-open/expandable:rotate-90'
)}
/>
<Inlines
nodes={titleParagraph.nodes}
@@ -62,9 +82,28 @@ export async function Expandable(props: BlockProps<DocumentBlockExpandable>) {
<a
href={`#${id}`}
aria-label={tString(language, 'direct_link_to_heading')}
className="expandable-anchor"
className={tcls(
'absolute',
'top-2',
'bottom-2',
'right-4',
'flex',
'items-center',
'dark:shadow-none',
'dark:ring-0'
)}
>
<Icon icon="hashtag" className="expandable-anchor-icon" />
<Icon
icon="hashtag"
className={tcls(
'inline-block',
'size-3',
'transition-colors',
'text-transparent',
'group-hover/expandable:text-tint-subtle',
'contrast-more:group-hover/expandable:text-tint-strong'
)}
/>
</a>
) : null}
</summary>
@@ -73,7 +112,7 @@ export async function Expandable(props: BlockProps<DocumentBlockExpandable>) {
document={document}
ancestorBlocks={[...ancestorBlocks, block]}
context={context}
style="expandable-body"
style="space-y-4 px-10 pb-5"
/>
</Details>
);
@@ -41,12 +41,12 @@ export async function File(props: BlockProps<DocumentBlockFile>) {
return (
<Caption {...props} withBorder withBlockKey>
<div className="file-block">
<div className="file-block-preview">
<div className="flex flex-wrap items-center gap-5 px-5 py-3">
<div className="flex min-h-8 min-w-14 flex-col items-center justify-center gap-1 border-r border-tint-subtle pr-4">
{contentType === 'image' ? (
<Image
alt={file.name}
className="file-block-image"
className="h-auto max-h-10 w-auto max-w-10 rounded object-contain"
sizes={[{ width: 40 }]}
resize={context.contentContext?.imageResizer}
sources={{
@@ -58,11 +58,11 @@ export async function File(props: BlockProps<DocumentBlockFile>) {
loading="lazy"
/>
) : (
<FileIcon contentType={contentType} className="file-block-icon" />
<FileIcon contentType={contentType} className="size-5 text-primary" />
)}
</div>
<div className="file-block-info">
<div className="file-block-name">
<div className="min-w-24 flex-1">
<div className="text-base">
<Link
href={file.downloadURL}
target="_blank"
@@ -72,13 +72,13 @@ export async function File(props: BlockProps<DocumentBlockFile>) {
{file.name}
</Link>
</div>
<div className="file-block-meta">
<div className="text-sm text-tint-subtle">
{contentType
? `${contentType} · ${getHumanFileSize(file.size)}`
: getHumanFileSize(file.size)}
</div>
</div>
<div className="file-block-actions">
<div className="flex shrink-0 flex-wrap gap-2">
<DownloadButton
icon="download"
size="xsmall"
@@ -0,0 +1,30 @@
@reference "../RootLayout/globals.css";
/* This file can be the first stylesheet a route loads, and layer order follows first
appearance. Without this, `components` would be created here and Tailwind's `base`
only later, letting preflight's `padding: 0` and `border: 0` win over the rules below. */
@layer theme, base, components, utilities;
/* A page carries one of these per heading, so the shared utilities live here instead of in a class
attribute repeated hundreds of times — on a large page that repetition is most of the HTML.
They sit in `components` so the utilities passed as props still override them. */
@layer components {
.hash {
@apply relative inline-grid grid-area-1-1 border-0 rounded site-background;
@apply pointer-events-none opacity-0 transition-opacity;
@apply pointer-fine:h-[1em] pointer-fine:pointer-events-auto;
@apply pointer-fine:group-hover/hash:opacity-100 pointer-fine:group-focus-within/hash:opacity-100;
@apply [.hash-revealed_&]:pointer-events-auto [.hash-revealed_&]:opacity-100;
}
.hash-link {
@apply inline-flex items-center p-1 pointer-fine:h-full pointer-fine:p-0;
}
.hash-icon {
@apply size-3 self-center text-transparent transition-colors;
@apply pointer-fine:group-hover/hash:text-tint-subtle contrast-more:pointer-fine:group-hover/hash:text-tint-strong;
@apply pointer-fine:group-focus-within/hash:text-tint-subtle contrast-more:pointer-fine:group-focus-within/hash:text-tint-strong;
@apply [.hash-revealed_&]:text-tint-subtle contrast-more:[.hash-revealed_&]:text-tint-strong;
}
}
@@ -3,7 +3,9 @@ import { Icon } from '@gitbook/icons';
import { Link } from '../primitives';
import type { DocumentContext } from './DocumentView';
import { type ClassValue, cx } from '@/lib/classnames';
import './HashLinkButton.css';
import { getBlockTextStyle } from './spacing';
import { type ClassValue, tcls } from '@/lib/tailwind';
/**
* Whether blocks should render a visible anchor link icon.
@@ -19,8 +21,10 @@ export function shouldShowHashLinks(context: DocumentContext): boolean {
/**
* A hash icon which adds the block or active block item's ID in the URL hash.
* Styled in `styles/blocks.css`, it is revealed when hovering its `.heading` parent.
* The button needs to be wrapped in a container with `hashLinkButtonWrapperStyles`.
*/
export const hashLinkButtonWrapperStyles = tcls('relative', 'group/hash');
export function HashLinkButton(props: {
id: string;
block: DocumentBlockTabs | DocumentBlockHeading;
@@ -28,12 +32,17 @@ export function HashLinkButton(props: {
className?: ClassValue;
iconClassName?: ClassValue;
}) {
const { id, className, iconClassName, label } = props;
const { id, block, className, iconClassName, label } = props;
const textStyle = getBlockTextStyle(block);
return (
<span className={cx('hash', className)}>
<Link href={`#${id}`} aria-label={label} className="hash-link">
<Icon icon="hashtag" className={cx('hash-icon', iconClassName)} />
<span className={tcls('hash', className)}>
<Link
href={`#${id}`}
aria-label={label}
className={tcls('hash-link', textStyle.lineHeight)}
>
<Icon icon="hashtag" className={tcls('hash-icon', iconClassName)} />
</Link>
</span>
);
@@ -1,17 +1,20 @@
import type { DocumentBlockHeading } from '@gitbook/api';
import type { BlockProps } from './Block';
import { HashLinkButton, shouldShowHashLinks } from './HashLinkButton';
import { HashLinkButton, hashLinkButtonWrapperStyles, shouldShowHashLinks } from './HashLinkButton';
import { HeadingRevealWrapper } from './HeadingRevealWrapper';
import { Inlines } from './Inlines';
import { getBlockTextStyle } from './spacing';
import { getCommentAnchorProps, getTextAlignment } from './utils';
import { getSpaceLanguage, tString } from '@/intl/server';
import { defaultLanguage } from '@/intl/translations';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
export async function Heading(props: BlockProps<DocumentBlockHeading>) {
const { block, style, context, ...rest } = props;
const textStyle = getBlockTextStyle(block);
const Tag = TAGS[block.type];
let id = block.meta?.id ?? '';
@@ -28,20 +31,38 @@ export async function Heading(props: BlockProps<DocumentBlockHeading>) {
as={Tag}
id={id}
{...getCommentAnchorProps(context, block.key)}
className={cx(
className={tcls(
textStyle.textSize,
'heading',
block.type,
'font-heading',
'pdf-heading',
'block',
// Reserve room for the absolutely positioned anchor icon on coarse pointers
showHashLink && 'pr-6',
'pointer-fine:flex',
'pointer-fine:items-baseline',
'pointer-fine:pr-0',
'scroll-mt-(--content-scroll-margin)',
getTextAlignment(block.data.align),
style
hashLinkButtonWrapperStyles,
style,
textStyle.marginTop
)}
>
<span
// Cover-aware contrast text applies only to the page body, not to documents
// rendered in overlays (search answers, AI chat) on a background-cover page.
data-cover-aware-text={context.isPageBody ? '' : undefined}
className={cx('heading-text', getTextAlignment(block.data.align))}
className={tcls(
'pointer-fine:flex-1',
'z-1',
'justify-self-start',
'max-w-full',
'break-words',
// Cover-aware contrast text applies only to the page body, not to documents
// rendered in overlays (search answers, AI chat) on a background-cover page.
context.isPageBody && 'page-cover-background:text-contrast-cover',
getTextAlignment(block.data.align),
textStyle.lineHeight
)}
>
<Inlines {...rest} context={context} nodes={block.nodes} ancestorInlines={[]} />
</span>
@@ -50,6 +71,15 @@ export async function Heading(props: BlockProps<DocumentBlockHeading>) {
<HashLinkButton
id={id}
block={block}
className={tcls(
'absolute',
block.type === 'heading-1'
? '[transform:translateY(0.125em)]'
: '[transform:translateY(0.17em)]',
'pointer-fine:-ml-6 pointer-fine:relative pointer-fine:order-first pointer-fine:self-center pointer-fine:pr-2 pointer-fine:[transform:none]',
'pointer-fine:[.flip-heading-hash_&]:order-last pointer-fine:[.flip-heading-hash_&]:ml-1 pointer-fine:[.flip-heading-hash_&]:pl-2'
)}
iconClassName={tcls('size-4')}
label={tString(language, 'direct_link_to_heading')}
/>
) : null}
@@ -2,7 +2,7 @@
import { useSyncExternalStore } from 'react';
import { type ClassValue, cx } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
const HEADING_ATTR = 'data-heading-reveal-wrapper';
@@ -87,7 +87,7 @@ export function HeadingRevealWrapper(props: {
return (
<Tag
id={id}
className={cx(className, revealed && 'hash-revealed')}
className={tcls(className, revealed && 'hash-revealed')}
onPointerUp={handlePointerUp}
{...{ [HEADING_ATTR]: true }}
{...rest}
@@ -1,14 +1,14 @@
import type { DocumentBlockHint } from '@gitbook/api';
import { Icon, type IconName } from '@gitbook/icons';
import { validateIconName } from '@gitbook/icons/icons';
import { validateIconName } from '@gitbook/icons/validateIconName';
import { Block, type BlockProps } from './Block';
import { Blocks } from './Blocks';
import { BLOCK_LINE_HEIGHT, getBlockTextKind } from './spacing';
import { getBlockTextStyle } from './spacing';
import { getSpaceLanguage, tString } from '@/intl/server';
import { defaultLanguage } from '@/intl/translations';
import { type ClassValue, cx } from '@/lib/classnames';
import { isHeadingBlock } from '@/lib/document';
import { type ClassValue, tcls } from '@/lib/tailwind';
export async function Hint({
block,
@@ -22,7 +22,7 @@ export async function Hint({
const icon = customIcon && validateIconName(customIcon) ? customIcon : hintStyle.icon;
const firstNode = block.nodes[0]!;
const firstLineHeight = BLOCK_LINE_HEIGHT[getBlockTextKind(firstNode)];
const firstLine = getBlockTextStyle(firstNode);
const hasHeading = isHeadingBlock(firstNode);
const language = contextProps.context.contentContext
@@ -33,25 +33,42 @@ export async function Hint({
return (
<div
className={cx(
className={tcls(
'hint',
hasHeading && 'hint-titled',
// Kept as utilities: `AskAIParagraphButton` matches `.hint.bg-*`.
hasHeading ? hintStyle.containerWithHeader : hintStyle.container,
'transition-colors',
'rounded-corners:rounded-md',
'circular-corners:rounded-xl',
hasHeading ? 'circular-corners:rounded-l-none rounded-corners:rounded-l-none' : '',
'overflow-hidden',
hasHeading ? ['border-l-2', hintStyle.containerWithHeader] : hintStyle.container,
'text-sm',
'grid',
'grid-cols-[auto_1fr]',
hasHeading ? 'grid-rows-[auto_auto]' : '',
style
)}
aria-label={label}
role="note"
>
<div className={cx('hint-aside', hasHeading && hintStyle.header, hintStyle.iconColor)}>
<Icon icon={icon} className={cx('hint-icon', firstLineHeight)} />
<div
className={tcls(
'py-4',
'pl-4',
hasHeading ? hintStyle.header : null,
hintStyle.iconColor
)}
>
<Icon icon={icon} className={tcls('size-[1.2em]', 'mt-px', firstLine.lineHeight)} />
</div>
{hasHeading ? (
<Block
style={cx(
'hint-heading flip-heading-hash',
// A utility, to beat the themed backgrounds of `.hash`.
'[&_.hash]:bg-transparent',
style={tcls(
'w-full items-start py-4! pl-3 text-[1em]! *:flex-none',
// Heading hash styles
'flip-heading-hash pr-8 [&_.hash]:bg-transparent',
hintStyle.header
)}
ancestorBlocks={[...ancestorBlocks, block]}
@@ -63,13 +80,27 @@ export async function Hint({
{...contextProps}
ancestorBlocks={[...ancestorBlocks, block]}
nodes={hasHeading ? block.nodes.slice(1) : block.nodes}
blockStyle={cx(
blockStyle={tcls(
hintStyle.body,
// render hash icon on the other side of the heading
'flip-heading-hash'
)}
// Descendant rules stay utilities so they keep beating the nested blocks' own classes.
style="hint-content [&_.hint]:border [&_pre]:border [&_pre]:border-neutral"
style={[
'p-4',
'pl-3',
'empty:p-0',
'-row-end-1',
'-col-end-1',
// Allow the grid track to shrink below its content's min-content size so wide
// nested blocks (e.g. code blocks, tables) scroll internally instead of
// overflowing the hint. Without this, the `1fr` column keeps its default
// `min-width: auto` and grows past the hint's width.
'min-w-0',
'space-y-3',
'[&_.hint]:border',
'[&_pre]:border',
'[&_pre]:border-neutral',
]}
/>
</div>
);
@@ -5,8 +5,8 @@ import { Caption, type CaptionAlign } from './Caption';
import type { DocumentContext } from './DocumentView';
import { getCommentAnchorProps } from './utils';
import { Image, type ImageResponsiveSize } from '@/components/utils';
import { type ClassValue, cx } from '@/lib/classnames';
import { resolveContentRefInDocument } from '@/lib/references';
import { type ClassValue, tcls } from '@/lib/tailwind';
export function Images(props: BlockProps<DocumentBlockImages>) {
const { document, block, style, context, isEstimatedOffscreen } = props;
@@ -17,18 +17,30 @@ export function Images(props: BlockProps<DocumentBlockImages>) {
return (
<div
{...getCommentAnchorProps(context, block.key)}
className={cx(
className={tcls(
style,
'gb-images',
align === 'right' && 'gb-images-right',
align === 'left' && 'gb-images-left'
'flex',
'w-full',
align === 'center' && 'justify-center',
align === 'right' && 'justify-end',
align === 'left' && 'justify-start'
)}
>
<div
className={cx(
'gb-images-row',
hasMultipleImages && 'gb-images-multi',
withFrame && 'gb-images-framed'
className={tcls(
'flex',
'flex-row',
'gap-3',
hasMultipleImages && ['grid', 'grid-flow-col'],
withFrame && [
'rounded-2xl',
'border',
'border-[rgb(234,235,238)]',
'dark:border-[rgb(45,50,58)]',
'relative',
'overflow-hidden',
'w-fit',
]
)}
>
{block.nodes.map((node: any, _i: number) => (
@@ -88,7 +100,7 @@ async function ImageBlock(props: {
}
return (
<div className="gb-image">
<div className={tcls('relative', 'overflow-hidden')}>
<Caption {...props} fit align={align}>
<Image
alt={block.data.alt ?? ''}
@@ -2,8 +2,8 @@ import type { DocumentInlineIcon } from '@gitbook/api';
import { Icon, type IconName } from '@gitbook/icons';
import type { InlineProps } from './Inline';
import { cx } from '@/lib/classnames';
import { textColorToStyle } from '@/lib/colors';
import { tcls } from '@/lib/tailwind';
export async function InlineIcon(props: InlineProps<DocumentInlineIcon>) {
const { inline } = props;
@@ -12,7 +12,7 @@ export async function InlineIcon(props: InlineProps<DocumentInlineIcon>) {
return (
<Icon
icon={icon as IconName}
className={cx('inline-icon', color ? textColorToStyle[color] : null)}
className={tcls('inline size-[1em]', color ? textColorToStyle[color] : null)}
/>
);
}
@@ -4,9 +4,9 @@ import type { DocumentInlineImage } from '@gitbook/api';
import { Image } from '../utils';
import type { InlineProps } from './Inline';
import { cx } from '@/lib/classnames';
import type { GitBookBaseContext } from '@/lib/context';
import { type ResolvedContentRef, resolveContentRefInDocument } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
export async function InlineImage(props: InlineProps<DocumentInlineImage>) {
const { document, inline, context, ancestorInlines } = props;
@@ -30,7 +30,11 @@ export async function InlineImage(props: InlineProps<DocumentInlineImage>) {
return (
/* Ensure images dont expand to the size of the container where this Image may be nested in. Now it's always nested in a size-restricted container */
<span className={cx(size !== 'line' && 'inline-flex max-w-[300px] align-middle')}>
<span
className={tcls(
size !== 'line' ? ['inline-flex', 'max-w-[300px]', 'align-middle'] : null
)}
>
<Image
alt={inline.data.alt ?? inline.data.caption ?? ''}
sizes={sizes}
@@ -93,9 +93,15 @@ function InlineLinkAnchor(props: {
>
{children}
{isMailto ? (
<Icon icon="envelope" className="inline-link-icon inline-link-mail" />
<Icon
icon="envelope"
className="ml-1 inline size-3 links-accent:text-tint-subtle"
/>
) : isExternal ? (
<Icon icon="arrow-up-right" className="inline-link-icon" />
<Icon
icon="arrow-up-right"
className="ml-0.5 inline size-3 links-accent:text-tint-subtle"
/>
) : null}
</StyledLink>
);
@@ -22,7 +22,7 @@ export function List(
tag={getListTag(block.type)}
nodes={block.nodes}
ancestorBlocks={[...ancestorBlocks, block]}
style={['gb-list', style]}
style={['min-w-0 space-y-2', style]}
/>
);
}
@@ -10,10 +10,10 @@ import type {
import type { BlockProps } from './Block';
import { Blocks } from './Blocks';
import { getBlockTextKind } from './spacing';
import { getBlockTextStyle } from './spacing';
import { getCommentAnchorProps } from './utils';
import { Checkbox } from '@/components/primitives';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
export function ListItem(props: BlockProps<DocumentBlockListItem>) {
const { block, ancestorBlocks, ...contextProps } = props;
@@ -32,8 +32,16 @@ export function ListItem(props: BlockProps<DocumentBlockListItem>) {
{...contextProps}
nodes={block.nodes}
ancestorBlocks={[...ancestorBlocks, block]}
blockStyle="gb-list-child"
style="gb-list-body"
blockStyle={tcls(
'min-h-lh',
// remove margin-top for the first heading in a list
'[h2]:pt-0',
'[h3]:pt-0',
'[h4]:pt-0',
// Override the "mx-auto" class from UnwrappedBlocks
'mx-0'
)}
style="flex min-w-0 flex-1 flex-col space-y-2"
/>
);
@@ -51,7 +59,7 @@ export function ListItem(props: BlockProps<DocumentBlockListItem>) {
/>
</ListItemPrefix>
<label htmlFor={block.key} className="flex-1">
<label htmlFor={block.key} className={tcls('flex-1')}>
{blocksElement}
</label>
</ListItemLI>
@@ -122,20 +130,27 @@ function ListItemLI(props: {
anchorProps: ReturnType<typeof getCommentAnchorProps>;
children: React.ReactNode;
}) {
const kind = getBlockTextKind(props.block);
const textStyle = getBlockTextStyle(props.block);
return (
<li
{...props.anchorProps}
className={cx('gb-list-item', kind !== 'body' && `gb-list-item-${kind}`)}
>
<li {...props.anchorProps} className={tcls(textStyle.lineHeight, 'flex items-start')}>
{props.children}
</li>
);
}
// Sized after the item's first line through the `gb-list-item-*` modifier of its parent.
function ListItemPrefix(props: { block: DocumentBlockListItem; children: React.ReactNode }) {
return <div className="gb-list-prefix">{props.children}</div>;
const textStyle = getBlockTextStyle(props.block);
return (
<div
className={tcls(
textStyle.textSize,
textStyle.lineHeight,
'mr-1 flex min-h-lh min-w-6 items-center justify-center text-tint'
)}
>
{props.children}
</div>
);
}
function getUnorderedListItemsPrefixContent(input: { depth: number }): string {
@@ -158,7 +173,7 @@ function PseudoBefore(props: {
}) {
return (
<div
className="gb-list-marker"
className="before:content-(--pseudoBefore--content) before:font-var"
style={
{
'--pseudoBefore--content': `'${props.content}'`,
@@ -5,8 +5,8 @@ import type { BlockProps } from './Block';
import { Inlines } from './Inlines';
import { getTextAlignment } from './utils';
import { getCommentAnchorProps } from './utils';
import { cx } from '@/lib/classnames';
import { getNodeText } from '@/lib/document';
import { tcls } from '@/lib/tailwind';
export function Paragraph(props: BlockProps<DocumentBlockParagraph>) {
const { block, style, ancestorBlocks, ...contextProps } = props;
@@ -21,7 +21,7 @@ export function Paragraph(props: BlockProps<DocumentBlockParagraph>) {
// rendered in overlays (search answers, AI chat) on a background-cover page.
data-cover-aware-text={context.isPageBody ? '' : undefined}
// Paragraph styles live in globals.css (`.paragraph`) to keep the class attribute short.
className={cx('paragraph', style, getTextAlignment(block.data?.align))}
className={tcls('paragraph', style, getTextAlignment(block.data?.align))}
>
<Inlines {...contextProps} nodes={block.nodes} ancestorInlines={[]} />
</p>
@@ -45,7 +45,11 @@ export function Paragraph(props: BlockProps<DocumentBlockParagraph>) {
<div
// The shared `AskAIParagraphButton` portals itself into the hovered wrapper.
data-ask-ai-paragraph=""
className={cx('group/ask-ai relative', style, getTextAlignment(block.data?.align))}
className={tcls(
'group/ask-ai relative',
style,
getTextAlignment(block.data?.align)
)}
>
{paragraph}
</div>
@@ -4,14 +4,14 @@ import {
type DocumentBlockPrompt,
type SiteCustomizationSettings,
} from '@gitbook/api';
import { validateIconName } from '@gitbook/icons/icons';
import { validateIconName } from '@gitbook/icons/validateIconName';
import type { BlockProps } from '../Block';
import { CodeBlock } from '../CodeBlock';
import { getPlainCodeBlock } from '../CodeBlock/highlight-tokens';
import { COMMENT_IGNORE_CLASSNAME, getCommentKeyProp } from '../utils';
import { PromptClient } from './PromptClient';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
const PROMPT_COLLAPSED_LINE_COUNT = 10;
@@ -44,7 +44,7 @@ export function Prompt(props: BlockProps<DocumentBlockPrompt>) {
{...getCommentKeyProp(context, block.key)}
// Only the comment marker: the prompt keeps its own width rather than the block styles.
className={
cx(style).split(' ').includes(COMMENT_IGNORE_CLASSNAME)
tcls(style).split(' ').includes(COMMENT_IGNORE_CLASSNAME)
? COMMENT_IGNORE_CLASSNAME
: undefined
}
@@ -15,6 +15,7 @@ import {
} from '@/components/primitives';
import { tString, useLanguage } from '@/intl/client';
import { AI_AGENTS, getAIAgent } from '@/lib/ai-agents';
import { tcls } from '@/lib/tailwind';
/** How long the copy button shows its confirmation. */
const COPIED_MESSAGE_DURATION = 1000;
@@ -63,7 +64,7 @@ export function PromptActions(props: { prompt: string; openInAIProviders: boolea
return (
// Lifted above the header's overlay button, which otherwise swallows the clicks.
<div className="prompt-actions">
<div className="relative z-20 flex shrink-0 items-center gap-2">
{openInAIProviders ? (
<ButtonGroup>
{mainButton}
@@ -123,8 +124,16 @@ export function PromptActions(props: { prompt: string; openInAIProviders: boolea
function AgentIconStack() {
return (
<span className="flex items-center">
{AI_AGENTS.map((agent) => (
<span key={agent.id} className="prompt-agent">
{AI_AGENTS.map((agent, index) => (
<span
key={agent.id}
className={tcls(
'flex size-4 shrink-0 items-center justify-center rounded-full border border-tint bg-tint-base',
// Each chip's border cuts into the one behind it, so the marks stay legible
// however tightly they are stacked.
index > 0 && '-ms-1.5'
)}
>
<Icon icon={agent.icon} className="size-2.5" />
</span>
))}
@@ -8,7 +8,7 @@ import { Icon, type IconName } from '@gitbook/icons';
import { PromptActions } from './PromptActions';
import { ToggleChevron } from '@/components/primitives';
import { tString, useLanguage } from '@/intl/client';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
type PromptClientProps = DocumentBlockPrompt['data'] & {
contentIcon: IconName | null;
@@ -44,13 +44,18 @@ export function PromptClient(props: PromptClientProps) {
<div
data-block-key={commentKey}
data-comment-block={commentKey ? '' : undefined}
className={cx('prompt-block', expanded && 'prompt-block-expanded', className)}
className={tcls(
'relative flex w-full flex-col overflow-hidden circular-corners:rounded-2xl rounded-corners:rounded-xl straight-corners:rounded-xs text-tint-strong',
'border border-tint-subtle contrast-more:border-tint',
'transition',
expanded ? 'bg-tint depth-subtle:shadow-xs' : 'bg-tint-base',
className
)}
>
<div
className={cx(
// The marker stays for the chevron's `group-hover/prompt-header`.
'group/prompt-header prompt-header',
!isPartiallyExpanded && (open ? 'prompt-header-open' : 'prompt-header-closed')
className={tcls(
'group/prompt-header relative flex min-h-9 flex-row items-center justify-between gap-4 p-3 transition-colors',
!isPartiallyExpanded && (open ? 'hover:bg-tint-hover' : 'hover:bg-tint-subtle')
)}
>
{!isPartiallyExpanded ? (
@@ -59,12 +64,15 @@ export function PromptClient(props: PromptClientProps) {
aria-controls={promptId}
aria-expanded={open}
aria-label={tString(language, 'view')}
className="prompt-toggle"
className={tcls(
'absolute inset-0 z-10 cursor-pointer outline-hidden',
'focus-visible:ring-2 focus-visible:ring-primary-hover'
)}
disabled={!prompt}
onClick={() => setOpen((prev) => !prev)}
/>
) : null}
<div className="prompt-title">
<div className="pointer-events-none relative z-0 flex min-w-0 flex-row items-center gap-2 text-tint-strong">
{!isPartiallyExpanded ? (
<ToggleChevron
open={open}
@@ -78,7 +86,7 @@ export function PromptClient(props: PromptClientProps) {
<PromptActions prompt={prompt} openInAIProviders={openInAIProviders} />
</div>
{isPartiallyExpanded || open ? (
<div id={promptId} className="prompt-body">
<div id={promptId} className="border-t border-tint-subtle bg-tint-base">
{children}
</div>
) : null}
@@ -2,7 +2,6 @@ import type { DocumentBlockQuote } from '@gitbook/api';
import type { BlockProps } from './Block';
import { Blocks } from './Blocks';
import { tcls } from '@/lib/tailwind';
export function Quote(props: BlockProps<DocumentBlockQuote>) {
const { block, style, ancestorBlocks, ...contextProps } = props;
@@ -13,8 +12,7 @@ export function Quote(props: BlockProps<DocumentBlockQuote>) {
tag="blockquote"
nodes={block.nodes}
ancestorBlocks={[...ancestorBlocks, block]}
// Merged here: `text-tint` must beat a hint's `text-neutral-strong` passed in `style`.
style={tcls(style, 'text-tint border-l-2 pl-6 py-3 border-tint space-y-4')}
style={[style, 'text-tint', 'border-l-2', 'pl-6', 'py-3', 'border-tint', 'space-y-4']}
/>
);
}
@@ -5,7 +5,6 @@ import type { DocumentBlockStepperStep } from '@gitbook/api';
import type { BlockProps } from './Block';
import { Blocks } from './Blocks';
import { getCommentAnchorProps } from './utils';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
export function StepperStep(props: BlockProps<DocumentBlockStepperStep>) {
@@ -37,19 +36,24 @@ export function StepperStep(props: BlockProps<DocumentBlockStepperStep>) {
return (
<div
{...getCommentAnchorProps(context, block.key)}
className={cx('stepper-item', tcls(style))}
className={tcls('flex flex-row gap-4 md:gap-8', style)}
>
<div className="stepper-step-marker">
<div className="can-override-bg can-override-text stepper-step-number">
<div className="relative select-none">
<div
className={tcls(
'can-override-bg can-override-text flex size-[calc(1.75rem+1px)] items-center justify-center rounded-full bg-primary-solid theme-muted:bg-tint-base tabular-nums contrast-more:bg-primary-11',
'font-medium text-contrast-primary-solid theme-muted:text-tint contrast-more:text-contrast-primary-11'
)}
>
{index + 1}
</div>
<div className="can-override-bg stepper-step-line" />
<div className="can-override-bg absolute bottom-2 left-3.5 top-9 w-px bg-primary-7 theme-muted:bg-tint-6" />
</div>
<Blocks
{...contextProps}
nodes={block.nodes}
ancestorBlocks={[...ancestorBlocks, block]}
style={['stepper-step-body', marginAdjustClassName]}
style={['min-w-0 flex-1 pb-6 [&>*+*]:mt-5', marginAdjustClassName]}
/>
</div>
);
@@ -7,7 +7,6 @@ import type { TableGridViewProps } from './Table';
import { TableHoverTable } from './TableHoverTable';
import { TableSearchTableBody } from './TableSearch';
import { getColumnAlignment, getColumnVerticalAlignment, type VerticalAlignment } from './utils';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
/** Semantic table renderer used when a cell spans multiple records. */
@@ -27,7 +26,7 @@ export function NativeViewGrid(props: TableGridViewProps) {
{...props}
stickyHeader={withStickyHeader}
stickyFirstColumn={withStickyFirstColumn}
className={cx(
className={tcls(
withStickyHeader
? [
'mb-0 border-t border-r border-l',
@@ -51,7 +50,7 @@ export function NativeViewGrid(props: TableGridViewProps) {
if (withStickyHeader || withStickyFirstColumn) {
return (
<StickyViewGrid
className={cx(tcls(style), 'table-view')}
className={tcls(style, 'relative mx-auto grid w-full min-w-0')}
stickyHeader={withStickyHeader}
tableClassName={tableContainerClassName}
withTableRole={false}
@@ -63,9 +62,9 @@ export function NativeViewGrid(props: TableGridViewProps) {
}
return (
<div className={cx(tcls(style), 'table-view')}>
<div className="table-scroll">
<div className={cx('table-stack', tableContainerClassName)}>
<div className={tcls(style, 'relative mx-auto grid w-full min-w-0')}>
<div className="w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-none border-tint-subtle">
<div className={tcls('flex flex-col', tableContainerClassName)}>
{header}
{body}
</div>
@@ -87,13 +86,13 @@ function NativeViewGridHeader(
return (
<div
aria-hidden="true"
className={cx(
'table-native-header',
(stickyHeader || !stickyFirstColumn) && 'table-header-clip',
className={tcls(
'mb-1 rounded-lg border border-tint-subtle bg-tint',
stickyHeader || !stickyFirstColumn ? 'overflow-hidden' : undefined,
className
)}
>
<table className="table-native">
<table className="w-full table-fixed border-separate border-spacing-0">
<NativeViewGridColumns {...props} />
<thead>
<tr>
@@ -109,12 +108,12 @@ function NativeViewGridHeader(
<th
key={column}
scope="col"
className={cx(
'table-header-cell',
className={tcls(
'relative px-3 py-2 font-medium text-sm text-tint-strong',
isStickyFirstColumn
? stickyHeader
? 'table-header-cell-pinned'
: 'table-header-cell-sticky'
? 'z-20 bg-tint'
: 'sticky left-0 z-20 bg-tint'
: undefined,
getColumnAlignment(definition)
)}
@@ -150,7 +149,14 @@ function NativeViewGridBody(
const recordIndexes = new Map(records.map((record, index) => [record[0], index] as const));
return (
<TableHoverTable className="table-native table-native-body">
<TableHoverTable
className={tcls(
'w-full table-fixed border-separate border-spacing-0',
'[&>tbody>tr>td[data-table-hovered]]:bg-tint-hover',
'[&>tbody>tr+tr>td]:border-t',
'[&>tbody+tbody>tr:first-child>td]:border-t'
)}
>
<NativeViewGridColumns {...props} />
{withHeader ? (
<thead className="sr-only">
@@ -219,11 +225,15 @@ function NativeViewGridBody(
data-table-row-end={
recordIndex + (cellMerge?.merge.rowSpan ?? 1) - 1
}
className={cx(
'table-native-cell',
!isLastColumn && 'table-native-cell-divider',
className={tcls(
'relative px-3 py-2 text-sm transition-colors',
!isLastColumn
? 'border-tint-subtle border-r'
: undefined,
getNativeCellVerticalAlignment(verticalAlignment),
isStickyFirstColumn && 'table-native-cell-sticky'
isStickyFirstColumn
? 'sticky left-0 z-10 bg-tint-base'
: undefined
)}
>
<RecordColumnValue
@@ -7,12 +7,13 @@ import {
import { isRecordColumnEmpty } from './isRecordColumnEmpty';
import { RecordColumnValue } from './RecordColumnValue';
import { RecordCardStyles } from './styles';
import type { TableRecordKV, TableViewProps } from './Table';
import { getRecordCardCovers } from './utils';
import { LinkBox, LinkOverlay } from '@/components/primitives';
import { Image } from '@/components/utils';
import { cx } from '@/lib/classnames';
import { type ResolvedContentRef, resolveContentRefInDocument } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
export async function RecordCard(
props: TableViewProps<DocumentTableViewCards> & {
@@ -56,14 +57,36 @@ export async function RecordCard(
// Marks the card body so overflow-clipped affordances (e.g. the paragraph "Ask"
// button) can opt out of rendering inside it.
data-card=""
className={cx(
'record-card-body',
className={tcls(
'grid-area-1-1',
'relative',
'grid',
'bg-tint-base',
'w-[calc(100%+2px)]',
'h-[calc(100%+2px)]',
'-inset-px',
'rounded-sm',
'straight-corners:rounded-none',
'circular-corners:rounded-xl',
'overflow-hidden',
'[&_.heading>div:first-child]:hidden',
'[&_.heading>div]:text-[.8em]',
'@xl:[&_.heading>div]:text-[1em]',
'[&_.blocks:first-child_.heading]:pt-0', // Remove padding-top on first heading in card
// On mobile, check if we can display the cover responsively or not:
// - If the file has a landscape aspect ratio, we display it normally
// - If the file is square or portrait, we display it left with 40% of the card width
lightCoverIsSquareOrPortrait || darkCoverIsSquareOrPortrait
? [
lightCoverIsSquareOrPortrait && 'record-card-body-portrait',
darkCoverIsSquareOrPortrait && 'record-card-body-portrait-dark',
]
: 'record-card-body-landscape'
lightCoverIsSquareOrPortrait
? '@sm:grid-cols-none grid-cols-[40%__1fr] @sm:grid-rows-[auto_1fr]'
: '',
darkCoverIsSquareOrPortrait
? 'dark:@sm:grid-cols-none dark:grid-cols-[40%__1fr] dark:@sm:grid-rows-[auto_1fr]'
: '',
].filter(Boolean)
: 'grid-rows-[auto_1fr]'
)}
>
{lightCover ? (
@@ -93,20 +116,37 @@ export async function RecordCard(
},
]}
resize={context.contentContext?.imageResizer}
className={cx(
'record-card-cover',
className={tcls(
'min-w-0',
'w-full',
'h-full',
'bg-tint-subtle',
lightCoverIsSquareOrPortrait || darkCoverIsSquareOrPortrait
? [
lightCoverIsSquareOrPortrait && 'record-card-cover-portrait',
darkCoverIsSquareOrPortrait && 'record-card-cover-portrait-dark',
]
: 'record-card-cover-landscape',
lightCoverIsSquareOrPortrait ? '@sm:aspect-video @sm:h-auto' : '',
darkCoverIsSquareOrPortrait
? 'dark:@sm:aspect-video dark:@sm:h-auto'
: '',
].filter(Boolean)
: ['h-auto', 'aspect-video'],
objectFits
)}
loading={isOffscreen && context.mode !== 'print' ? 'lazy' : 'eager'}
/>
) : null}
<div className="record-card-content">
<div
className={tcls(
'min-w-0',
'w-full',
'flex',
'flex-col',
'place-self-start',
'gap-3',
'p-4',
'text-sm',
'text-tint-strong'
)}
>
{view.columns.map((column) => {
const definition = block.data.definition[column];
@@ -123,8 +163,8 @@ export async function RecordCard(
if (!view.hideColumnTitle && definition.title) {
const ariaLabelledBy = `${block.key}-${column}-title`;
return (
<div key={column} className="record-card-field">
<div id={ariaLabelledBy} className="record-card-field-title">
<div key={column} className="flex flex-col gap-1">
<div id={ariaLabelledBy} className="text-sm text-tint">
{definition.title}
</div>
<RecordColumnValue
@@ -163,7 +203,7 @@ export async function RecordCard(
);
}
return <div className="record-card">{body}</div>;
return <div className={tcls(RecordCardStyles)}>{body}</div>;
}
/**
@@ -22,10 +22,10 @@ import {
import { Checkbox } from '@/components/primitives';
import { StyledLink } from '@/components/primitives';
import { Image } from '@/components/utils';
import { cx } from '@/lib/classnames';
import { getNodeFragmentByName } from '@/lib/document';
import { getSimplifiedContentType } from '@/lib/files';
import { resolveContentRefInDocument } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
import { filterOutNullable } from '@/lib/typescript';
const alignmentMap: Record<'text-left' | 'text-center' | 'text-right', string> = {
@@ -75,7 +75,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
}
return (
<Checkbox
className="h-5 w-5"
className={tcls('w-5', 'h-5')}
checked={value}
disabled={true}
aria-labelledby={ariaLabelledBy}
@@ -90,12 +90,16 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
const max = definition.max;
return (
<Tag className="record-rating">
<Tag className={tcls('inline-grid')}>
{value ? (
<>
<span className="record-rating-stars">
<span className={tcls('inline-flex', 'grid-area-1-1', 'gap-0.5')}>
{Array.from({ length: max }).map((_, i) => (
<Icon key={i} icon="star" className="record-rating-star" />
<Icon
key={i}
icon="star"
className={tcls('size-[15px]', 'text-primary/5')}
/>
))}
</span>
<span
@@ -105,14 +109,14 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
aria-valuenow={rating}
aria-valuemin={1}
aria-valuemax={definition.max}
className="record-rating-stars"
className={tcls('inline-flex', 'grid-area-1-1', 'gap-0.5')}
>
{Array.from({ length: rating }).map((_, i) => (
<Icon
key={i}
icon="star"
iconStyle={IconStyle.SharpSolid}
className="record-rating-star-filled"
className={tcls('size-[15px]', 'text-primary')}
/>
))}
</span>
@@ -126,7 +130,10 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
return null;
}
return (
<Tag className="record-number" aria-labelledby={ariaLabelledBy}>{`${value}`}</Tag>
<Tag
className={tcls('text-base', 'tabular-nums', 'tracking-tighter')}
aria-labelledby={ariaLabelledBy}
>{`${value}`}</Tag>
);
}
case 'text': {
@@ -135,7 +142,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
}
const fragment = getNodeFragmentByName(block, value);
if (!fragment) {
return <Tag className={cx('w-full', verticalAlignment)}>{''}</Tag>;
return <Tag className={tcls(['w-full', verticalAlignment])}>{''}</Tag>;
}
const horizontalAlignment = getColumnAlignment(definition);
@@ -147,8 +154,15 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
document={document}
ancestorBlocks={[...ancestorBlocks, block]}
nodes={fragment.nodes}
// Alignment stays as utilities: they must beat the alignment set by the blocks inside.
style={['blocks record-text', verticalAlignment, horizontalClasses]}
style={[
'blocks',
'w-full',
'space-y-2',
'lg:space-y-3',
'leading-normal',
verticalAlignment,
horizontalClasses,
]}
context={context}
blockStyle={['w-full', 'max-w-[unset]']}
wrapperProps={{
@@ -177,7 +191,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
);
return (
<Tag className="text-base" aria-labelledby={ariaLabelledBy}>
<Tag className={tcls('text-base')} aria-labelledby={ariaLabelledBy}>
{files.filter(filterOutNullable).map((ref, index) => {
const contentType = ref.file
? getSimplifiedContentType(ref.file.contentType)
@@ -187,7 +201,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
<StyledLink
key={index}
href={ref.href}
className="record-file-link"
className="flex flex-row items-center gap-2"
insights={
ref.file
? {
@@ -221,7 +235,10 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
loading={context.mode === 'print' ? 'eager' : 'lazy'}
/>
) : (
<FileIcon contentType={contentType} className="size-4" />
<FileIcon
contentType={contentType}
className={tcls('size-4')}
/>
)}
{ref.text}
</StyledLink>
@@ -242,7 +259,10 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
})
: null;
return (
<Tag className="record-ref" aria-labelledby={ariaLabelledBy}>
<Tag
className={tcls('text-base', 'text-balance', 'flex', 'items-center')}
aria-labelledby={ariaLabelledBy}
>
{resolved?.icon ?? null}
{resolved ? (
<StyledLink
@@ -291,7 +311,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
);
return (
<Tag className="text-base" aria-labelledby={ariaLabelledBy}>
<Tag className={tcls('text-base')} aria-labelledby={ariaLabelledBy}>
{resolved.filter(filterOutNullable).map(([contentRef, resolved], index) => (
<StyledLink
key={index}
@@ -316,7 +336,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
}
return (
<Tag aria-labelledby={ariaLabelledBy}>
<span className="record-select">
<span className={tcls('inline-flex', 'gap-2', 'flex-wrap')}>
{value.map((selectId) => {
const option = definition.options.find(
(option) => option.value === selectId
@@ -327,7 +347,18 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
}
return (
<span key={option.value} className="record-select-option">
<span
key={option.value}
className={tcls(
'text-sm',
'whitespace-pre',
'rounded-sm',
'py-1',
'px-2',
'bg-primary',
'text-primary-strong'
)}
>
{option.label}
</span>
);
@@ -354,10 +385,10 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
}
return (
<Tag className="text-base" aria-labelledby={ariaLabelledBy}>
<Tag className={tcls('text-base')} aria-labelledby={ariaLabelledBy}>
<StyledLink
href={image.href}
className="record-file-link"
className="flex flex-row items-center gap-2"
insights={
image.file
? {
@@ -6,7 +6,7 @@ import type { TableGridViewProps, TableRecordKV } from './Table';
import { TableSearchRecord } from './TableSearch';
import './styles.css';
import { getColumnVerticalAlignment } from './utils';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
export function RecordRow(
props: TableGridViewProps & {
@@ -24,7 +24,7 @@ export function RecordRow(
role="row"
recordId={record[0]}
visibleClassName="flex"
className="table-grid-row"
className={tcls('group/row', 'table-grid-row')}
>
{view.columns.map((column) => {
const cellMerge = getTableCellMerge(cellMergeLayout, record[0], column);
@@ -53,7 +53,7 @@ export function RecordRow(
role="cell"
{...getCommentCellProps(context, record[0], column)}
aria-colspan={cellMerge?.merge.colSpan}
className={cx(
className={tcls(
'table-grid-cell',
isStickyFirstColumnCell ? 'table-grid-cell-sticky' : undefined
)}
@@ -2,7 +2,7 @@
import { type ReactNode, useCallback, useEffect, useLayoutEffect, useRef } from 'react';
import { useScrollListener } from '@/components/hooks/useScrollListener';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
interface StickyViewGridProps {
className?: string;
@@ -31,9 +31,12 @@ function DefaultHeaderScrollGrid({
return (
<div className={className}>
<div role={withTableRole ? 'table' : undefined} className="group/table table-sticky">
<div className="table-scroll">
<div className={cx('table-stack', resolvedTableClassName)}>
<div
role={withTableRole ? 'table' : undefined}
className="group/table relative flex w-full min-w-0 max-w-full flex-col rounded-lg border-tint-subtle"
>
<div className="w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-none border-tint-subtle">
<div className={tcls('flex', 'flex-col', resolvedTableClassName)}>
{header}
{children}
</div>
@@ -139,14 +142,27 @@ function StickyHeaderOverlayScrollGrid({
<div className={className}>
<div
ref={rootRef}
className="group/table table-sticky"
className="group/table relative flex w-full min-w-0 max-w-full flex-col rounded-lg border-tint-subtle data-[scrollable=true]:border"
data-scrollable="false"
role={withTableRole ? 'table' : undefined}
>
{header ? (
<div ref={stickyHeaderRef} className="table-sticky-header">
<div
ref={stickyHeaderRef}
className={tcls(
'sticky z-20 w-full min-w-0 max-w-full overflow-hidden rounded-t-[inherit]',
'[top:var(--toc-top-offset,var(--outline-top-offset,0px))]'
)}
>
<div
className={cx('table-sticky-header-track', resolvedTableClassName)}
className={tcls(
'flex',
'flex-col',
resolvedTableClassName,
// The sticky header is rendered outside the scroll container, so it
// needs to mirror the body's horizontal scroll position.
'[transform:translateX(var(--table-sticky-scroll-left,0px))]'
)}
style={{ width: 'var(--table-sticky-table-width)' }}
>
{header}
@@ -154,8 +170,14 @@ function StickyHeaderOverlayScrollGrid({
</div>
) : null}
<div ref={bodyScrollRef} className="table-scroll table-sticky-scroll">
<div ref={bodyTableRef} className={cx('table-stack', resolvedTableClassName)}>
<div
ref={bodyScrollRef}
className="w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-none border-tint-subtle group-data-[scrollable=true]/table:mx-px group-data-[scrollable=true]/table:rounded-none group-data-[scrollable=true]/table:border-0"
>
<div
ref={bodyTableRef}
className={tcls('flex', 'flex-col', resolvedTableClassName)}
>
{children}
</div>
</div>
@@ -23,7 +23,6 @@ import {
} from './TableSearch';
import { ViewCards } from './ViewCards';
import { ViewGrid, ViewGridHeader } from './ViewGrid';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
export type { TableRecordKV };
@@ -79,7 +78,7 @@ export function Table(props: BlockProps<DocumentBlockTable>) {
{...getCommentAnchorProps(context, block.key)}
// Owns clicks inside, e.g. on blocks of a record's own document; cells still win.
{...getCommentMarkerProps(context, 'data-comment-block')}
className={cx(tcls(style), 'table-block')}
className={tcls(style, 'flex flex-col gap-3')}
>
{showSearch ? (
<TableSearchInput
@@ -156,7 +155,7 @@ function TableView({
if (withStickyHeader || withStickyFirstColumn) {
return (
<StickyViewGrid
className={cx(tcls(style), 'table-view')}
className={tcls(style, 'relative mx-auto grid w-full min-w-0')}
stickyHeader={withStickyHeader}
tableClassName={tableContainerClassName}
header={
@@ -164,7 +163,7 @@ function TableView({
<ViewGridHeader
{...gridProps}
tableClassName={tableContainerClassName}
className={cx(
className={tcls(
withStickyHeader
? [
'mb-0 border-t border-r border-l',
@@ -185,13 +184,21 @@ function TableView({
}
return (
<div className={cx(tcls(style), 'table-view')}>
<div className="table-scroll">
<div className={cx('table-stack', tableContainerClassName)} role="table">
<div className={tcls(style, 'relative mx-auto grid w-full min-w-0')}>
<div
className={tcls(
'w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-none border-tint-subtle '
)}
>
<div
className={tcls('flex', 'flex-col', tableContainerClassName)}
role="table"
>
{withHeader ? (
<ViewGridHeader
{...gridProps}
tableClassName={tableContainerClassName}
className={tableContainerClassName}
/>
) : null}
<ViewGrid {...gridProps} tableClassName={tableContainerClassName} />
@@ -47,9 +47,9 @@ describe('ViewCards', () => {
expect(markup).toContain('-mx-4 sm:-mx-6 md:-mx-8 2xl:-mx-12');
expect(markup).toContain('scroll-px-4');
expect(markup).toContain('2xl:scroll-px-12');
expect(markup).toContain('scroll-container-prev-x');
expect(markup).toContain('left-0');
expect(markup).toContain('2xl:ml-8');
expect(markup).toContain('scroll-container-next-x');
expect(markup).toContain('right-0');
expect(markup).toContain('2xl:mr-8');
expect(markup).not.toContain('before:bg-linear-to-r');
expect(markup).not.toContain('after:bg-linear-to-l');
@@ -59,6 +59,6 @@ describe('ViewCards', () => {
it('renders the wrapping grid by default', () => {
const markup = renderWithContext(<ViewCards {...makeProps(true)} />);
expect(markup).toContain('record-cards');
expect(markup).toContain('inline-grid');
});
});
@@ -4,7 +4,6 @@ import { RecordCard } from './RecordCard';
import type { TableViewProps } from './Table';
import { TableSearchRecord } from './TableSearch';
import { ScrollContainer } from '@/components/primitives/ScrollContainer';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
export function ViewCards(props: TableViewProps<DocumentTableViewCards>) {
@@ -26,10 +25,12 @@ function CardsGrid(props: TableViewProps<DocumentTableViewCards>) {
return (
<div
className={cx(
tcls(style),
'record-cards',
view.cardSize === 'large' ? 'record-cards-large' : 'record-cards-medium',
className={tcls(
style,
'inline-grid',
'gap-4',
'grid-cols-1',
view.cardSize === 'large' ? '@xl:grid-cols-2' : '@2xl:grid-cols-3 @sm:grid-cols-2', // Large cards break earlier to avoid becoming *too* big.
block.data.fullWidth ? 'large:flex-column' : null
)}
>
@@ -69,10 +70,12 @@ const PEEK = {
function CardsCarousel(props: TableViewProps<DocumentTableViewCards>) {
const { view, records } = props;
const itemClassName = cx(
'record-carousel-item',
view.cardSize === 'large' ? 'record-carousel-item-large' : 'record-carousel-item-medium'
);
// Cards need a fixed width so the row overflows and scrolls; mirror the grid's
// medium/large sizing.
const cardWidth =
view.cardSize === 'large'
? 'w-[90%] @sm:w-[calc(45%-0.5rem)] @5xl:w-[calc(50%-0.5rem)]'
: 'w-[90%] @sm:w-[calc(45%-0.5rem)] @xl:w-[calc(30%-0.66rem)] @5xl:w-[calc(33.33%-0.66rem)]';
return (
<ScrollContainer
@@ -105,7 +108,15 @@ function CardsCarousel(props: TableViewProps<DocumentTableViewCards>) {
<TableSearchRecord
key={record[0]}
recordId={record[0]}
visibleClassName={itemClassName}
// `grid grid-cols-1` stretches the card to fill the fixed-width,
// equal-height track; `snap-start` aligns it to the left edge.
visibleClassName={tcls(
'grid',
'grid-cols-1',
'shrink-0',
'snap-start',
cardWidth
)}
>
<RecordCard {...props} record={record} />
</TableSearchRecord>
@@ -2,7 +2,7 @@ import { getColumnWidth, getViewGridLayout } from './layout';
import { RecordRow } from './RecordRow';
import type { TableGridViewProps } from './Table';
import { getColumnAlignment } from './utils';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
interface ViewGridHeaderProps extends TableGridViewProps {
className?: string;
@@ -27,14 +27,14 @@ export function ViewGridHeader(props: ViewGridHeaderProps) {
return (
<div
role="rowgroup"
className={cx(
className={tcls(
tableClassName ?? tableWidth,
'table-grid-header',
(withStickyHeader || !stickyFirstColumn) && 'table-header-clip',
'mb-1 flex flex-col rounded-lg border border-tint-subtle bg-tint',
withStickyHeader || !stickyFirstColumn ? 'overflow-hidden' : undefined,
className
)}
>
<div role="row" className="table-grid-header-row">
<div role="row" className={tcls('flex', 'w-full')}>
{view.columns.map((column) => {
const definition = block.data.definition[column];
if (!definition) {
@@ -45,12 +45,12 @@ export function ViewGridHeader(props: ViewGridHeaderProps) {
<div
key={column}
role="columnheader"
className={cx(
'table-header-cell',
className={tcls(
'relative px-3 py-2 font-medium text-sm text-tint-strong',
stickyFirstColumn && column === firstVisibleColumn
? withStickyHeader
? 'table-header-cell-pinned'
: 'table-header-cell-sticky'
? 'z-20 bg-tint'
: 'sticky left-0 z-20 bg-tint'
: undefined,
getColumnAlignment(definition)
)}
@@ -89,7 +89,10 @@ export function ViewGrid(props: ViewGridProps) {
});
const body = (
<div role="rowgroup" className={cx('table-grid-body', tableClassName ?? tableWidth)}>
<div
role="rowgroup"
className={tcls('flex', 'flex-col', tableClassName ?? tableWidth, '[&>*+*]:border-t')}
>
{records.map((record) => (
<RecordRow
key={record[0]}
@@ -102,5 +105,5 @@ export function ViewGrid(props: ViewGridProps) {
</div>
);
return <div className={cx('table-stack', tableClassName ?? tableWidth)}>{body}</div>;
return <div className={tcls('flex', 'flex-col', tableClassName ?? tableWidth)}>{body}</div>;
}
@@ -23,12 +23,6 @@
}
.table-grid-cell-sticky {
@apply sticky left-0 z-10 bg-tint-base;
@media (hover: hover) {
.table-grid-row:hover > & {
@apply bg-tint-hover;
}
}
@apply sticky left-0 z-10 bg-tint-base group-hover/row:bg-tint-hover;
}
}
@@ -0,0 +1,26 @@
import type { ClassValue } from '@/lib/tailwind';
export const RecordCardStyles = [
'group',
'grid',
'shadow-1xs',
'shadow-tint-9/1',
'depth-flat:shadow-none',
'rounded-sm',
'straight-corners:rounded-none',
'circular-corners:rounded-xl',
'dark:shadow-transparent',
'before:pointer-events-none',
'before:grid-area-1-1',
'before:transition-shadow',
'before:w-full',
'before:h-full',
'before:rounded-[inherit]',
'before:ring-1',
'before:ring-tint-12/2',
'before:z-10',
'before:relative',
] as ClassValue;
export const RecordCardLinkStyles = ['hover:before:ring-primary-hover'] as ClassValue;
@@ -10,7 +10,6 @@ import { DropdownMenu, DropdownMenuItem } from '@/components/primitives';
import { useResolvedSlug, useSelect } from '@/components/Select';
import { useLanguage } from '@/intl/client';
import { tString } from '@/intl/translate';
import { cx } from '@/lib/classnames';
import {
SELECT_DEFAULT_ATTR,
SELECT_GROUP_ATTR,
@@ -18,6 +17,7 @@ import {
SELECT_PINNED_ATTR,
SELECT_UNPINNED_ATTR,
} from '@/lib/select';
import { tcls } from '@/lib/tailwind';
import { resolveAnchorURL } from '@/lib/urls';
export interface TabsItem {
@@ -81,7 +81,17 @@ export function DynamicTabs(props: { tabs: TabsItem[]; setClassName: string; cla
);
return (
<div {...{ [SELECT_GROUP_ATTR]: '' }} className={cx('tabs-block', setClassName, className)}>
<div
{...{ [SELECT_GROUP_ATTR]: '' }}
className={tcls(
'rounded-lg',
'straight-corners:rounded-xs',
'ring-1 ring-tint-subtle ring-inset',
'flex min-w-0 flex-col',
setClassName,
className
)}
>
<TabItemList tabs={tabs} activeTabId={activeTabId} onSelect={selectTab} />
{tabs.map((tab, index) => (
<TabPanel
@@ -118,9 +128,9 @@ const TabPanel = memo(function TabPanel(props: {
role="tabpanel"
id={tab.id}
aria-labelledby={getTabButtonId(tab.id)}
className="tabs-panel"
className="scroll-mt-[calc(var(--content-scroll-margin)+var(--spacing)*20)]"
>
<div className="tabs-panel-body">{tab.body}</div>
<div className="px-8 py-6">{tab.body}</div>
</div>
);
});
@@ -150,7 +160,18 @@ const TabItemList = memo(function TabItemList(props: {
ref={containerRef}
role="tablist"
onKeyDown={moveFocusBetweenTabs}
className="tabs-list"
className={tcls(
'group/tabs',
'overflow-hidden',
'rounded-t-lg',
'straight-corners:rounded-t-xs',
'inline-flex',
'self-stretch',
'after:flex-1',
'after:bg-tint-12/1',
// if last tab is selected, apply rounded to :after element
'[&:has(button.active-tab:last-of-type):after]:rounded-bl-md'
)}
>
{/* When we measure, we add the menu at start to be sure everything's fit. */}
{isMeasuring ? (
@@ -244,18 +265,19 @@ const TabItem = memo(function TabItem(props: {
onClick={() => onSelect(tab.id)}
wrapperClassName={
isActive
? 'tabs-item-current'
? // Keeps room for the overflow menu button.
'max-w-[calc(100%-3rem)]'
: isMeasuring
? // Measured after the active tab, at their narrowest, so the menu only takes
// the tabs that can't fit even truncated.
'tabs-item-measuring'
'order-1 max-w-28'
: // Equal shares capped at their own width, so no tab drops below that
// narrowest size; the high grow leaves the strip's filler only the leftover.
'tabs-item-fluid'
'min-w-0 max-w-max basis-0 grow-[1000]'
}
>
{tab.icon && <Icon icon={tab.icon} className="tabs-button-icon" />}
<span className="tabs-button-label">{tab.title}</span>
{tab.icon && <Icon icon={tab.icon} className="size-4 shrink-0" />}
<span className="min-w-0 truncate">{tab.title}</span>
</TabButton>
);
});
@@ -272,13 +294,59 @@ function TabButton(
const { isActive, wrapperClassName, ...rest } = props;
return (
<div
className={cx(
'tabs-item',
(props['aria-selected'] || props['aria-expanded'] || isActive) && 'active-tab',
className={tcls(
'relative',
'flex items-center',
//prev from active-tab
'[&:has(+_.active-tab)]:rounded-br-md',
//next from active-tab
'[.active-tab+&]:rounded-bl-md',
//next from active-tab
'[.active-tab_+_:after]:rounded-br-md',
'after:transition-colors',
'after:border-r',
'after:absolute',
'after:left-[unset]',
'after:right-0',
'after:border-tint',
'after:top-[15%]',
'after:h-[70%]',
'after:w-px',
'last:after:border-transparent',
'text-tint',
'bg-tint-12/1',
'hover:text-tint-strong',
'max-w-full',
'shrink-0',
'truncate',
props['aria-selected'] || props['aria-expanded'] || isActive
? [
'active-tab',
'text-tint-strong',
'bg-transparent',
'[&.active-tab]:after:border-transparent',
'[:has(+_&.active-tab)]:after:border-transparent',
'[:has(&_+)]:after:border-transparent',
]
: null,
wrapperClassName
)}
>
<button {...rest} type="button" className={cx('tabs-button', props.className)} />
<button
{...rest}
type="button"
className={tcls(
'relative inline-flex min-w-0 max-w-full items-center gap-1.5 px-4 py-2.5 font-medium text-sm transition-[color]',
props.className
)}
/>
</div>
);
}
@@ -1,6 +1,6 @@
import type { DocumentBlockTabs } from '@gitbook/api';
import type { IconName } from '@gitbook/icons';
import { validateIconName } from '@gitbook/icons/icons';
import { validateIconName } from '@gitbook/icons/validateIconName';
import type { BlockProps } from '../Block';
import { Blocks } from '../Blocks';
@@ -41,7 +41,7 @@ export function Tabs(props: BlockProps<DocumentBlockTabs>) {
ancestorBlocks={[...ancestorBlocks, block, tab]}
context={context}
blockStyle="flip-heading-hash"
style="tabs-panel-blocks"
style="w-full space-y-4"
/>
),
};
@@ -13,8 +13,8 @@ import type {
DocumentTextMark,
} from '@gitbook/api';
import { cx } from '@/lib/classnames';
import { backgroundColorToStyle, textColorToStyle } from '@/lib/colors';
import { tcls } from '@/lib/tailwind';
export function Text(props: { text: DocumentText }) {
const { text } = props;
@@ -94,7 +94,31 @@ function Subscript(props: MarkedLeafProps<DocumentMarkSubscript>) {
}
function Code(props: MarkedLeafProps<DocumentMarkCode>) {
return <code className="inline-code">{props.children}</code>;
return (
<code
className={tcls(
'py-px',
'px-1.5',
'min-w-6.5',
'justify-center',
'items-center',
'leading-normal',
'ring-1',
'ring-inset',
'ring-tint',
'bg-tint',
'rounded-sm',
// Text size is proportional to the font-size of the parent element
'text-[.875em]',
// We ensure that the code is not making the parent bigger, especially in headings
'leading-[calc(max(1.20em,1.25rem))]',
'break-words',
'hyphens-none'
)}
>
{props.children}
</code>
);
}
function Color(props: MarkedLeafProps<DocumentMarkColor>) {
@@ -104,10 +128,10 @@ function Color(props: MarkedLeafProps<DocumentMarkColor>) {
data-highlight={
mark.data.background && mark.data.background !== 'default' ? '' : undefined
}
className={cx(
className={tcls([
textColorToStyle[mark.data.text ?? 'default'],
backgroundColorToStyle[mark.data.background ?? 'default']
)}
backgroundColorToStyle[mark.data.background ?? 'default'],
])}
>
{children}
</span>
@@ -12,7 +12,6 @@ import {
getNumericDateFormatter,
getShortDateFormatter,
} from '@/components/utils/dates';
import { cx } from '@/lib/classnames';
import { getRevisionTags, resolveBlockTags } from '@/lib/tags';
import { tcls } from '@/lib/tailwind';
@@ -49,18 +48,23 @@ export function Update(props: BlockProps<DocumentBlockUpdate>) {
return (
<FilteredUpdate
tagSlugs={resolvedTags.map((tag) => tag.slug)}
className={cx('update-block', tcls(style))}
className={tcls('relative flex flex-col gap-2 md:flex-row md:gap-4 lg:gap-8', style)}
>
<div className="update-block-aside">
<div
className={tcls(
// Date is only sticky on larger screens when we use flex-row layout, with 0px fallback to prevent flicker and flaky tests before JS sets the variable
'h-fit w-40 min-w-40 shrink-0 md:sticky md:top-[calc(var(--toc-top-offset,0px)+8px)]!'
)}
>
<time
// Adding a dateTime attribute for accessibility (and SEO)
dateTime={date}
className="update-block-date"
className="inline-flex items-center text-sm font-medium tracking-wide text-neutral-10"
>
{dateFormatter.format(parsedDate)}
</time>
{resolvedTags.length > 0 ? (
<div className="update-block-tags">
<div className="mt-2 flex flex-wrap gap-1.5">
{resolvedTags.map((tag) => (
<Tag key={tag.slug} tag={tag} />
))}
@@ -71,7 +75,7 @@ export function Update(props: BlockProps<DocumentBlockUpdate>) {
{...contextProps}
nodes={block.nodes}
ancestorBlocks={[...ancestorBlocks, block]}
style="update-block-body"
style="flex flex-1 flex-col [&>*+*]:mt-5 [&>*:first-child]:!pt-0"
/>
</FilteredUpdate>
);
@@ -11,7 +11,7 @@ export function Updates(props: BlockProps<DocumentBlockUpdates>) {
{...contextProps}
nodes={block.nodes}
ancestorBlocks={[...ancestorBlocks, block]}
style={[style, 'updates-block']}
style={[style, 'updates-block flex flex-col gap-20']}
/>
);
}
@@ -8,6 +8,7 @@ import { Icon } from '@gitbook/icons';
import { TagIcon } from '../Tag';
import { Button } from '@/components/primitives';
import { tcls } from '@/lib/tailwind';
import {
UPDATES_FILTER_KEY_ATTR,
UPDATES_FILTER_SEARCH_PARAM,
@@ -170,9 +171,9 @@ export function UpdatesTagFilters(props: {
}
return (
<div className="updates-filter">
<div className="updates-filter-header">
<div className="updates-filter-label">
<div className="shrink-0 border-b border-tint-subtle pb-4 pt-px">
<div className="mb-3 ml-3 flex items-center justify-between gap-2">
<div className="leading-wider flex items-center gap-1 text-xs font-semibold uppercase text-tint">
<Icon icon="tags" className="size-3" />
{tagsLabel}
</div>
@@ -187,7 +188,7 @@ export function UpdatesTagFilters(props: {
className="pointer-events-none invisible text-xs"
/>
</div>
<div className="updates-filter-tags">
<div className="flex flex-wrap gap-1.5 px-3">
{tags.map((tag) => (
<TagChip key={tag.slug} tag={tag} onToggle={toggleTag} />
))}
@@ -196,6 +197,12 @@ export function UpdatesTagFilters(props: {
);
}
const CHIP_CLASS =
'inline-flex max-w-full rounded-full circular-corners:rounded-2xl straight-corners:rounded-xs not-focus-visible:outline-0 focus-visible:ring-2 focus-visible:ring-primary';
const CHIP_VARIANT_CLASS =
'max-w-full items-center gap-1 rounded-full px-2 py-1 font-medium text-xs leading-normal transition-colors circular-corners:rounded-2xl straight-corners:rounded-xs';
function TagChip(props: { tag: RevisionTag; onToggle: (tag: string) => void }) {
const { tag, onToggle } = props;
const { selectedTagSet } = useUpdatesFilter();
@@ -206,25 +213,34 @@ function TagChip(props: { tag: RevisionTag; onToggle: (tag: string) => void }) {
type="button"
aria-pressed={selectedTagSet.has(tag.slug)}
onClick={onClick}
className="updates-chip"
className={CHIP_CLASS}
>
<span
{...{ [UPDATES_TAG_CHIP_SELECTED_ATTR]: tag.slug }}
className="updates-chip-face updates-chip-selected"
className={tcls(
CHIP_VARIANT_CLASS,
'hidden bg-primary-original text-contrast-primary-original hover:bg-primary-solid-hover'
)}
>
<TagIcon tag={tag} />
<span className="truncate">{tag.label}</span>
</span>
<span
{...{ [UPDATES_TAG_CHIP_UNSELECTED_DIMMED_ATTR]: tag.slug }}
className="updates-chip-face updates-chip-dimmed"
className={tcls(
CHIP_VARIANT_CLASS,
'hidden bg-tint-5 text-tint-strong opacity-8 hover:bg-tint-hover hover:opacity-11'
)}
>
<TagIcon tag={tag} />
<span className="truncate">{tag.label}</span>
</span>
<span
{...{ [UPDATES_TAG_CHIP_UNSELECTED_PLAIN_ATTR]: tag.slug }}
className="updates-chip-face updates-chip-plain"
className={tcls(
CHIP_VARIANT_CLASS,
'flex bg-tint-5 text-tint-strong hover:bg-tint-hover'
)}
>
<TagIcon tag={tag} />
<span className="truncate">{tag.label}</span>
@@ -1,35 +1,55 @@
import type { DocumentBlock } from '@gitbook/api';
/**
* Text style of a block's first line. Elements aligned on it (list prefixes, hint icons) pick
* their size and line height from it, via the matching modifier classes in `styles/blocks.css`.
* Get the line height of a block
*/
export type BlockTextKind = 'body' | 'heading-1' | 'heading-2' | 'heading-3' | 'divider';
export function getBlockTextKind(block: DocumentBlock): BlockTextKind {
export function getBlockTextStyle(block: DocumentBlock): {
/** Tailwind class for the text size */
textSize: string;
/** Tailwind class for the height (h-*) */
lineHeight: string;
/** Tailwind class for the margin top (mt-*) */
marginTop?: string;
} {
switch (block.type) {
case 'paragraph':
return {
textSize: 'text-base',
lineHeight: 'leading-normal',
};
case 'heading-1':
return {
textSize: 'text-xl @xs:text-2xl @lg:text-3xl font-semibold',
lineHeight: 'leading-tight',
marginTop: 'column-first-of-type:pt-0 pt-[1em]',
};
case 'heading-2':
return {
textSize: 'text-lg @xs:text-xl @lg:text-2xl font-semibold',
lineHeight: 'leading-snug',
marginTop: 'column-first-of-type:pt-0 pt-[0.75em]',
};
case 'heading-3':
return {
textSize: 'text-base @xs:text-lg @lg:text-xl font-semibold',
lineHeight: 'leading-snug',
marginTop: 'column-first-of-type:pt-0 pt-[0.5em]',
};
case 'divider':
return block.type;
return {
textSize: '',
lineHeight: 'leading-none',
};
case 'list-ordered':
case 'list-tasks':
case 'list-unordered':
return getBlockTextStyle(block.nodes[0]!);
case 'list-item':
return getBlockTextKind(block.nodes[0]!);
return getBlockTextStyle(block.nodes[0]!);
default:
return 'body';
return {
textSize: 'text-base',
lineHeight: 'leading-normal',
};
}
}
/**
* Line height utility of each text kind.
*/
export const BLOCK_LINE_HEIGHT: Record<BlockTextKind, string> = {
body: 'leading-normal',
'heading-1': 'leading-tight',
'heading-2': 'leading-snug',
'heading-3': 'leading-snug',
divider: 'leading-none',
};
@@ -1,13 +1,13 @@
import React from 'react';
import { CONTENT_STYLE } from '../layout';
import { CONTAINER_STYLE, CONTENT_STYLE } from '../layout';
import { ThemeToggler } from '../ThemeToggler';
import { FooterLinksGroup } from './FooterLinksGroup';
import { SocialAccountButton } from './SocialAccounts';
import { Image } from '@/components/utils';
import { partition } from '@/lib/arrays';
import { cx } from '@/lib/classnames';
import type { GitBookSiteContext } from '@/lib/context';
import { tcls } from '@/lib/tailwind';
const FOOTER_COLUMNS = 4;
@@ -26,14 +26,41 @@ export function Footer(props: { context: GitBookSiteContext }) {
!hasLogo && !hasGroups && !hasCopyright && !socialLinks.length && hasThemeToggle;
return (
<footer data-gb-site-footer className={cx('footer', mobileOnly && 'footer-toggle-only')}>
<div className="chrome-shift-padding">
<div className="footer-container">
<div className={cx(CONTENT_STYLE, 'footer-grid')}>
<footer
data-gb-site-footer
className={tcls(
'border-tint-subtle border-t',
// If the footer only contains a mode toggle, we only show it where the outline
// column — which carries its own toggle — isn't pinned open.
mobileOnly
? 'layout-default:xl:chat-closed:hidden layout-default:3xl:hidden layout-wide:3xl:chat-closed:hidden page-api-block:page-has-outline:min-[96rem]:hidden'
: null
)}
>
<div className="lg:chat-open:pr-(--ai-chat-width) transition-[padding] duration-300 motion-reduce:transition-none">
<div
className={tcls(
CONTAINER_STYLE,
'px-4',
'py-8',
'@4xl:py-12',
'mx-auto',
'@container/footer'
)}
>
<div
className={tcls(
CONTENT_STYLE,
'flex @xs:grid @4xl:max-w-none! flex-col justify-between gap-12',
'grid-cols-[auto_auto]',
'@4xl:grid-cols-[18rem_minmax(auto,48rem)_auto]',
'@7xl:grid-cols-[18rem_minmax(auto,48rem)_14rem]'
)}
>
{
// Footer Logo
customization.footer.logo ? (
<div className="footer-logo">
<div className="col-start-1 row-start-1">
<Image
alt="Logo"
resize={context.imageResizer}
@@ -48,7 +75,17 @@ export function Footer(props: { context: GitBookSiteContext }) {
: null,
}}
loading="lazy"
style="footer-logo-img"
style={[
'w-auto',
'max-w-40',
'@4xl:max-w-64',
'max-h-10',
'@4xl:max-h-12',
'object-contain',
'object-left',
'rounded-sm',
'straight-corners:rounded-xs',
]}
sizes={[
{
width: 320,
@@ -64,7 +101,7 @@ export function Footer(props: { context: GitBookSiteContext }) {
customization.themes.toggeable ? (
// Hidden where the outline column is pinned open (see PageAside),
// since that column carries its own toggle.
<div className="footer-toggle">
<div className="page-api-block:page-has-outline:min-[96rem]:hidden -col-start-2 row-start-1 flex items-start @xs:justify-end layout-default:xl:chat-closed:hidden layout-default:3xl:hidden layout-wide:3xl:chat-closed:hidden">
<React.Suspense fallback={null}>
<ThemeToggler />
</React.Suspense>
@@ -75,11 +112,14 @@ export function Footer(props: { context: GitBookSiteContext }) {
{
// Navigation groups (split into equal columns)
customization.footer.groups?.length > 0 ? (
<div className="footer-groups">
<div className="footer-columns">
<div className={tcls('col-span-2')}>
<div className="mx-auto flex flex-col gap-10 @xl:flex-row @xl:gap-6">
{partition(customization.footer.groups, FOOTER_COLUMNS).map(
(column, columnIndex) => (
<div key={columnIndex} className="footer-column">
<div
key={columnIndex}
className="flex flex-1 grow flex-col gap-10"
>
{column.map((group, groupIndex) => (
<FooterLinksGroup
key={groupIndex}
@@ -98,7 +138,7 @@ export function Footer(props: { context: GitBookSiteContext }) {
{
// Social Links
socialLinks.length > 0 ? (
<div className="footer-social">
<div className="col-span-full flex w-full grow items-center justify-center gap-2">
{socialLinks.map((account) => (
<SocialAccountButton
key={`${account.platform}-${account.handle}`}
@@ -113,7 +153,7 @@ export function Footer(props: { context: GitBookSiteContext }) {
{
// Legal
customization.footer.copyright ? (
<div className="footer-legal">
<div className="order-last col-span-full flex w-full grow flex-col items-center gap-2 text-center text-xs text-tint">
<p>{customization.footer.copyright}</p>
</div>
) : null
@@ -8,6 +8,7 @@ import { Link } from '../primitives';
import type { GitBookAnyContext } from '@/lib/context';
import { resolveContentRef } from '@/lib/references';
import { getLocalizedTitle } from '@/lib/sites';
import { tcls } from '@/lib/tailwind';
export function FooterLinksGroup(props: {
group: CustomizationFooterGroup;
@@ -17,9 +18,9 @@ export function FooterLinksGroup(props: {
const title = getLocalizedTitle(group, context.locale);
return (
<nav className="footer-group">
<h4 className="footer-group-title">{title}</h4>
<ul className="footer-group-links">
<nav className="flex flex-col gap-4 text-sm">
<h4 className="font-heading font-semibold">{title}</h4>
<ul className="flex flex-col items-start gap-4">
{group.links.map((link, index) => {
return (
<li key={index}>
@@ -40,7 +41,21 @@ async function FooterLink(props: { link: CustomizationContentLink; context: GitB
return (
<Link
href={resolved?.href ?? '#'}
className="footer-link"
className={tcls(
'font-normal',
'text-tint',
'links-default:hover:text-primary',
'links-default:tint:hover:text-tint-strong',
'contrast-more:underline',
'contrast-more:text-tint-strong',
'underline-offset-2',
'links-accent:hover:underline',
'links-accent:underline-offset-4',
'links-accent:decoration-primary-subtle',
'links-accent:decoration-[3px]'
)}
insights={{
type: 'link_click',
link: {
@@ -13,10 +13,10 @@ import { HeaderLinks } from './HeaderLinks';
import { HeaderLogo } from './HeaderLogo';
import { HeaderMobileMenu } from './HeaderMobileMenu';
import { TranslationsDropdown } from './SpacesDropdown';
import { CONTAINER_STYLE } from '@/components/layout';
import { CONTAINER_STYLE, HEADER_HEIGHT_DESKTOP } from '@/components/layout';
import { getSpaceLanguage, t } from '@/intl/server';
import { cx } from '@/lib/classnames';
import type { GitBookSiteContext } from '@/lib/context';
import { tcls } from '@/lib/tailwind';
/**
* Render the header for the space.
@@ -35,8 +35,6 @@ export async function Header(props: {
const language = await getSpaceLanguage(context);
const withSections = shouldRenderSiteSectionNavigation(visibleSections);
const prominentSearch =
'search' in customization.styling && customization.styling.search === 'prominent';
const headerSocialAccounts = customization.socialAccounts.filter(
(account) => account.display.header === true
@@ -45,19 +43,70 @@ export async function Header(props: {
return (
<header
data-gb-site-header
className={cx('header-bar', withTopHeader ? null : 'mobile-only')}
className={tcls(
'flex',
'flex-col',
`h-[${HEADER_HEIGHT_DESKTOP}px]`,
'sticky',
'top-0',
'pt-[env(safe-area-inset-top)]',
'z-30',
'w-full',
'flex-none',
'shadow-[0px_1px_0px]',
'shadow-tint-12/2',
// Box shadows are dropped in forced colors mode, the separator needs a real border.
'forced-colors:border-b',
'bg-tint-base/9',
'theme-muted:bg-tint-subtle/9',
'[html.sidebar-filled.theme-bold.tint_&]:bg-tint-subtle/9',
'theme-gradient:bg-gradient-primary',
'theme-gradient-tint:bg-gradient-tint',
'contrast-more:bg-tint-base',
withTopHeader ? null : 'mobile-only lg:hidden',
'text-sm',
'backdrop-blur-lg'
)}
>
<div className="header-inner">
<div className="chrome-shift">
<div data-gb-header-content className={cx(CONTAINER_STYLE, 'header-content')}>
<div
className={tcls(
'site-header:theme-bold:bg-header-background',
'site-header:theme-bold:shadow-[0px_1px_0px]',
'site-header:theme-bold:shadow-tint-12/2'
)}
>
<div className="lg:chat-open:pr-(--ai-chat-width) transition-all duration-300 motion-reduce:transition-none">
<div
data-gb-header-content
className={tcls(
'gap-4',
'lg:gap-6',
'flex',
'items-center',
'justify-between',
'w-full',
'py-3',
'min-h-16',
'sm:h-16',
CONTAINER_STYLE,
'transition-[max-width] duration-300 motion-reduce:transition-none',
'@container/header'
)}
>
<div
className={cx(
'header-start',
prominentSearch && 'header-start-prominent'
className={tcls(
'flex max-w-full',
'min-w-0 shrink items-center justify-start gap-2 lg:gap-4',
'search' in customization.styling &&
customization.styling.search === 'prominent'
? 'lg:@2xl:basis-72'
: null
)}
>
<HeaderMobileMenu
className={cx(
className={tcls(
'-ml-2',
'text-tint-strong',
'site-header:theme-bold:text-header-link',
@@ -72,9 +121,29 @@ export async function Header(props: {
</div>
<div
className={cx(
'header-search',
prominentSearch && 'header-search-prominent'
className={tcls(
'flex',
'grow-0',
'shrink-0',
'md:@2xl:basis-56',
'justify-self-end',
'items-center',
'gap-2',
'transition-[margin] duration-300 motion-reduce:transition-none',
'search' in customization.styling &&
customization.styling.search === 'prominent'
? [
'md:@2xl:grow-[0.8]',
'md:@4xl:basis-40',
'md:@2xl:max-w-[50%]',
'md:@4xl:max-w-lg',
'lg:@2xl:ml-[max(calc((100%-18rem-48rem)/2),1.5rem)]', // container (100%) - sidebar (18rem) - content (48rem)
'chat-closed:xl:ml-[max(calc((100%-18rem-48rem-14rem-3rem)/2),1.5rem)]', // container (100%) - sidebar (18rem) - content (48rem) - outline (14rem) - margin (3rem)
'md:@2xl:mr-auto',
'order-last',
'md:@2xl:order-[unset]',
]
: ['order-last']
)}
>
<SearchContainer
@@ -98,7 +167,7 @@ export async function Header(props: {
);
})}
{headerSocialAccounts.length > 0 ? (
<div className="header-social">
<div className="flex items-center gap-1">
{headerSocialAccounts.map((account) => {
return (
<SocialAccountButton
@@ -139,7 +208,7 @@ export async function Header(props: {
</div>
{visibleSections && withSections ? (
<div className="chrome-shift-padding">
<div className="lg:chat-open:pr-(--ai-chat-width) transition-[padding] duration-300 motion-reduce:transition-none">
<SiteSectionTabs sections={encodeClientSiteSections(context, visibleSections)}>
{variants.translations.length > 1 ? (
<TranslationsDropdown
@@ -8,7 +8,6 @@ import { DropdownMenuItem } from '../primitives/DropdownMenu';
import { SiteAuthLoginDropdownMenuItem } from '../SiteAuth/SiteAuthLoginLink';
import { HeaderLinkDropdown, HeaderLinkNavItem } from './HeaderLinkDropdown';
import { isSiteAuthLoginHref } from '@/lib/auth-login-link';
import { cx } from '@/lib/classnames';
import type { GitBookSiteContext } from '@/lib/context';
import { resolveContentRef } from '@/lib/references';
import { getLocalizedTitle } from '@/lib/sites';
@@ -37,10 +36,7 @@ export async function HeaderLink(props: {
isSiteAuthLoginHref={
target ? isSiteAuthLoginHref(context.linker, target.href) : false
}
dropdownClassName={cx(
'shrink',
customization.styling.search === 'prominent' && 'right-0 left-auto'
)}
dropdownClassName={`shrink ${customization.styling.search === 'prominent' ? 'right-0 left-auto' : null}`}
>
{link.links.map((subLink, index) => (
<SubHeaderLink key={index} {...props} link={subLink} />
@@ -12,7 +12,7 @@ import {
import { Button, Link, ToggleChevron } from '../primitives';
import { type DropdownButtonProps, DropdownMenu } from '../primitives/DropdownMenu';
import { SiteAuthLoginButton, SiteAuthLoginLink } from '../SiteAuth/SiteAuthLoginLink';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
/**
* Client component wrapping the DropdownMenu for header links.
@@ -137,6 +137,31 @@ function HeaderItemButton(
);
}
function getHeaderLinkClassName(_props: { headerPreset: CustomizationHeaderPreset }) {
return tcls(
'flex items-center gap-1',
'shrink',
'contrast-more:underline',
'truncate',
'text-tint',
'links-default:hover:text-primary',
'links-default:aria-expanded:text-primary',
'links-default:tint:hover:text-tint-strong',
'links-default:tint:aria-expanded:text-tint-strong',
'underline-offset-2',
'links-accent:hover:underline',
'links-accent:aria-expanded:underline',
'links-accent:underline-offset-4',
'links-accent:decoration-primary-subtle',
'links-accent:decoration-[3px]',
'links-accent:py-0.5', // Prevent underline from being cut off at the bottom
'theme-bold:text-header-link',
'hover:theme-bold:text-header-link/7!'
);
}
function HeaderItemLink(props: Omit<HeaderLinkNavItemProps, 'linkStyle'>) {
const {
linkTarget,
@@ -150,7 +175,7 @@ function HeaderItemLink(props: Omit<HeaderLinkNavItemProps, 'linkStyle'>) {
} = props;
const sharedProps = {
href: href ?? '#',
className: cx('header-link', className),
className: tcls(getHeaderLinkClassName({ headerPreset }), className),
insights: {
type: 'link_click' as const,
link: {
@@ -182,7 +207,10 @@ function HeaderItemDropdown(
) {
const { headerPreset, title, className, ...rest } = props;
return (
<span className={cx('header-link header-link-static', className)} {...rest}>
<span
className={tcls(getHeaderLinkClassName({ headerPreset }), 'cursor-default', className)}
{...rest}
>
{title}
<ToggleChevron />
</span>
@@ -16,10 +16,10 @@ import {
import { SiteAuthLoginDropdownMenuItem } from '../SiteAuth/SiteAuthLoginLink';
import { HeaderLinkMoreDropdown } from './HeaderLinkMoreClient';
import { isSiteAuthLoginHref } from '@/lib/auth-login-link';
import { cx } from '@/lib/classnames';
import type { GitBookSiteContext } from '@/lib/context';
import { resolveContentRef } from '@/lib/references';
import { getLocalizedTitle } from '@/lib/sites';
import { tcls } from '@/lib/tailwind';
/**
* Dropdown menu for header links hidden at small screen size.
@@ -33,10 +33,10 @@ export function HeaderLinkMore(props: {
const { label, links, context, socialAccounts } = props;
return (
<div className="header-links-ellipsis">
<div className="header-links-ellipsis z-20 items-center">
<HeaderLinkMoreDropdown
label={label}
dropdownClassName={cx(
dropdownClassName={tcls(
'max-md:right-0 max-md:left-auto',
context.customization.styling.search === 'prominent' && 'right-0 left-auto'
)}
@@ -6,7 +6,7 @@ import { Icon } from '@gitbook/icons';
import { ToggleChevron } from '../primitives';
import { DropdownMenu } from '../primitives/DropdownMenu';
import type { ClassValue } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
/**
* Client component for the "More" header link dropdown.
@@ -23,9 +23,21 @@ export function HeaderLinkMoreDropdown(props: {
return (
<DropdownMenu
button={
<button type="button" className="header-more">
<button
type="button"
className={tcls(
'text-tint',
'hover:text-primary',
'dark:hover:text-primary',
'theme-bold:text-header-link',
'theme-bold:hover:text-header-link/8',
'flex',
'gap-1',
'items-center'
)}
>
<span className="sr-only">{label}</span>
<Icon icon="ellipsis" className="size-4" />
<Icon icon="ellipsis" className={tcls('size-4')} />
<ToggleChevron />
</button>
}
@@ -1,6 +1,6 @@
import type React from 'react';
import { type ClassValue, cx } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
interface HeaderLinksProps {
children: React.ReactNode;
@@ -8,5 +8,15 @@ interface HeaderLinksProps {
}
export async function HeaderLinks({ children, style }: HeaderLinksProps) {
return <nav className={cx('header-links', style)}>{children}</nav>;
return (
<nav
className={tcls(
'header-links',
'@4xl:[&>.button+.button]:-ml-2 z-20 ml-auto flex min-w-9 shrink grow @7xl:grow-0 items-center justify-end @4xl:gap-x-6 gap-x-4',
style
)}
>
{children}
</nav>
);
}
@@ -3,6 +3,7 @@ import { CurrentContentIcon } from './CurrentContentIcon';
import { Image } from '@/components/utils';
import type { GitBookSiteContext } from '@/lib/context';
import { resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
interface HeaderLogoProps {
context: GitBookSiteContext;
@@ -21,7 +22,10 @@ export async function HeaderLogo(props: HeaderLogoProps) {
: null;
return (
<Link href={primaryLink?.href ?? linker.toPathInSite('')} className="header-logo">
<Link
href={primaryLink?.href ?? linker.toPathInSite('')}
className={tcls('group/headerlogo', 'min-w-0', 'shrink', 'flex', 'items-center')}
>
{customization.header.logo ? (
<Image
alt="Logo"
@@ -46,7 +50,19 @@ export async function HeaderLogo(props: HeaderLogoProps) {
},
]}
preload
style="header-logo-img"
style={tcls(
'overflow-hidden',
'shrink',
'min-w-0',
'max-w-40',
'lg:max-w-64',
'lg:site-header-none:page-no-toc:max-w-56',
'max-h-8',
'h-full',
'w-full',
'object-contain',
'object-left'
)}
/>
) : (
<LogoFallback {...props} />
@@ -65,10 +81,27 @@ function LogoFallback(props: HeaderLogoProps) {
context={context}
alt=""
sizes={[{ width: 32 }]}
style="header-logo-icon"
style={['object-contain', 'size-8']}
fetchPriority="high"
/>
<div className="header-logo-text">{site.title}</div>
<div
className={tcls(
'text-pretty',
'line-clamp-2',
'tracking-tight',
'max-w-[18ch]',
'lg:max-w-[24ch]',
'font-heading',
'font-semibold',
'ms-3',
'text-base/tight',
'lg:text-lg/tight',
'text-tint-strong',
'theme-bold:text-header-link'
)}
>
{site.title}
</div>
</>
);
}
@@ -4,7 +4,6 @@ import type { IconName } from '@gitbook/icons';
import type { ButtonProps } from '../primitives';
import { getTargetURLForSiteSpace } from '../SiteSections/encodeClientSiteSections';
import { SpacesDropdownClient } from './SpacesDropdownClient';
import { cx } from '@/lib/classnames';
import type { GitBookSiteContext } from '@/lib/context';
import { getLocalizedTitle } from '@/lib/sites';
import { tcls } from '@/lib/tailwind';
@@ -36,7 +35,7 @@ export function SpacesDropdown(
} = props;
const currentLanguage = context.locale;
const dropdownClassName = cx(
const dropdownClassName = 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
);
@@ -85,7 +84,7 @@ export function TranslationsDropdown(
asEmbeddable={asEmbeddable}
variant="blank"
className={tcls(
'translations-dropdown max-md:[&_.button-content]:hidden',
'bg-transparent lg:max-w-64 max-md:[&_.button-content]:hidden',
hasEmojiPrefix
? 'md:[&_.button-leading-icon]:hidden' // If the title starts with an emoji, don't show the icon (on desktop)
: '',
@@ -5,7 +5,7 @@ import type { IconName } from '@gitbook/icons';
import { Button, type ButtonProps, ToggleChevron } from '../primitives';
import { DropdownMenu } from '../primitives/DropdownMenu';
import { SpacesDropdownMenuItems } from './SpacesDropdownMenuItem';
import { type ClassValue, cx } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
/**
* Client component that creates the Button trigger and DropdownMenu internally, avoiding
@@ -38,7 +38,7 @@ export function SpacesDropdownClient(props: {
size="small"
variant={variant}
trailing={<ToggleChevron />}
className={cx('spaces-dropdown-button', className)}
className={tcls('bg-tint-base', className)}
>
<span className="button-content">{title}</span>
</Button>
@@ -18,9 +18,9 @@ import { PageAsideCloseButton } from './PageAsideButton';
import { ScrollSectionsList } from './ScrollSectionsList';
import { ScrollToTopButton } from './ScrollToTopButton';
import { getSpaceLanguage, t, tString } from '@/intl/server';
import { cx } from '@/lib/classnames';
import type { GitBookSiteContext } from '@/lib/context';
import { getDocumentSections } from '@/lib/document-sections';
import { tcls } from '@/lib/tailwind';
/**
* Aside listing the headings in the document.
@@ -44,13 +44,77 @@ export async function PageAside(props: {
toggleClass="outline-open"
withOverlay
withCloseButton
className={cx(
'page-aside',
// Kept as utilities so they win over SideSheet's own `fixed inset-y-0 z-41`.
'xl:sticky lg:top-0 lg:site-header:top-16 lg:site-header-sections:top-27 lg:z-10 lg:hover:z-12'
className={tcls(
'group/aside',
'order-last',
'xl:sticky',
'w-64',
// Without header
'lg:top-0',
'lg:max-h-screen',
// With header
'lg:site-header:top-16',
'lg:site-header:max-h-[calc(100vh-4rem)]',
// With header & sections
'lg:site-header-sections:top-27',
'lg:site-header-sections:max-h-[calc(100vh-6.75rem)]',
// Client-side dynamic positioning (CSS vars applied by script)
'lg:[html[style*="--outline-top-offset"]_&]:top-(--outline-top-offset)!',
'lg:[html[style*="--outline-height"]_&]:max-h-(--outline-height)!',
'layout-default:max-xl:border-l',
'layout-wide:max-3xl:border-l',
'border-tint-subtle',
'p-4',
'pt-8',
'ml-4',
'break-anywhere', // To prevent long words in headings from breaking the layout
'lg:z-10',
'lg:hover:z-12',
'layout-default:xl:chat-closed:pr-0',
'layout-default:xl:chat-closed:pl-8',
'layout-default:xl:chat-closed:flex!',
'layout-default:xl:chat-closed:animate-none!',
'layout-default:3xl:flex!',
'layout-default:3xl:animate-none!',
// In layout-wide mode, hide outline when viewport is too narrow
// or when chat is open and viewport is narrow, to prevent layout overflow
'layout-wide:xl:-mr-68',
'layout-wide:3xl:chat-closed:flex!',
'layout-wide:3xl:chat-closed:animate-none!',
// Show outline if page has OpenAPI block
// TODO: remove this in favour of a nicer, more immediately accessible solution in the future.
'page-api-block:page-has-outline:min-[96rem]:max-3xl:-mr-[max(calc((100vw-90rem)/2),0rem)]',
'page-api-block:page-has-outline:min-[96rem]:flex!',
'page-api-block:page-has-outline:min-[96rem]:animate-none!',
'page-api-block:page-has-outline:min-[96rem]:border-l-0',
'page-api-block:page-has-outline:min-[96rem]:pl-8',
// Only add a background once the element is positioned correctly, to prevent
// overlapping the page cover. Kept opaque wherever the outline is a toggleable
// overlay (below xl in any layout, and xl–3xl in wide layout, where it opens as
// a desktop SideSheet), but dropped for the permanent outline column so a bleeding
// cards carousel can scroll behind it.
'max-xl:hydrated:site-background',
'layout-wide:max-3xl:hydrated:site-background',
'text-tint',
'contrast-more:text-tint-strong'
// The cover-aware text color lives on the individual rows below, not here: the
// outline column is tall enough to always cross the cover's bottom edge, and a
// container can't carry a single correct color for text on both sides of it.
)}
>
<div className="page-aside-inner">
<div className="flex h-full w-full shrink-0 flex-col overflow-hidden">
{page.layout.outline ? (
<>
{filterableTags.length > 0 ? (
@@ -61,18 +125,21 @@ export async function PageAside(props: {
/>
) : null}
<div
className={cx(
'page-aside-header',
filterableTags.length > 0 && 'page-aside-header-tags'
className={tcls(
'mb-3 ml-3 flex page-no-outline:hidden items-center justify-between max-lg:hidden',
filterableTags.length > 0 && 'mt-4'
)}
>
<ScrollToTopButton data-cover-aware-text className="page-aside-title">
<ScrollToTopButton
data-cover-aware-text
className="leading-wider xl:page-cover-background:text-contrast-cover flex cursor-pointer items-center gap-1 text-xs font-semibold uppercase text-tint"
>
<Icon icon="block-quote" className="size-3" />{' '}
{t(language, 'on_this_page')}
</ScrollToTopButton>
<PageAsideCloseButton className="page-api-block:min-[96rem]:hidden layout-default:xl:hidden layout-wide:3xl:hidden" />
</div>
<div className="page-aside-scroll">
<div className="flex shrink flex-col overflow-hidden">
{document ? (
<React.Suspense fallback={null}>
<PageAsideSections document={document} context={context} />
@@ -96,7 +163,7 @@ async function PageAsideSections(props: { document: JSONDocument; context: GitBo
const sections = await getDocumentSections(context, document);
return sections.length > 1 ? (
<div data-gb-page-outline className="page-aside-outline">
<div data-gb-page-outline className="overflow-y-auto">
<ScrollSectionsList sections={sections} />
</div>
) : null;
@@ -106,7 +173,14 @@ function PageAsideActions(props: { withPageFeedback: boolean; page: RevisionPage
const { page, withPageFeedback } = props;
return (
<div className="page-aside-actions">
<div
className={tcls(
'flex flex-col gap-3',
'border-tint-subtle border-t first:border-none',
'sidebar-list-default:px-3 pt-5 first:pt-0',
'empty:hidden'
)}
>
{withPageFeedback ? (
<React.Suspense fallback={null}>
<PageFeedbackForm pageId={page.id} />
@@ -121,10 +195,16 @@ async function PageAsideFooter(props: { context: GitBookSiteContext }) {
const { customization, site, space } = context;
return (
<div className="page-aside-footer">
<div
className={tcls(
'sticky bottom-0 z-10 mt-auto flex flex-col',
'border-tint-subtle',
'pt-4'
)}
>
{/* Mode Switcher */}
{customization.themes.toggeable ? (
<div className="page-aside-theme">
<div className="flex items-center justify-end">
<React.Suspense fallback={null}>
<ThemeToggler />
</React.Suspense>
@@ -8,6 +8,7 @@ import { useUpdatesFilter } from '@/components/DocumentView/UpdatesFilter';
import { useScrollActiveId } from '@/components/hooks';
import { useBodyLoaded } from '@/components/primitives';
import type { DocumentSection } from '@/lib/document-sections';
import { tcls } from '@/lib/tailwind';
import { UPDATES_TAG_SECTION_ATTR } from '@/lib/updates';
/**
@@ -57,11 +58,27 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
}, [activeId]);
return (
<ul className="page-outline" ref={scrollContainerRef}>
<ul
className="relative flex flex-col border-tint-subtle pb-5 sidebar-list-line:border-l"
ref={scrollContainerRef}
>
{sections.map((section) => (
<li
key={section.id}
className="page-outline-item"
className={tcls(
'flex',
'flex-row',
'relative',
'h-fit',
'mt-2',
'first:mt-0',
'mb-0.5',
section.depth > 1 && [
section.depth > 2 ? 'ml-6' : 'ml-3',
'my-0',
'sidebar-list-line:ml-0',
]
)}
ref={activeId === section.id ? activeItemRef : null}
{...(section.tags !== undefined
? { [UPDATES_TAG_SECTION_ATTR]: section.tags.join(' ') }
@@ -71,9 +88,73 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
href={`#${section.id}`}
aria-current={activeId === section.id ? 'true' : undefined}
data-cover-aware-text
className={
section.depth > 1 ? 'page-outline-link subitem' : 'page-outline-link'
}
className={tcls(
'relative',
'z-10',
'text-sm',
'w-full',
'py-1',
'px-3',
'transition-all',
'motion-reduce:transition-none',
'duration-200',
'rounded-md',
'straight-corners:rounded-none',
'circular-corners:rounded-2xl',
'sidebar-list-line:rounded-l-none!',
'hover:bg-tint-hover',
'theme-gradient:hover:bg-tint-12/1',
'hover:text-tint-strong',
'contrast-more:hover:ring-1',
'contrast-more:hover:ring-inset',
'contrast-more:hover:ring-current',
'sidebar-list-line:border-l-2',
'border-transparent',
'sidebar-list-line:-left-px',
'xl:page-cover-background:text-contrast-cover',
// The method badge no longer has a right margin, so lay the row out with a gap
section.tag && ['flex', 'items-baseline', 'gap-2'],
section.depth > 1 && [
'subitem',
section.depth > 2
? 'sidebar-list-line:pl-9'
: 'sidebar-list-line:pl-6',
'opacity-8',
'contrast-more:opacity-11',
'sidebar-list-default:rounded-l-none!',
'sidebar-list-default:border-l',
'sidebar-list-default:border-tint',
],
activeId === section.id && [
'text-primary-subtle',
'hover:text-primary',
'contrast-more:text-primary',
'contrast-more:hover:text-primary-strong',
'hover:bg-primary-hover',
'theme-muted:hover:bg-primary-active',
'[html.sidebar-filled.theme-bold.tint_&]:hover:bg-primary-active',
'theme-gradient:hover:bg-primary-active',
'tint:font-semibold',
'contrast-more:font-semibold',
'sidebar-list-line:border-primary-9',
'sidebar-list-default:border-tint',
'sidebar-list-pill:bg-primary',
'[html.theme-muted.sidebar-list-pill_&]:bg-primary-hover',
'[html.theme-gradient.sidebar-list-pill_&]:bg-primary-active',
]
)}
>
{section.tag ? (
<OpenAPIMethodBadge
@@ -85,7 +166,13 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
) : null}
<span
className={section.deprecated ? 'page-outline-deprecated' : undefined}
className={tcls(
section.deprecated && [
'line-through',
'opacity-50',
'contrast-more:opacity-60',
]
)}
>
{section.title}
</span>
@@ -3,7 +3,7 @@
import { PageIcon } from '../PageIcon';
import { StyledLink } from '../primitives';
import { DropdownMenu, DropdownMenuItem } from '../primitives/DropdownMenu';
import { type ClassValue, cx } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
export type BreadcrumbSibling = {
id: string;
@@ -46,7 +46,10 @@ export function BreadcrumbItemDropdown(props: {
const content = (
<>
{emoji || icon ? (
<PageIcon page={{ emoji, icon }} style="page-breadcrumbs-icon" />
<PageIcon
page={{ emoji, icon }}
style="mb-0.5 mr-1 inline-block size-[1em] shrink-0"
/>
) : null}
{label}
</>
@@ -57,11 +60,13 @@ export function BreadcrumbItemDropdown(props: {
// normalize "" to "/" the way the table of contents does.
const trigger =
href !== undefined ? (
<StyledLink href={href || '/'} role="link" className={cx(linkClassName)}>
<StyledLink href={href || '/'} role="link" className={tcls(linkClassName)}>
{content}
</StyledLink>
) : (
<span className={cx(linkClassName, 'page-breadcrumbs-label')}>{content}</span>
<span className={tcls(linkClassName, 'cursor-default hover:no-underline')}>
{content}
</span>
);
// No dropdown when there is nowhere else to go at this level.
@@ -87,7 +92,7 @@ export function BreadcrumbItemDropdown(props: {
sibling.emoji || sibling.icon ? (
<PageIcon
page={{ emoji: sibling.emoji, icon: sibling.icon }}
style="page-breadcrumbs-menu-icon"
style="size-3 shrink-0 text-tint-subtle"
/>
) : undefined
}
@@ -7,6 +7,7 @@ import {
import { DocumentView, DocumentViewSkeleton } from '../DocumentView';
import { CurrentPageProvider } from '../hooks/useCurrentPage';
import { TrackPageViewEvent } from '../Insights';
import { CONTENT_STYLE } from '../layout';
import { PageFeedbackForm } from '../PageFeedback';
import { DateRelative, SuspenseLoadedHint } from '../primitives';
import OptionalSuspense from './OptionalSuspense';
@@ -18,7 +19,6 @@ import { PreservePageLayout } from './PreservePageLayout';
import { MAIN_CONTENT_ID } from '@/components/layout';
import { getSpaceLanguage } from '@/intl/server';
import { t } from '@/intl/translate';
import { cx } from '@/lib/classnames';
import type { GitBookSiteContext } from '@/lib/context';
import {
hasAPIBlock,
@@ -29,6 +29,7 @@ import {
} from '@/lib/document';
import { getLLMsTxtURL, getPageMarkdownURL } from '@/lib/llms-directive';
import type { AncestorRevisionPage } from '@/lib/pages';
import { tcls } from '@/lib/tailwind';
import { getPageRSSURL } from '@/routes/rss';
const LINK_PREVIEW_MAX_COUNT = 500;
@@ -106,8 +107,16 @@ export async function PageBody(props: {
id={MAIN_CONTENT_ID}
// Comments on the whole page target anywhere in it that isn't a block.
{...(withCommentAnchors ? { 'data-comment-page': '' } : {})}
className={cx(
'page-main',
className={tcls(
'relative min-w-0 flex-1',
'break-anywhere', // Allow words to break if they are too long.
'py-8',
'layout-wide:no-sidebar:lg:max-xl:pb-20', // Add padding to prevent overlap of minimised trademark
'@container',
// Flex column so the growing content wrapper below fills the page: the footer
// navigation settles at the bottom, and a full-page cover shows behind the content.
'flex flex-col',
CONTENT_STYLE,
pageHasToc ? 'page-has-toc' : 'page-no-toc',
wideLayout ? 'layout-wide' : 'layout-default'
)}
@@ -164,9 +173,14 @@ export async function PageBody(props: {
) : null}
{page.layout.metadata ? (
<div className="page-meta">
<div
className={tcls(
CONTENT_STYLE,
'mt-6 flex flex-row flex-wrap items-center gap-4 text-tint contrast-more:text-tint-strong'
)}
>
{updatedAt ? (
<p className="page-meta-date">
<p className="mr-auto text-sm">
{t(
language,
'page_last_modified',
@@ -4,10 +4,12 @@ import {
SiteInsightsLinkPosition,
} from '@gitbook/api';
import { CONTENT_STYLE } from '../layout';
import { PageIcon } from '../PageIcon';
import { Card } from '@/components/primitives';
import type { GitBookAnyContext } from '@/lib/context';
import { resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
/**
* Blankslate when the page has no document or the document is empty.
@@ -27,7 +29,7 @@ export async function PageBodyBlankslate(props: {
const pageElements = await Promise.all(
pages.map(async (child) => {
const icon = <PageIcon page={child} style="page-blankslate-icon" />;
const icon = <PageIcon page={child} style={['text-base', 'text-tint']} />;
if (child.type === RevisionPageType.Computed) {
throw new Error(
@@ -71,5 +73,18 @@ export async function PageBodyBlankslate(props: {
})
);
return <div className="page-blankslate">{pageElements}</div>;
return (
<div
className={tcls(
CONTENT_STYLE,
'grid',
'gap-4',
'grid-cols-1',
'sm:grid-cols-2',
'md:layout-wide:grid-cols-3'
)}
>
{pageElements}
</div>
);
}
@@ -7,12 +7,14 @@ import {
type RevisionPageDocumentCover,
} from '@gitbook/api';
import { CONTENT_STYLE } from '../layout';
import { getCoverHeight } from './coverHeight';
import defaultPageCoverSVG from './default-page-cover.svg';
import { PageCoverImage } from './PageCoverImage';
import { getImageAttributes } from '@/components/utils';
import type { GitBookSiteContext } from '@/lib/context';
import { type ResolvedContentRef, resolveContentRef } from '@/lib/references';
import { tcls } from '@/lib/tailwind';
const defaultPageCover = defaultPageCoverSVG as StaticImageData;
@@ -89,7 +91,54 @@ export async function PageCover(props: {
data-cover-text-color-dark={cover.textColorDark}
data-cover-type={as}
data-full={String(as === 'full')}
className="page-cover"
className={tcls(
'overflow-hidden',
// Negative margin to balance the container padding
'-mx-4',
// Full-width cover: extend to edges, disregard TOC where possible
as === 'full' || as === 'background'
? [
'sm:-mx-6',
'md:-mx-8',
'lg:-ml-12',
// Extend the full-width cover
'layout-default:page-no-toc:lg:-ml-92', // Extend into the left sidebar if there's no TOC...
'layout-wide:2xl:-mr-[clamp(2rem,calc((100vw-90rem)/2+2rem),18rem)]', // ...and to the right if there's no outline.
'layout-wide:page-no-toc:2xl:-mx-[max(calc((100vw-90rem)/2+2rem),2rem)]', // Span full width if the page content is centered.
'layout-wide:has-sidebar:page-no-toc:lg:-ml-[max(calc((100vw-90rem)/2+23rem),23rem)]', // If there's still a sidebar, we have to factor it in too.
// Corner rounding: we round once the page is wide enough to have space around the cover.
'layout-default:2xl:rounded-corners:rounded-b-xl',
'layout-default:2xl:circular-corners:rounded-b-3xl',
'layout-wide:3xl:circular-corners:rounded-b-3xl',
'layout-wide:3xl:rounded-corners:rounded-b-xl',
// Round the bottom left corner once the sidebar is shown next to it
'has-sidebar:lg:rounded-corners:rounded-bl-xl',
'has-sidebar:lg:circular-corners:rounded-bl-3xl',
]
: null,
as === 'hero'
? [
// Regular cover: size regularly along with other content
CONTENT_STYLE,
'max-sm:-mx-4',
'sm:rounded-corners:rounded-xl',
'sm:circular-corners:rounded-3xl',
'mb-8',
'max-sm:w-screen',
'max-sm:-mt-8',
]
: null,
as === 'background'
? [
'-z-1 absolute inset-x-0 contrast-more:opacity-5 *:contrast-more:blur-md',
]
: null
)}
>
<PageCoverImage
imgs={{
@@ -1,7 +1,7 @@
'use client';
import type { ImageSize } from '../utils';
import { useCoverPosition } from './useCoverPosition';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
interface ImageAttributes {
src: string;
@@ -40,21 +40,21 @@ export function PageCoverImage(props: PageCoverImageProps) {
if (isLoading) {
return (
<div className="page-cover-loading">
<div className="page-cover-skeleton" />
<div className="h-full w-full overflow-hidden">
<div className="h-full w-full animate-pulse bg-gradient-to-br from-gray-100 to-gray-200 dark:from-gray-800 dark:to-gray-900" />
</div>
);
}
return (
<div className="page-cover-frame" style={{ height }}>
<div className="h-full w-full overflow-hidden @container" style={{ height }}>
<img
src={imgs.light.src}
srcSet={imgs.light.srcSet}
sizes={imgs.light.sizes}
fetchPriority={darkFirst ? 'auto' : 'high'}
alt="Page cover"
className={cx('page-cover-img', imgs.dark && 'page-cover-img-light')}
className={tcls('w-full', 'object-cover', imgs.dark ? 'dark:hidden' : '')}
style={{
aspectRatio: height
? undefined
@@ -75,7 +75,7 @@ export function PageCoverImage(props: PageCoverImageProps) {
sizes={imgs.dark.sizes}
fetchPriority={darkFirst ? 'high' : 'low'}
alt="Page cover"
className="page-cover-img page-cover-img-dark"
className={tcls('w-full', 'object-cover', 'dark:inline', 'hidden')}
style={{
aspectRatio: height
? undefined
@@ -3,11 +3,12 @@ import type React from 'react';
import { type RevisionPageDocument, SiteInsightsLinkPosition } from '@gitbook/api';
import { Icon, type IconName } from '@gitbook/icons';
import { CONTENT_STYLE } from '../layout';
import { Link, type LinkInsightsProps } from '../primitives';
import { getSpaceLanguage, t } from '@/intl/server';
import { cx } from '@/lib/classnames';
import type { GitBookSiteContext } from '@/lib/context';
import { resolvePrevNextPages } from '@/lib/pages';
import { tcls } from '@/lib/tailwind';
/**
* Show cards to go to previous/next pages at the bottom.
@@ -26,7 +27,7 @@ export async function PageFooterNavigation(props: {
const nextHref = next ? linker.toPathForPage({ pages: revision.pages, page: next }) : '';
return (
<div className="page-nav">
<div className={tcls(CONTENT_STYLE, 'mt-6 flex @xl:flex-row flex-col gap-3 text-tint')}>
{previous ? (
<NavigationCard
icon="chevron-left"
@@ -83,12 +84,24 @@ function NavigationCard(
<Link
href={href}
insights={insights}
className={cx('page-nav-card', reversed && 'page-nav-next')}
className={tcls(
'group flex flex-1 items-center @xl:gap-3 gap-2 text-pretty circular-corners:rounded-2xl rounded-corners:rounded-xl border border-tint-subtle @xl:p-4 p-3 @xl:text-base text-sm text-tint outline-tint-12 transition-colors hover:border-primary-hover contrast-more:border-tint-12 contrast-more:text-tint-strong contrast-more:hover:border-primary-12 contrast-more:hover:outline-2',
reversed ? 'flex-row-reverse text-end' : 'text-start'
)}
>
<Icon icon={icon} className="size-3" />
<div className="page-nav-body">
<span className="page-nav-label">{label}</span>
<span className="page-nav-title">{title}</span>
<div className="flex flex-col">
<span
className={tcls(
'flex items-center gap-1 text-xs',
reversed ? 'flex-row-reverse' : 'flex-row'
)}
>
{label}
</span>
<span className="line-clamp-2 leading-snug text-tint-strong transition-colors group-hover:text-primary contrast-more:group-hover:text-primary-strong">
{title}
</span>
</div>
</Link>
);
@@ -11,6 +11,7 @@ import {
import { Icon } from '@gitbook/icons';
import { SpacesDropdownMenuItems, type VariantSpace } from '../Header/SpacesDropdownMenuItem';
import { CONTENT_STYLE, CONTENT_STYLE_REDUCED } from '../layout';
import {
PageActionsDropdown,
type PageActionsDropdownURLs,
@@ -25,11 +26,11 @@ import {
import { categorizeVariants } from '../SpaceLayout/categorizeVariants';
import { BreadcrumbItemDropdown, type BreadcrumbSibling } from './BreadcrumbItemDropdown';
import { PageTags } from './PageTags';
import { cx } from '@/lib/classnames';
import type { GitBookSiteContext, SiteStructureNode } from '@/lib/context';
import { hasAdaptiveMcpEndpoint } from '@/lib/mcp/endpoints';
import { type AncestorRevisionPage, resolveFirstDocument } from '@/lib/pages';
import { getLocalizedTitle } from '@/lib/sites';
import { tcls } from '@/lib/tailwind';
import { getPageRSSURL } from '@/routes/rss';
export async function PageHeader(props: {
@@ -161,9 +162,9 @@ export async function PageHeader(props: {
const pageActions = (
<div
className={cx(
'page-header-actions',
!showBreadcrumbs && 'page-header-actions-solo',
className={tcls(
'float-right ml-4 flex gap-2',
showBreadcrumbs ? '-mb-1 -mt-1.5' : '-mt-3 xs:mt-2',
// On desktop API pages these actions are pulled out of <header> (rendered as its
// preceding sibling, see below) so their sticky containing block is the tall,
// growing content wrapper in <main> — a plain block — rather than the short header.
@@ -172,7 +173,12 @@ export async function PageHeader(props: {
// offset tracks the header height (banner, cover…) via the same --toc-top-offset the
// outline and code samples use. Hidden while the outline drawer is open (drawer
// widths only) so it doesn't overlap the sheet.
hasAPIBlocks && 'page-header-actions-api'
hasAPIBlocks && [
'page-api-block:lg:sticky',
'page-api-block:lg:top-[calc(var(--toc-top-offset,4rem)+1rem)]',
'page-api-block:lg:z-20',
'lg:max-[96rem]:[body.outline-open:has(.openapi-block)_&]:hidden',
]
)}
>
{hasPageActions ? (
@@ -203,11 +209,11 @@ export async function PageHeader(props: {
// overlaps it: mark it here so it is never briefly unstyled before hydration.
data-cover-aware-text
data-over-cover
className="page-breadcrumbs"
className="page-cover-background:text-contrast-cover flow-root text-xs leading-relaxed text-tint layout-wide:page-no-toc:hidden page-cover-background:opacity-9"
>
<ol>
<ol className="inline">
{contextCrumbs.map((crumb, index) => (
<li key={crumb.key}>
<li key={crumb.key} className="inline">
<ContextCrumb crumb={crumb} />
{(index !== contextCrumbs.length - 1 || hasAncestors) && (
<BreadcrumbSeparator />
@@ -226,7 +232,7 @@ export async function PageHeader(props: {
page: target,
});
return (
<li key={breadcrumb.id}>
<li key={breadcrumb.id} className="inline">
<BreadcrumbItemDropdown
href={href}
label={breadcrumb.title}
@@ -253,21 +259,46 @@ export async function PageHeader(props: {
{...(context.changeRequest ? { 'data-comment-page-title': '' } : {})}
data-cover-aware-text
data-over-cover
className="page-title"
className={tcls(
'text-2xl',
'@xs:text-3xl',
'@lg:text-4xl',
'leading-tight',
'font-heading',
'font-bold',
'flex',
'items-center',
'gap-[.5em]',
'grow',
'text-pretty',
'clear-right',
'xs:clear-none',
'page-cover-background:text-contrast-cover'
)}
>
<PageIcon page={page} style="page-title-icon" />
<PageIcon page={page} style={['text-tint-subtle', 'shrink-0']} />
{page.title}
</h1>
) : null}
{page.description && page.layout.description ? (
<p data-cover-aware-text data-over-cover className="page-description">
<p
data-cover-aware-text
data-over-cover
className={tcls(
CONTENT_STYLE_REDUCED,
'text-lg',
'page-cover-background:text-contrast-cover',
'text-tint contrast-more:text-tint-strong',
'clear-both'
)}
>
{page.description}
</p>
) : null}
</>
);
const headerClassName = 'page-header';
const headerClassName = tcls(CONTENT_STYLE, 'mb-6 space-y-3 after:clear-both after:block');
// On API pages the actions are pulled out of <header> so their sticky containing block is the
// full-height <main> rather than the short header (a sticky element can't outlive its containing
@@ -290,7 +321,16 @@ export async function PageHeader(props: {
* Shared styling for the individual breadcrumb links. Uses normal casing/weight to match the way
* breadcrumbs are rendered in search results.
*/
const BREADCRUMB_LINK_CLASSES = 'page-breadcrumbs-link';
const BREADCRUMB_LINK_CLASSES = [
'inline',
'no-underline',
'hover:underline',
'text-xs',
'font-normal',
'items-center',
'contrast-more:underline',
'contrast-more:decoration-current',
];
/** A section-group, section or variant crumb shown at the start of the breadcrumbs. */
type BreadcrumbContextCrumb = {
@@ -472,7 +512,13 @@ function getPageSiblings(
* Separator rendered between two breadcrumb items.
*/
function BreadcrumbSeparator() {
return <Icon aria-hidden icon="chevron-right" className="page-breadcrumbs-sep" />;
return (
<Icon
aria-hidden
icon="chevron-right"
className="mx-2 inline-flex size-2 text-tint-subtle"
/>
);
}
/**
@@ -9,7 +9,7 @@ import { useTrackEvent } from '../Insights';
import { Button, ButtonGroup, Input } from '../primitives';
import { useLanguage } from '@/intl/client';
import { t, tString } from '@/intl/translate';
import { cx } from '@/lib/classnames';
import { tcls } from '@/lib/tailwind';
const MIN_COMMENT_LENGTH = 3;
const MAX_COMMENT_LENGTH = 512;
@@ -56,8 +56,8 @@ export function PageFeedbackForm(props: { pageId: string; className?: string })
}, [rating]);
return (
<div className={cx('page-feedback', className)}>
<div className="page-feedback-row">
<div className={tcls('flex flex-col gap-3 text-sm', className)}>
<div className="flex flex-wrap items-center gap-2">
<p>{t(languages, 'was_this_helpful')}</p>
<ButtonGroup className="rounded-full border border-tint bg-tint-base">
<RatingButton
@@ -85,7 +85,7 @@ export function PageFeedbackForm(props: { pageId: string; className?: string })
</div>
{rating ? (
submitted ? (
<div className="page-feedback-thanks">
<div className="animate-blur-in-display-slow flex items-center gap-1 p-1.5 text-success-subtle">
<Icon icon="check-circle" className="size-4" />
{tString(languages, 'was_this_helpful_thank_you')}
</div>
@@ -2,7 +2,7 @@ import type { RevisionPage } from '@gitbook/api';
import { Icon, type IconName } from '@gitbook/icons';
import { Emoji } from '@/components/primitives';
import { type ClassValue, cx } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
export function PageIcon(props: {
page: Pick<RevisionPage, 'emoji' | 'icon'>;
@@ -25,7 +25,7 @@ export function PageIcon(props: {
}
if (page.icon) {
return <Icon icon={page.icon as IconName} className={cx('page-icon', style)} />;
return <Icon icon={page.icon as IconName} className={tcls('size-[1em]', style)} />;
}
return null;
@@ -1,30 +1,9 @@
/* Tailwind is split so the component stylesheets land in the utilities layer ahead of the
generated utilities: specificity then decides, as it did when they were utility classes. */
@layer theme, base, components, utilities;
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/preflight.css" layer(base);
@import "tailwindcss";
@config '../../../tailwind.config.ts';
/* For the component stylesheets: as utilities, `contrast-more:` sorted after a caller's plain utility
and won. Ahead of the utilities it needs one more point of specificity to keep winning. */
@custom-variant contrast-more-strong {
@media (prefers-contrast: more) {
&:is(html *) {
@slot;
}
}
}
@import "./prose.css";
@import "../DocumentView/OpenAPI/method-badge.css";
@import "./styles/primitives.css";
@import "./styles/chrome.css";
@import "./styles/page.css";
@import "./styles/toc.css";
@import "./styles/blocks.css";
@import "./styles/rich-blocks.css";
@import "tailwindcss/utilities.css" layer(utilities);
/*
The default border color has changed to `currentcolor` in Tailwind CSS v4,
@@ -1,292 +0,0 @@
@layer utilities {
/* Every block carries this; full-width blocks add `page-content-width`, whose `layout-wide` max-width is more specific. */
.gb-block {
@apply max-w-3xl w-full decoration-primary/6;
}
/* Lists opt out: a long list is expected to break across printed pages. */
.gb-block:not(.gb-block-list) {
@apply print:break-inside-avoid;
}
/* Headings */
.heading {
@apply relative block scroll-mt-(--content-scroll-margin) pointer-fine:flex pointer-fine:items-baseline pointer-fine:pr-0 column-first-of-type:pt-0;
/* Room for the absolutely positioned anchor icon on coarse pointers. */
&:where(:has(> .hash)) {
@apply pr-6 pointer-fine:pr-0;
}
}
.heading-1 {
@apply text-xl @xs:text-2xl @lg:text-3xl font-semibold pt-[1em];
}
.heading-2 {
@apply text-lg @xs:text-xl @lg:text-2xl font-semibold pt-[0.75em];
}
.heading-3 {
@apply text-base @xs:text-lg @lg:text-xl font-semibold pt-[0.5em];
}
.heading-text {
@apply z-1 justify-self-start max-w-full break-words pointer-fine:flex-1;
&[data-cover-aware-text] {
@apply page-cover-background:text-contrast-cover;
}
}
.heading-1 > .heading-text {
@apply leading-tight;
}
.heading-2 > .heading-text,
.heading-3 > .heading-text {
@apply leading-snug;
}
/* Heading anchor link */
.hash {
@apply absolute inline-grid grid-area-1-1 border-0 rounded site-background;
@apply pointer-events-none opacity-0 transition-opacity;
@apply [transform:translateY(0.17em)];
}
/* Before the `pointer-fine` reset below, which must win at equal specificity. */
:where(.heading-1) > .hash {
@apply [transform:translateY(0.125em)];
}
.hash {
@apply pointer-fine:h-[1em] pointer-fine:pointer-events-auto pointer-fine:relative pointer-fine:-ml-6 pointer-fine:order-first pointer-fine:self-center pointer-fine:pr-2 pointer-fine:[transform:none];
@apply pointer-fine:[.flip-heading-hash_&]:order-last pointer-fine:[.flip-heading-hash_&]:ml-1 pointer-fine:[.flip-heading-hash_&]:pl-2;
/* Same selectors and specificity as the former `group-hover/hash` and `group-focus-within/hash`. */
@media (pointer: fine) {
&:is(:where(.heading):hover *) {
@media (hover: hover) {
@apply opacity-100;
}
}
&:is(:where(.heading):focus-within *) {
@apply opacity-100;
}
}
@apply [.hash-revealed_&]:pointer-events-auto [.hash-revealed_&]:opacity-100;
}
.hash-link {
@apply inline-flex items-center p-1 leading-normal pointer-fine:h-full pointer-fine:p-0;
}
.heading-1 .hash-link {
@apply leading-tight;
}
.heading-2 .hash-link,
.heading-3 .hash-link {
@apply leading-snug;
}
.hash-icon {
@apply size-4 self-center text-transparent transition-colors;
@media (pointer: fine) {
&:is(:where(.heading):hover *) {
@media (hover: hover) {
@apply text-tint-subtle contrast-more-strong:text-tint-strong;
}
}
&:is(:where(.heading):focus-within *) {
@apply text-tint-subtle contrast-more-strong:text-tint-strong;
}
}
@apply [.hash-revealed_&]:text-tint-subtle contrast-more-strong:[.hash-revealed_&]:text-tint-strong;
}
/* Hints */
.hint {
@apply transition-colors rounded-corners:rounded-md circular-corners:rounded-xl overflow-hidden text-sm grid grid-cols-[auto_1fr];
}
.hint-titled {
@apply rounded-corners:rounded-l-none circular-corners:rounded-l-none border-l-2 grid-rows-[auto_auto];
}
.hint-aside {
@apply py-4 pl-4;
}
.hint-icon {
@apply size-[1.2em] mt-px;
}
/* After `.heading` so its paddings and alignment win. */
.hint-heading {
@apply w-full items-start pointer-fine:items-baseline py-4! pl-3 text-[1em]! pr-8 pointer-fine:pr-0;
/* Zero specificity so the heading text keeps its `pointer-fine:flex-1`. */
:where(&) > * {
@apply flex-none;
}
}
/* `min-w-0` lets the `1fr` track shrink, so wide nested blocks scroll instead of overflowing. */
.hint-content {
@apply p-4 pl-3 empty:p-0 -row-end-1 -col-end-1 min-w-0 space-y-3;
}
/* Lists */
.gb-list {
@apply min-w-0 space-y-2;
}
.gb-list-item {
@apply leading-normal flex items-start;
}
.gb-list-item-heading-1 {
@apply leading-tight;
}
.gb-list-item-heading-2,
.gb-list-item-heading-3 {
@apply leading-snug;
}
.gb-list-item-divider {
@apply leading-none;
}
.gb-list-prefix {
@apply text-base leading-normal mr-1 flex min-h-lh min-w-6 items-center justify-center text-tint;
}
.gb-list-item-heading-1 > .gb-list-prefix {
@apply text-xl @xs:text-2xl @lg:text-3xl font-semibold leading-tight;
}
.gb-list-item-heading-2 > .gb-list-prefix {
@apply text-lg @xs:text-xl @lg:text-2xl font-semibold leading-snug;
}
.gb-list-item-heading-3 > .gb-list-prefix {
@apply text-base @xs:text-lg @lg:text-xl font-semibold leading-snug;
}
/* A divider has no text size of its own. */
.gb-list-item-divider > .gb-list-prefix {
@apply leading-none;
font-size: inherit;
}
.gb-list-marker {
@apply before:content-(--pseudoBefore--content) before:font-var;
}
.gb-list-body {
@apply flex min-w-0 flex-1 flex-col space-y-2;
}
/* Blocks inside a list item; after `page-content-width` (page.css) so `mx-0` wins. */
.gb-list-child {
@apply min-h-lh mx-0;
/* The first heading in a list item has no top margin. */
&:is(h2, h3, h4) {
@apply pt-0;
}
}
/* Inline code */
.inline-code {
@apply py-px px-1.5 min-w-6.5 justify-center items-center ring-1 ring-inset ring-tint bg-tint rounded-sm text-[.875em] leading-[calc(max(1.20em,1.25rem))] break-words hyphens-none;
}
.inline-icon {
@apply inline size-[1em];
}
.inline-link-icon {
@apply ml-0.5 inline size-3 links-accent:text-tint-subtle;
}
.inline-link-mail {
@apply ml-1;
}
/* Images */
.gb-images {
@apply flex w-full justify-center;
}
.gb-images-left {
@apply justify-start;
}
.gb-images-right {
@apply justify-end;
}
.gb-images-row {
@apply flex flex-row gap-3;
}
.gb-images-multi {
@apply grid grid-flow-col;
}
.gb-images-framed {
@apply rounded-2xl border border-[rgb(234,235,238)] dark:border-[rgb(45,50,58)] relative overflow-hidden w-fit;
}
.gb-image {
@apply relative overflow-hidden;
}
/* Captions */
.gb-caption {
@apply relative;
}
.gb-caption-media {
@apply relative overflow-hidden after:block after:absolute after:-inset-0 after:pointer-events-none;
}
.gb-caption-fit {
@apply w-fit;
}
.gb-caption-bordered {
@apply rounded-corners:rounded-sm circular-corners:rounded-2xl after:border-tint-subtle after:border after:rounded circular-corners:after:rounded-2xl rounded-corners:after:rounded-sm dark:after:mix-blend-plus-lighter after:pointer-events-none;
}
.gb-caption-framed {
@apply p-2;
}
.gb-caption-center {
@apply mx-auto;
}
.gb-caption-left {
@apply mr-auto ml-0;
}
.gb-caption-right {
@apply mr-0 ml-auto;
}
.gb-caption-text {
@apply text-xs text-center text-tint mt-2;
}
.gb-caption-text-framed {
@apply mt-0.5 mb-2.5;
}
}
@@ -1,399 +0,0 @@
@layer utilities {
/* Wrappers that make room for the AI chat panel. */
.chrome-shift {
@apply lg:chat-open:pr-(--ai-chat-width) transition-all duration-300 motion-reduce:transition-none;
}
.chrome-shift-padding {
@apply lg:chat-open:pr-(--ai-chat-width) transition-[padding] duration-300 motion-reduce:transition-none;
}
/* Header */
.header-bar {
@apply flex flex-col sticky top-0 pt-[env(safe-area-inset-top)] z-30 w-full flex-none shadow-[0px_1px_0px] shadow-tint-12/2 forced-colors:border-b bg-tint-base/9 theme-muted:bg-tint-subtle/9 [html.sidebar-filled.theme-bold.tint_&]:bg-tint-subtle/9 theme-gradient:bg-gradient-primary theme-gradient-tint:bg-gradient-tint contrast-more-strong:bg-tint-base text-sm backdrop-blur-lg;
&.mobile-only {
@apply lg:hidden;
}
}
.header-inner {
@apply site-header:theme-bold:bg-header-background site-header:theme-bold:shadow-[0px_1px_0px] site-header:theme-bold:shadow-tint-12/2;
}
.header-content {
@apply gap-4 lg:gap-6 flex items-center justify-between w-full py-3 min-h-16 sm:h-16 transition-[max-width] duration-300 motion-reduce:transition-none @container/header;
}
.header-start {
@apply flex max-w-full min-w-0 shrink items-center justify-start gap-2 lg:gap-4;
}
.header-start-prominent {
@apply lg:@2xl:basis-72;
}
.header-search {
@apply flex grow-0 shrink-0 md:@2xl:basis-56 justify-self-end items-center gap-2 transition-[margin] duration-300 motion-reduce:transition-none order-last;
}
.header-search-prominent {
/* Margins: container (100%) - sidebar (18rem) - content (48rem) [- outline (14rem) - margin (3rem)] */
@apply md:@2xl:grow-[0.8] md:@4xl:basis-40 md:@2xl:max-w-[50%] md:@4xl:max-w-lg lg:@2xl:ml-[max(calc((100%-18rem-48rem)/2),1.5rem)] chat-closed:xl:ml-[max(calc((100%-18rem-48rem-14rem-3rem)/2),1.5rem)] md:@2xl:mr-auto md:@2xl:order-[unset];
}
.header-social {
@apply flex items-center gap-1;
}
.header-links {
@apply @4xl:[&>.button+.button]:-ml-2 z-20 ml-auto flex min-w-9 shrink grow @7xl:grow-0 items-center justify-end @4xl:gap-x-6 gap-x-4;
}
.header-links-ellipsis {
@apply z-20 items-center;
}
.header-link {
@apply flex items-center gap-1 shrink contrast-more-strong:underline truncate text-tint links-default:hover:text-primary links-default:aria-expanded:text-primary links-default:tint:hover:text-tint-strong links-default:tint:aria-expanded:text-tint-strong underline-offset-2 links-accent:hover:underline links-accent:aria-expanded:underline links-accent:underline-offset-4 links-accent:decoration-primary-subtle links-accent:decoration-[3px] links-accent:py-0.5 theme-bold:text-header-link hover:theme-bold:text-header-link/7!;
}
.header-link-static {
@apply cursor-default;
}
.header-more {
@apply text-tint hover:text-primary dark:hover:text-primary theme-bold:text-header-link theme-bold:hover:text-header-link/8 flex gap-1 items-center;
}
/*
* Button overrides, in this layer so the button's hover/focus rules still win over them.
* `.translations-dropdown` comes last: its transparent background replaces the other one.
*/
.spaces-dropdown-button {
@apply bg-tint-base;
}
.translations-dropdown {
@apply bg-transparent lg:max-w-64;
}
.header-logo {
@apply min-w-0 shrink flex items-center;
}
.header-logo-img {
@apply overflow-hidden shrink min-w-0 max-w-40 lg:max-w-64 lg:site-header-none:page-no-toc:max-w-56 max-h-8 h-full w-full object-contain object-left;
}
.header-logo-icon {
@apply object-contain size-8;
}
.header-logo-text {
@apply text-pretty line-clamp-2 tracking-tight max-w-[18ch] lg:max-w-[24ch] font-heading font-semibold ms-3 text-base/tight lg:text-lg/tight text-tint-strong theme-bold:text-header-link;
}
/* Announcement banner */
.announcement {
@apply pb-2 pt-4 theme-bold:bg-header-background;
}
.announcement-box {
@apply flex w-full items-start justify-center overflow-hidden circular-corners:rounded-xl rounded-md straight-corners:rounded-none px-4 py-3 text-neutral-strong text-sm theme-bold:ring-1 theme-gradient:ring-1 ring-inset transition-colors;
}
.announcement-closeable {
@apply pr-12;
}
.announcement-icon {
@apply mr-3 mt-0.5 size-4 shrink-0;
}
.announcement-info {
@apply bg-info ring-info-subtle;
&.announcement-linked {
@apply hover:bg-info-hover active:bg-info-active;
}
.announcement-icon {
@apply text-info-subtle;
}
}
.announcement-warning {
@apply bg-warning decoration-warning/6 ring-warning-subtle;
&.announcement-linked {
@apply hover:bg-warning-hover;
}
.announcement-icon {
@apply text-warning-subtle;
}
}
.announcement-danger {
@apply bg-danger decoration-danger/6 ring-danger-subtle;
&.announcement-linked {
@apply hover:bg-danger-hover;
}
.announcement-icon {
@apply text-danger-subtle;
}
}
.announcement-success {
@apply bg-success decoration-success/6 ring-success-subtle;
&.announcement-linked {
@apply hover:bg-success-hover;
}
.announcement-icon {
@apply text-success-subtle;
}
}
/* Footer */
.footer {
@apply border-tint-subtle border-t;
}
/* Only a theme toggle: hidden where the outline column, which carries its own, is pinned open. */
.footer-toggle-only {
@apply layout-default:xl:chat-closed:hidden layout-default:3xl:hidden layout-wide:3xl:chat-closed:hidden page-api-block:page-has-outline:min-[96rem]:hidden;
}
/* The site container, with its base padding overridden to a flat px-4. */
.footer-container {
@apply sm:px-6 sm:pl-[max(env(safe-area-inset-left),1.5rem)] sm:pr-[max(env(safe-area-inset-right),1.5rem)] md:px-8 md:pl-[max(env(safe-area-inset-left),2rem)] md:pr-[max(env(safe-area-inset-right),2rem)] max-w-screen-2xl px-4 py-8 @4xl:py-12 mx-auto @container/footer;
}
.footer-grid {
@apply flex @xs:grid @4xl:max-w-none! flex-col justify-between gap-12 grid-cols-[auto_auto] @4xl:grid-cols-[18rem_minmax(auto,48rem)_auto] @7xl:grid-cols-[18rem_minmax(auto,48rem)_14rem];
}
.footer-logo {
@apply col-start-1 row-start-1;
}
.footer-logo-img {
@apply w-auto max-w-40 @4xl:max-w-64 max-h-10 @4xl:max-h-12 object-contain object-left rounded-sm straight-corners:rounded-xs;
}
.footer-toggle {
@apply page-api-block:page-has-outline:min-[96rem]:hidden -col-start-2 row-start-1 flex items-start @xs:justify-end layout-default:xl:chat-closed:hidden layout-default:3xl:hidden layout-wide:3xl:chat-closed:hidden;
}
.footer-groups {
@apply col-span-2;
}
.footer-columns {
@apply mx-auto flex flex-col gap-10 @xl:flex-row @xl:gap-6;
}
.footer-column {
@apply flex flex-1 grow flex-col gap-10;
}
.footer-social {
@apply col-span-full flex w-full grow items-center justify-center gap-2;
}
.footer-legal {
@apply order-last col-span-full flex w-full grow flex-col items-center gap-2 text-center text-xs text-tint;
}
.footer-group {
@apply flex flex-col gap-4 text-sm;
}
.footer-group-title {
@apply font-heading font-semibold;
}
.footer-group-links {
@apply flex flex-col items-start gap-4;
}
.footer-link {
@apply font-normal text-tint links-default:hover:text-primary links-default:tint:hover:text-tint-strong contrast-more-strong:underline contrast-more-strong:text-tint-strong underline-offset-2 links-accent:hover:underline links-accent:underline-offset-4 links-accent:decoration-primary-subtle links-accent:decoration-[3px];
}
/* Search bar */
.search-input-header {
@apply @max-2xl:size-9.5 relative flex grow;
}
.search-input-frame {
@apply relative flex w-full grow;
}
.search-input-icon {
@apply size-text-lg shrink-0 text-tint site-header:theme-bold:text-header-link/8;
}
.search-input-icon-frame {
@apply size-text-lg shrink-0 text-tint-subtle;
}
.search-input-count {
@apply animate-blur-in mr-2 text-sm text-tint-subtle;
}
/* Site section tabs */
.section-tabs {
@apply relative z-10 flex w-full flex-nowrap items-end;
}
.section-tabs-scroll {
@apply grow md:-ml-8 -ml-4 sm:-ml-6;
}
.section-tabs-scroll-full {
@apply md:-mr-8 -mr-4 sm:-mr-6;
}
/* Divider before the trailing children, shown once the tabs overflow. */
.section-tabs-scroll-divided {
@apply after:absolute after:inset-y-2 after:right-0 after:border-transparent after:border-r after:transition-colors;
}
.section-tabs-scroll-more {
@apply after:border-tint;
}
.section-tabs-list {
@apply flex grow gap-2 bg-transparent pl-1 sm:pl-3 md:pl-5 pr-1;
}
.section-tabs-list-full {
@apply sm:pr-3 md:pr-5;
}
.section-tabs-content {
/* Bounds the scrolling content too: the popup settles at `height: auto`, so `h-full` doesn't. */
@apply h-full w-full overflow-y-auto overflow-x-hidden md:w-max md:max-w-(--available-width) max-h-[calc(100dvh-8rem)] transition-[opacity,translate] duration-300 ease-[cubic-bezier(0.83,0,0.17,1)] data-ending-style:opacity-0 data-starting-style:opacity-0 data-starting-style:data-[activation-direction=left]:-translate-x-1/2 data-ending-style:data-[activation-direction=left]:translate-x-1/2 data-ending-style:data-[activation-direction=right]:-translate-x-1/2 data-starting-style:data-[activation-direction=right]:translate-x-1/2;
}
.section-tabs-positioner {
@apply z-20 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) outline-hidden transition-[top,left,right,bottom] duration-300 ease-[cubic-bezier(0.83,0,0.17,1)] data-instant:transition-none;
}
.section-tabs-popup {
/*
* Sized here rather than on the content, so the border doesn't push the content off-centre.
* `[interpolate-size:numeric-only]`: the global `allow-keywords` would animate Base UI's reset to `auto`.
* The size vars reset on close, so closing only animates opacity and scale.
*/
@apply relative h-(--popup-height) w-(--popup-width) origin-(--transform-origin) overflow-hidden circular-corners:rounded-3xl rounded-corners:rounded-xl border border-tint bg-tint-base shadow-lg outline-hidden max-md:w-[calc(100vw-2rem)] max-h-[calc(100dvh-8rem)] transition-[opacity,scale,width,height] duration-300 ease-[cubic-bezier(0.83,0,0.17,1)] [interpolate-size:numeric-only] data-ending-style:transition-[opacity,scale] data-ending-style:scale-95 data-starting-style:scale-95 data-ending-style:opacity-0 data-starting-style:opacity-0;
}
.section-tabs-viewport {
@apply relative h-full w-full overflow-hidden;
}
/* Button overrides: they beat the active blank button's resting colours but not its hover ones. */
.section-tab {
@apply relative my-1.5 overflow-visible;
}
.section-tab-active {
@apply after:-bottom-1.5 bg-transparent text-primary-subtle after:absolute after:inset-x-3 after:h-0.5 after:bg-primary-9 contrast-more-strong:bg-primary-12 contrast-more-strong:text-contrast-primary-12;
}
.section-icon {
@apply size-[1em] shrink-0 text-inherit opacity-8;
}
.section-icon-active {
@apply opacity-10;
}
/* Section group dropdown */
.section-dropdown {
@apply flex w-full flex-col md:flex-row;
}
.section-panel {
@apply w-full shrink-0 md:w-max;
}
.section-groups-panel {
@apply w-full md:w-max md:min-w-0 md:max-w-full;
}
.section-panel-plain {
@apply bg-tint-base;
}
.section-panel-recessed {
@apply border-tint-subtle bg-tint-subtle max-md:border-t md:border-l;
}
.section-links {
@apply flex w-full grid-flow-row flex-col gap-x-2 gap-y-0.5 p-3 md:grid md:w-max;
}
.section-groups {
@apply p-3 flex w-full flex-col justify-start space-y-8 md:w-max md:flex-row md:items-start md:gap-[var(--site-section-column-gap)] md:space-y-0;
}
.section-groups-masonry {
@apply p-3 w-full max-md:space-y-8 md:max-w-[var(--masonry-max-width)] md:gap-x-[var(--site-section-column-gap)] md:[column-count:var(--masonry-columns)] md:[column-width:var(--site-section-column-min-width)] md:[&>li]:mb-4;
}
.section-group {
@apply flex w-full min-w-0 shrink-0 break-inside-avoid flex-col gap-1 md:w-auto;
}
.section-group-span {
@apply md:[column-span:all];
}
.section-group-title {
@apply mb-1 mt-2 flex min-w-0 gap-2 px-2.5 font-heading text-xs font-semibold text-tint-subtle;
}
.section-group-label {
@apply min-w-0 flex-1 whitespace-normal;
}
.section-group-list {
@apply flex w-full flex-col gap-x-2 gap-y-0.5 grid-flow-row md:grid;
}
/* Same track sizing as the masonry it spans, so its sections line up with the groups around it. */
.section-group-list-masonry {
@apply flex w-full flex-col gap-x-2 gap-y-0.5 md:block md:gap-x-[var(--site-section-column-gap)] md:[column-count:var(--masonry-columns)] md:[column-width:var(--site-section-column-min-width)] md:[&>li]:mb-0.5 md:[&>li]:break-inside-avoid;
}
.section-tile {
@apply flex w-full min-w-0 shrink-0 grow md:max-w-[var(--site-section-tile-max-width)];
}
.section-tile-link {
@apply grow circular-corners:rounded-2xl rounded-corners:rounded-lg px-2.5 py-1.5 transition-colors;
&:not(.section-tile-link-active) {
@apply text-tint-strong hover:bg-tint-hover;
}
}
.section-tile-link-active {
@apply bg-primary-active text-primary-strong;
}
.section-tile-body {
@apply mb-auto flex min-w-0 grow items-center gap-2;
}
.section-tile-text {
@apply flex min-w-0 flex-col gap-0.5;
}
.section-tile-title {
@apply block min-w-0 whitespace-normal;
}
.section-tile-icon {
@apply -ml-1 self-start circular-corners:rounded-2xl rounded-corners:rounded-lg p-2 transition-colors bg-tint text-tint-strong;
&.section-tile-icon-inverted {
@apply bg-primary-base;
}
&.section-tile-icon-active {
@apply bg-primary-base text-primary-subtle;
}
@media (hover: hover) {
.section-tile:hover &:not(.section-tile-icon-active) {
@apply bg-tint-base;
}
}
}
/* Site section list (sidebar, when there is no header) */
.section-list {
@apply -mx-5 relative border-tint-subtle border-b from-transparent sidebar-filled:to-tint-subtle theme-muted:to-tint-subtle to-tint-base text-sm text-tint before:pointer-events-none before:absolute before:right-2 before:bottom-0 before:left-0 before:h-12 before:bg-linear-to-b [html.sidebar-filled.theme-bold.tint_&]:to-tint-subtle [html.sidebar-filled.theme-muted_&]:to-tint-base;
}
.section-list-items {
@apply flex w-full flex-col px-2;
}
.section-item {
@apply flex flex-row items-center gap-3 rounded-md straight-corners:rounded-none circular-corners:rounded-xl px-3 py-2 transition-all hover:bg-tint-hover hover:text-tint-strong contrast-more-strong:hover:ring-1 contrast-more-strong:hover:ring-tint;
&[aria-current="page"] {
@apply font-semibold text-primary-subtle hover:bg-primary-hover hover:text-primary contrast-more-strong:text-primary contrast-more-strong:hover:text-primary-strong contrast-more-strong:hover:ring-1 contrast-more-strong:hover:ring-primary-hover;
}
}
.section-item-group {
@apply flex w-full flex-row items-center gap-3 rounded-md px-3 py-2 text-left transition-all hover:bg-tint-hover hover:text-tint-strong straight-corners:rounded-none contrast-more-strong:hover:ring-1 contrast-more-strong:hover:ring-tint;
/* The active group's primary hover colours always lost to the tint ones, so they are left out. */
&.section-item-current {
@apply font-semibold text-primary hover:text-tint-strong contrast-more-strong:text-primary-strong;
}
}
.section-item-icon {
@apply flex size-8 shrink-0 items-center justify-center rounded-md straight-corners:rounded-none bg-tint-subtle text-lg text-tint leading-none shadow-tint shadow-xs ring-1 ring-tint-subtle transition-transform contrast-more-strong:text-tint-strong dark:shadow-none;
.section-item[aria-current="page"] & {
@apply bg-primary tint:bg-primary-original text-primary-subtle tint:text-contrast-primary-original shadow-md shadow-primary ring-primary contrast-more-strong:text-primary contrast-more-strong:ring-2 contrast-more-strong:ring-primary dark:shadow-none;
}
.section-item-current & {
@apply bg-primary text-primary shadow-md shadow-primary ring-primary contrast-more-strong:text-primary-strong contrast-more-strong:ring-2 contrast-more-strong:ring-primary dark:shadow-none;
}
@media (hover: hover) {
:is(.section-item, .section-item-group):hover & {
@apply scale-110;
}
:is(.section-item:not([aria-current="page"]), .section-item-group:not(.section-item-current)):hover & {
@apply ring-tint-hover;
}
}
/* After the active rules: pressing flattens the shadow of an active item too. */
:is(.section-item, .section-item-group):active & {
@apply scale-90 shadow-none;
}
}
.section-item-abbr {
@apply text-sm opacity-8;
.section-item[aria-current="page"] &,
.section-item-current & {
@apply opacity-10;
}
}
.section-item-toggle {
@apply ml-auto relative rounded-full straight-corners:rounded-xs w-5 h-5 after:grid-area-1-1 after:absolute after:-top-1 after:grid after:-left-1 after:w-7 after:h-7 hover:bg-tint-active hover:text-current;
.section-item-current & {
@apply hover:bg-tint-hover;
}
}
.section-item-chevron {
@apply shrink-0 size-3 m-1 transition-opacity text-current opacity-6 contrast-more-strong:opacity-11;
@media (hover: hover) {
.section-item-toggle:hover & {
@apply opacity-11;
}
}
}
.section-list-children {
@apply pl-3;
}
.section-list-children-hidden {
@apply [&_ul>li]:opacity-1;
}
}
@@ -1,296 +0,0 @@
@layer utilities {
/* Shared layout constants (`components/layout.ts`); grouped with the elements that combine them. */
.site-container,
.space-layout-body {
@apply px-4 pl-[max(env(safe-area-inset-left),1rem)] pr-[max(env(safe-area-inset-right),1rem)] sm:px-6 sm:pl-[max(env(safe-area-inset-left),1.5rem)] sm:pr-[max(env(safe-area-inset-right),1.5rem)] md:px-8 md:pl-[max(env(safe-area-inset-left),2rem)] md:pr-[max(env(safe-area-inset-right),2rem)] max-w-screen-2xl mx-auto;
}
.page-content-width,
.page-main,
.page-header,
.page-meta,
.page-nav,
.page-blankslate {
@apply max-w-3xl layout-wide:max-w-6xl mx-auto w-full;
}
.page-content-reduced,
.page-description {
@apply max-w-3xl w-full;
}
.page-cover-height {
height: 240px;
}
.side-column-header {
top: 64px;
height: calc(100vh - 64px);
}
.side-column-header-cover {
top: 304px;
height: calc(100vh - 304px);
}
.side-column {
@apply top-0 h-screen;
}
.side-column-cover {
top: 240px;
height: calc(100vh - 240px);
}
/* SpaceLayout */
.space-layout {
@apply overflow-x-clip lg:chat-open:mr-(--ai-chat-width) motion-safe:transition-all motion-safe:duration-300;
}
.space-layout-body {
@apply flex flex-col lg:flex-row lg:justify-center transition-[max-width] duration-300 motion-reduce:transition-none;
}
.space-layout-body-header {
@apply site-header:min-h-[calc(100dvh-65px)] site-header-sections:min-h-[calc(100dvh-109px)];
}
.space-layout-body-no-header {
@apply lg:min-h-screen;
}
/* On bold themes the TOC header takes the header color so the logo looks correct. */
.space-layout-toc-header {
@apply pr-4 flex grow-0 text-base/tight items-center site-header:theme-bold:bg-header-background site-header:theme-bold:m-[-1.5rem_-1px_-0.5rem_-2rem] site-header:theme-bold:p-[1rem_1rem_1rem_2rem];
}
.space-layout-toc-header-mobile {
@apply lg:hidden;
}
.space-layout-toc-inner {
@apply my-5 sidebar-default:mt-2 flex flex-col gap-2 px-5 empty:hidden;
}
.space-layout-toc-inner-mobile {
@apply max-lg:hidden;
}
.space-layout-toc-search {
@apply flex gap-2 max-lg:hidden;
}
/* SitePage */
.site-page-cover {
@apply relative flex grow flex-col;
}
.site-page-row {
@apply flex grow flex-row;
}
.site-page-scroll {
@apply [--content-scroll-margin:calc(var(--spacing)*16)];
}
.site-page-scroll-sections {
@apply [--content-scroll-margin:calc(var(--spacing)*27)];
}
/* PageBody. Flex column so the growing content wrapper fills the page; the bottom padding keeps the minimised trademark clear. */
.page-main {
@apply relative min-w-0 flex-1 break-anywhere py-8 layout-wide:no-sidebar:lg:max-xl:pb-20 @container flex flex-col;
}
.page-meta {
@apply mt-6 flex flex-row flex-wrap items-center gap-4 text-tint contrast-more-strong:text-tint-strong;
}
.page-meta-date {
@apply mr-auto text-sm;
}
/* PageHeader */
.page-header {
@apply mb-6 space-y-3 after:clear-both after:block;
}
.page-header-actions {
@apply float-right ml-4 flex gap-2;
&:where(:not(.page-header-actions-solo)) {
@apply -mb-1 -mt-1.5;
}
/* Without breadcrumbs the actions sit level with the title. */
&:where(.page-header-actions-solo) {
@apply -mt-3 xs:mt-2;
}
&.page-header-actions-api {
@apply page-api-block:lg:sticky page-api-block:lg:top-[calc(var(--toc-top-offset,4rem)+1rem)] page-api-block:lg:z-20 lg:max-[96rem]:[body.outline-open:has(.openapi-block)_&]:hidden;
}
}
.page-breadcrumbs {
@apply page-cover-background:text-contrast-cover flow-root text-xs leading-relaxed text-tint layout-wide:page-no-toc:hidden page-cover-background:opacity-9;
& > ol,
& > ol > li {
@apply inline;
}
}
/* Comes after `.link` (primitives.css) so `no-underline` replaces its underline, as twMerge did. */
.page-breadcrumbs-link {
@apply inline no-underline hover:underline text-xs font-normal items-center contrast-more-strong:underline contrast-more-strong:decoration-current;
}
/* Section groups have no URL. */
.page-breadcrumbs-label {
@apply cursor-default hover:no-underline;
}
.page-breadcrumbs-sep {
@apply mx-2 inline-flex size-2 text-tint-subtle;
}
.page-title {
@apply text-2xl @xs:text-3xl @lg:text-4xl leading-tight font-heading font-bold flex items-center gap-[.5em] grow text-pretty clear-right xs:clear-none page-cover-background:text-contrast-cover;
}
.page-description {
@apply text-lg page-cover-background:text-contrast-cover text-tint contrast-more-strong:text-tint-strong clear-both;
}
/* PageIcon: size first, so the more specific icon classes below override it. */
.page-icon {
@apply size-[1em];
}
.page-title-icon {
@apply text-tint-subtle shrink-0;
}
.page-breadcrumbs-icon {
@apply mb-0.5 mr-1 inline-block size-[1em] shrink-0;
}
.page-breadcrumbs-menu-icon {
@apply size-3 shrink-0 text-tint-subtle;
}
/* PageCover */
.page-cover {
@apply overflow-hidden;
/* Negative margins cancel the container padding; full covers also extend past the TOC and outline where possible. */
&[data-cover-type="full"],
&[data-cover-type="background"] {
@apply -mx-4 sm:-mx-6 md:-mx-8 lg:-ml-12 layout-default:page-no-toc:lg:-ml-92 layout-wide:2xl:-mr-[clamp(2rem,calc((100vw-90rem)/2+2rem),18rem)] layout-wide:page-no-toc:2xl:-mx-[max(calc((100vw-90rem)/2+2rem),2rem)] layout-wide:has-sidebar:page-no-toc:lg:-ml-[max(calc((100vw-90rem)/2+23rem),23rem)] layout-default:2xl:rounded-corners:rounded-b-xl layout-default:2xl:circular-corners:rounded-b-3xl layout-wide:3xl:circular-corners:rounded-b-3xl layout-wide:3xl:rounded-corners:rounded-b-xl has-sidebar:lg:rounded-corners:rounded-bl-xl has-sidebar:lg:circular-corners:rounded-bl-3xl;
}
&[data-cover-type="background"] {
@apply -z-1 absolute inset-x-0 contrast-more-strong:opacity-5 *:contrast-more-strong:blur-md;
}
/* The hero's `-mx-4` was dropped by twMerge in favour of the content `mx-auto`. */
&[data-cover-type="hero"] {
@apply max-w-3xl layout-wide:max-w-6xl mx-auto w-full max-sm:-mx-4 sm:rounded-corners:rounded-xl sm:circular-corners:rounded-3xl mb-8 max-sm:w-screen max-sm:-mt-8;
}
}
.page-cover-loading {
@apply h-full w-full overflow-hidden;
}
.page-cover-frame {
@apply h-full w-full overflow-hidden @container;
}
.page-cover-skeleton {
@apply h-full w-full animate-pulse bg-gradient-to-br from-gray-100 to-gray-200 dark:from-gray-800 dark:to-gray-900;
}
.page-cover-img {
@apply w-full object-cover;
}
.page-cover-img-light {
@apply dark:hidden;
}
.page-cover-img-dark {
@apply dark:inline hidden;
}
/* PageFooterNavigation */
.page-nav {
@apply mt-6 flex @xl:flex-row flex-col gap-3 text-tint;
}
.page-nav-card {
@apply flex flex-1 items-center @xl:gap-3 gap-2 text-pretty circular-corners:rounded-2xl rounded-corners:rounded-xl border border-tint-subtle @xl:p-4 p-3 @xl:text-base text-sm text-tint outline-tint-12 transition-colors hover:border-primary-hover contrast-more-strong:border-tint-12 contrast-more-strong:text-tint-strong contrast-more-strong:hover:border-primary-12 contrast-more-strong:hover:outline-2 text-start;
&.page-nav-next {
@apply flex-row-reverse text-end;
}
}
.page-nav-body {
@apply flex flex-col;
}
.page-nav-label {
@apply flex items-center gap-1 text-xs flex-row;
.page-nav-next & {
@apply flex-row-reverse;
}
}
.page-nav-title {
@apply line-clamp-2 leading-snug text-tint-strong transition-colors;
@media (hover: hover) {
.page-nav-card:hover & {
@apply text-primary contrast-more-strong:text-primary-strong;
}
}
}
/* PageBodyBlankslate */
.page-blankslate-icon {
@apply text-base text-tint;
}
.page-blankslate {
@apply grid gap-4 grid-cols-1 sm:grid-cols-2 md:layout-wide:grid-cols-3;
}
/* PageFeedback */
.page-feedback {
@apply flex flex-col gap-3 text-sm;
}
.page-feedback-row {
@apply flex flex-wrap items-center gap-2;
}
.page-feedback-thanks {
@apply animate-blur-in-display-slow flex items-center gap-1 p-1.5 text-success-subtle;
}
/* PageAside. Position, top and z-index stay as utilities in the TSX: they must beat SideSheet's `fixed inset-y-0 z-41`.
The background is only added where the outline is an overlay, so a bleeding cards carousel can scroll behind the permanent column. */
.page-aside {
@apply order-last w-64 lg:max-h-screen lg:site-header:max-h-[calc(100vh-4rem)] lg:site-header-sections:max-h-[calc(100vh-6.75rem)] lg:[html[style*="--outline-top-offset"]_&]:top-(--outline-top-offset)! lg:[html[style*="--outline-height"]_&]:max-h-(--outline-height)! layout-default:max-xl:border-l layout-wide:max-3xl:border-l border-tint-subtle p-4 pt-8 ml-4 break-anywhere layout-default:xl:chat-closed:pr-0 layout-default:xl:chat-closed:pl-8 layout-default:xl:chat-closed:flex! layout-default:xl:chat-closed:animate-none! layout-default:3xl:flex! layout-default:3xl:animate-none! layout-wide:xl:-mr-68 layout-wide:3xl:chat-closed:flex! layout-wide:3xl:chat-closed:animate-none! page-api-block:page-has-outline:min-[96rem]:max-3xl:-mr-[max(calc((100vw-90rem)/2),0rem)] page-api-block:page-has-outline:min-[96rem]:flex! page-api-block:page-has-outline:min-[96rem]:animate-none! page-api-block:page-has-outline:min-[96rem]:border-l-0 page-api-block:page-has-outline:min-[96rem]:pl-8 max-xl:hydrated:site-background layout-wide:max-3xl:hydrated:site-background text-tint contrast-more-strong:text-tint-strong;
}
.page-aside-inner {
@apply flex h-full w-full shrink-0 flex-col overflow-hidden;
}
.page-aside-header {
@apply mb-3 ml-3 flex page-no-outline:hidden items-center justify-between max-lg:hidden;
}
.page-aside-header-tags {
@apply mt-4;
}
.page-aside-title {
@apply xl:page-cover-background:text-contrast-cover flex cursor-pointer items-center gap-1 text-xs font-semibold uppercase text-tint;
}
.page-aside-scroll {
@apply flex shrink flex-col overflow-hidden;
}
.page-aside-outline {
@apply overflow-y-auto;
}
.page-aside-actions {
@apply flex flex-col gap-3 border-tint-subtle border-t first:border-none sidebar-list-default:px-3 pt-5 first:pt-0 empty:hidden;
}
.page-aside-footer {
@apply sticky bottom-0 z-10 mt-auto flex flex-col border-tint-subtle pt-4;
}
.page-aside-theme {
@apply flex items-center justify-end;
}
/* ScrollSectionsList (one item per heading) */
.page-outline {
@apply relative flex flex-col border-tint-subtle pb-5 sidebar-list-line:border-l;
}
.page-outline-item {
@apply flex flex-row relative h-fit mt-2 first:mt-0 mb-0.5;
/* twMerge let the sub-item `my-0` drop `mt-2 mb-0.5`. */
&:has(> .subitem) {
@apply ml-3 my-0 sidebar-list-line:ml-0;
}
}
.page-outline-link {
@apply relative z-10 text-sm w-full py-1 px-3 transition-all motion-reduce:transition-none duration-200 rounded-md straight-corners:rounded-none circular-corners:rounded-2xl sidebar-list-line:rounded-l-none! hover:bg-tint-hover theme-gradient:hover:bg-tint-12/1 hover:text-tint-strong contrast-more-strong:hover:ring-1 contrast-more-strong:hover:ring-inset contrast-more-strong:hover:ring-current sidebar-list-line:border-l-2 border-transparent sidebar-list-line:-left-px xl:page-cover-background:text-contrast-cover;
/* OpenAPI operations show a method badge before the title. */
&:has(> .openapi-method) {
@apply flex items-baseline gap-2;
}
&.subitem {
@apply sidebar-list-line:pl-6 opacity-8 contrast-more-strong:opacity-11 sidebar-list-default:rounded-l-none! sidebar-list-default:border-l sidebar-list-default:border-tint;
}
/* The extra attribute specificity reproduces twMerge dropping the base hover colors. */
&[aria-current="true"] {
@apply text-primary-subtle hover:text-primary contrast-more-strong:text-primary contrast-more-strong:hover:text-primary-strong hover:bg-primary-hover theme-muted:hover:bg-primary-active [html.sidebar-filled.theme-bold.tint_&]:hover:bg-primary-active theme-gradient:hover:bg-primary-active tint:font-semibold contrast-more-strong:font-semibold sidebar-list-line:border-primary-9 sidebar-list-default:border-tint sidebar-list-pill:bg-primary [html.theme-muted.sidebar-list-pill_&]:bg-primary-hover [html.theme-gradient.sidebar-list-pill_&]:bg-primary-active;
}
}
.page-outline-deprecated {
@apply line-through opacity-50 contrast-more-strong:opacity-60;
}
}
@@ -1,280 +0,0 @@
@layer utilities {
/* Button. Rule order mirrors the old `tcls(base, variant, size, active)` merge. */
.button {
@apply inline-flex items-center align-middle gap-2 rounded-xl straight-corners:rounded-none circular-corners:rounded-3xl border border-tint hover:border-tint-hover disabled:border-tint depth-subtle:shadow-xs hover:depth-subtle:shadow-md focus-visible:depth-subtle:shadow-md active:depth-subtle:shadow-xs shadow-tint/6 dark:shadow-tint-1 not-focus-visible:outline-0 contrast-more-strong:border-tint-12 contrast-more-strong:hover:outline-2 contrast-more-strong:hover:outline-tint-12 contrast-more-strong:hover:border-tint-12 contrast-more-strong:focus-visible:border-tint-12 contrast-more-strong:focus-visible:outline-tint-12 hover:depth-subtle:-translate-y-px focus-visible:depth-subtle:-translate-y-px aria-expanded:depth-subtle:-translate-y-px active:depth-subtle:translate-y-0 transition-all grow-0 shrink-0 truncate max-w-full disabled:cursor-not-allowed disabled:translate-y-0! disabled:shadow-none!;
/* Plain, not `leading-normal`: its `--tw-leading` would override a caller's `text-sm` line height, which twMerge used to drop. */
line-height: 1.5;
}
/* `contrast-more-strong:border-tint-12` is repeated: as a variant utility it used to sort after `border-primary-original`. */
.button-primary {
@apply bg-primary-original text-contrast-primary-original hover:not-disabled:bg-primary-solid-hover hover:not-disabled:border-primary-solid-hover hover:not-disabled:text-contrast-primary-solid-hover border-primary-original contrast-more-strong:border-tint-12 contrast-more-strong:bg-primary-solid contrast-more-strong:text-contrast-primary-solid disabled:border-primary-2 disabled:bg-primary-subtle disabled:text-primary/8;
}
.button-blank {
@apply bg-transparent text-tint border-0 contrast-more-strong:border shadow-none! translate-y-0! hover:not-disabled:bg-tint-hover hover:not-disabled:text-tint-strong focus-visible:bg-tint-hover focus-visible:text-tint-strong aria-expanded:bg-tint-hover aria-expanded:text-tint-strong contrast-more-strong:bg-tint-subtle disabled:text-tint/8 disabled:bg-transparent;
}
.button-secondary {
@apply bg-tint depth-flat:bg-tint-base text-tint hover:bg-tint-hover hover:not-disabled:depth-flat:bg-tint-hover hover:not-disabled:text-tint contrast-more-strong:bg-tint-subtle disabled:bg-transparent disabled:text-tint/8;
}
.button-header {
@apply bg-tint-base text-tint hover:theme-clean:bg-tint-subtle theme-bold:bg-header-link/1 theme-bold:text-header-link theme-bold:shadow-none! theme-bold:border-header-link/4 hover:theme-bold:bg-header-link/2 hover:theme-bold:text-header-link hover:theme-bold:shadow-none hover:theme-bold:border-header-link/5 contrast-more-strong:theme-bold:bg-header-background contrast-more-strong:theme-bold:text-header-link contrast-more-strong:theme-bold:border-header-link contrast-more-strong:hover:theme-bold:border-header-link;
}
/* `:where` keeps the old utility specificity for the horizontal padding dropped on icon-only buttons. */
.button-large {
@apply font-semibold p-3;
&:where(:not(.button-icon-only)) {
@apply px-5;
}
}
.button-medium {
@apply p-2;
&:where(:not(.button-icon-only)) {
@apply px-4;
}
}
.button-small {
@apply p-1.5 text-sm/normal;
&:where(:not(.button-icon-only)) {
@apply px-3;
}
}
.button-xsmall {
@apply p-1 text-sm/tight rounded-corners:rounded-lg;
&:where(:not(.button-icon-only)) {
@apply px-2;
}
}
/*
* Active state, after sizes so `font-medium` beats `font-semibold`. `:where` keeps the old
* specificity, so e.g. `hover:not-disabled:bg-tint-hover` still wins over the active hover.
* Variant `contrast-more-strong:` colors are repeated where they used to sort after the active color.
*/
.button-primary:where([data-active="true"], [aria-pressed="true"]) {
@apply bg-primary-solid-hover contrast-more-strong:bg-primary-solid;
}
.button-blank:where([data-active="true"], [aria-pressed="true"]) {
@apply bg-primary-active contrast-more-strong:bg-primary-12 contrast-more-strong:text-contrast-primary-12 disabled:bg-primary-active text-primary-strong font-medium hover:text-primary-strong disabled:text-primary-strong hover:bg-primary-active focus-visible:bg-primary-active focus-visible:text-primary-strong aria-expanded:bg-primary-active aria-expanded:text-primary-strong;
}
.button-secondary:where([data-active="true"], [aria-pressed="true"]) {
@apply bg-tint-active contrast-more-strong:bg-tint-subtle disabled:bg-tint-active;
}
.button-header:where([data-active="true"], [aria-pressed="true"]) {
@apply bg-header-link/3;
}
.button-leading-icon {
@apply shrink-0;
}
.button-content-wrap {
@apply whitespace-normal text-start;
}
.button-trailing-icon {
@apply ms-auto;
}
.button-group {
@apply *:translate-y-0! *:shadow-none! [&>*:not(:first-child)]:border-l-0;
}
/* Link */
.link {
/* The underline is proportional to the font size, with a minimum: the default is too thin. */
@apply underline decoration-[max(0.07em,1px)] underline-offset-2 links-accent:underline-offset-4 links-default:decoration-primary/6 links-default:text-primary-subtle hover:links-default:text-primary-strong contrast-more-strong:links-default:text-primary contrast-more-strong:hover:links-default:text-primary-strong links-accent:decoration-primary-subtle hover:links-accent:decoration-[3px] hover:links-accent:[text-decoration-skip-ink:none] transition-all duration-100;
}
.link-overlay {
@apply absolute inset-0 z-10;
}
/* Card */
.card {
@apply flex flex-row justify-between items-center gap-4 ring-1 ring-tint-subtle rounded-sm straight-corners:rounded-none circular-corners:rounded-2xl px-5 py-3 transition-shadow hover:ring-primary-hover;
}
.card-body {
@apply flex flex-col flex-1;
}
.card-pretitle {
@apply uppercase text-xs text-tint;
}
.card-title {
@apply text-base transition-colors;
}
.card-posttitle {
@apply text-base;
}
.card-chevron {
@apply size-3 text-tint transition-all;
}
@media (hover: hover) {
.card:hover .card-title {
@apply text-primary;
}
.card:hover .card-chevron {
@apply translate-x-0.5 text-primary;
}
}
/* ToggleChevron */
.toggle-chevron {
@apply shrink-0 size-3 transition-all;
}
.toggle-chevron-auto {
@apply group-aria-expanded/dropdown:rotate-180 group-data-panel-open/dropdown:rotate-180 group-open:rotate-180;
}
.toggle-chevron-auto-90 {
@apply group-aria-expanded/dropdown:rotate-90 group-data-panel-open/dropdown:rotate-90 group-open:rotate-90;
}
.toggle-chevron-dim {
@apply opacity-6 group-hover/dropdown:opacity-11;
}
/* KeyboardShortcut */
.shortcut {
@apply flex not-pointer-fine:hidden justify-end gap-0.5 whitespace-nowrap text-tint text-xs [font-feature-settings:"calt","case"] contrast-more-strong:text-tint-strong;
}
.shortcut-key {
@apply flex h-5 min-w-5 items-center justify-center rounded-md border border-tint-subtle px-1;
}
.shortcut-key-mod {
@apply text-xs [html.os-mac_&]:text-sm;
}
.shortcut-mac {
@apply hidden [html.os-mac_&]:inline;
}
.shortcut-ctrl {
@apply inline [html.os-mac_&]:hidden;
}
.shortcut-icon {
@apply size-[.9em];
}
.tooltip {
@apply max-w-xs circular-corners:rounded-2xl rounded-corners:rounded-md bg-tint-12 px-2 py-1 text-contrast-tint-12 text-sm data-closed:animate-scale-out data-open:animate-scale-in;
}
.side-sheet-overlay {
@apply fixed inset-0 z-40 items-start bg-tint-base/3 not-hydrated:opacity-0 starting:opacity-0 backdrop-blur-md starting:backdrop-blur-none transition-[opacity,display,backdrop-filter] transition-discrete duration-250 dark:bg-tint-base/6;
}
/* ScrollContainer */
.scroll-container {
@apply relative flex shrink grow;
}
.scroll-container-x {
@apply min-w-0;
}
.scroll-container-y {
@apply min-h-0;
}
/* After the button rules: `hidden` and the transition used to replace `inline-flex` and `transition-all`. */
.scroll-container-button {
@apply bg-tint-base! absolute z-10 not-pointer-none:block hidden scale-0 transition-[scale,opacity];
}
.scroll-container-prev-x {
@apply -translate-y-1/2! top-1/2 left-0 ml-2 opacity-0;
}
.scroll-container-prev-y {
@apply -translate-x-1/2! top-0 left-1/2 mt-2 opacity-0;
}
.scroll-container-next-x {
@apply -translate-y-1/2! top-1/2 right-0 mr-2;
}
.scroll-container-next-y {
@apply -translate-x-1/2! bottom-0 left-1/2 mb-2;
}
@media not (pointer: none) {
@media (hover: hover) {
.scroll-container:hover .scroll-container-button-shown {
@apply scale-100 opacity-11;
}
}
}
/* Input. `:where` keeps the specificity the utilities had before. */
.input-box {
@apply relative flex min-h-min overflow-hidden border border-tint bg-tint-base align-middle shadow-tint/6 ring-primary-hover transition-all dark:shadow-tint-1 flex-row;
&:where(:not(.input-box-disabled)) {
@apply depth-subtle:focus-within:-translate-y-px depth-subtle:hover:not-has-[button:hover]:-translate-y-px depth-subtle:shadow-xs focus-within:border-primary-hover focus-within:depth-subtle:shadow-lg focus-within:shadow-primary-subtle focus-within:ring-2 forced-colors:focus-within:outline-2 hover:not-has-[button:hover]:cursor-text hover:not-has-[button:hover]:border-tint-hover hover:not-has-[button:hover]:not-focus-within:bg-tint-subtle depth-subtle:hover:not-has-[button:hover]:not-focus-within:shadow-md focus-within:hover:not-has-[button:hover]:border-primary-hover;
}
&:where(.input-box-multiline) {
@apply flex-col;
}
}
.input-box-disabled {
@apply cursor-not-allowed border-tint-subtle bg-tint-subtle text-tint/8;
}
/* Size classes are shared with the multiline shortcut slot, which mirrors the container padding. */
.input-box-small {
@apply px-2.5 py-1.5 text-sm gap-1.5 circular-corners:rounded-3xl rounded-corners:rounded-xl;
&:where(.input-box-multiline) {
@apply p-1.5;
}
}
.input-box-medium {
@apply px-3 py-2 gap-2 circular-corners:rounded-3xl rounded-corners:rounded-xl;
&:where(.input-box-multiline) {
@apply p-2;
}
}
.input-box-large {
@apply px-3.5 py-3 gap-3 circular-corners:rounded-3xl rounded-corners:rounded-xl;
&:where(.input-box-multiline) {
@apply p-3;
}
}
.input-box-shortcut {
@apply absolute right-0 top-0;
}
/* `aria-busy` must not change the cursor: a busy field can still be editable. */
.input-field {
@apply max-h-64 grow shrink resize-none leading-normal text-left outline-none placeholder-shown:text-ellipsis;
/*
* Styling `::placeholder` from an ancestor variant costs a full-document restyle, so callers
* set this variable on the container instead. It must stay a `var()` fallback rather than a
* declaration here, or the input would shadow the inherited override.
*/
@apply placeholder:text-[var(--input-placeholder,color-mix(in_oklab,rgb(var(--tint-11))_72%,transparent))];
}
}
@@ -1,609 +0,0 @@
@layer utilities {
/* Code blocks */
.codeblock {
@apply relative flex shrink flex-col overflow-hidden print:overflow-visible;
}
.codeblock-framed {
@apply circular-corners:rounded-2xl rounded-corners:rounded-xl straight-corners:rounded-xs;
@apply [&:has([data-codeblock-focus]:focus)]:ring-2 [&:has([data-codeblock-focus]:focus)]:ring-primary-hover;
}
.codeblock-focus {
@apply pointer-events-none absolute size-0 outline-none;
}
.codeblock-header {
@apply flex items-center justify-start gap-2 text-sm;
}
.codeblock-title {
@apply straight-corners:rounded-t-xs relative top-px z-20 inline-flex items-center justify-center border border-b-0 border-tint-subtle bg-tint-subtle px-3 py-2 text-xs leading-none tracking-wide text-tint theme-bold-tint:bg-tint-base theme-muted:bg-tint-base rounded-corners:rounded-t-lg circular-corners:rounded-t-xl contrast-more-strong:border-tint contrast-more-strong:bg-tint-base [html.theme-bold.sidebar-filled_&]:bg-tint-base;
}
.codeblock-body {
@apply relative flex min-h-0 flex-col;
}
.codeblock-actions {
@apply absolute top-2 right-2 z-2 flex items-center gap-1.5 font-sans leading-none opacity-0 has-[button:focus-visible]:opacity-11;
@media (hover: hover) {
.codeblock:hover & {
@apply opacity-11;
}
}
}
/* Single-line blocks center the buttons vertically instead of pinning them to the top. */
.codeblock-actions-centered {
@apply inset-y-0;
}
/* Declared after `.button` (primitives.css), so these win at equal specificity. */
.codeblock-button {
@apply translate-y-0! backdrop-blur-md print:hidden;
}
.codeblock-button-ask {
@apply [[data-ai-chat]_&]:hidden;
}
.codeblock-pre {
@apply relative overflow-auto py-2.5 text-tint-strong print:overflow-visible;
}
.codeblock-pre-embedded {
@apply bg-tint-base;
}
.codeblock-pre-framed {
@apply border border-tint-subtle bg-tint-subtle theme-bold-tint:bg-tint-base theme-muted:bg-tint-base contrast-more-strong:border-tint contrast-more-strong:bg-tint-base;
@apply circular-corners:rounded-2xl rounded-corners:rounded-xl straight-corners:rounded-xs depth-subtle:shadow-xs;
}
.codeblock-pre-titled {
@apply rounded-ss-none!;
}
.codeblock-code {
@apply table max-h-full w-fit min-w-full [counter-reset:line] print:max-h-none print:whitespace-pre-wrap;
@apply [[aria-expanded=false]_&]:mask-b-from-50%;
}
.codeblock-code-wrap {
@apply whitespace-pre-wrap;
}
/* Lines of an embedded block drop the theme background and only tint on hover. */
.highlight-line-plain {
@apply bg-transparent! hover:bg-tint-subtle!;
}
/* Tabs */
.tabs-block {
@apply flex min-w-0 flex-col rounded-lg ring-1 ring-tint-subtle ring-inset straight-corners:rounded-xs;
}
.tabs-list {
@apply inline-flex self-stretch overflow-hidden rounded-t-lg straight-corners:rounded-t-xs after:flex-1 after:bg-tint-12/1;
/* When the last tab is selected, round the filler after it. */
@apply [&:has(button.active-tab:last-of-type):after]:rounded-bl-md;
}
.tabs-item {
@apply relative flex max-w-full shrink-0 items-center truncate bg-tint-12/1 text-tint hover:text-tint-strong;
@apply [&:has(+_.active-tab)]:rounded-br-md [.active-tab+&]:rounded-bl-md [.active-tab_+_:after]:rounded-br-md;
@apply after:absolute after:top-[15%] after:right-0 after:left-[unset] after:h-[70%] after:w-px after:border-r after:border-tint after:transition-colors last:after:border-transparent;
@apply [&.active-tab]:after:border-transparent [:has(+_&.active-tab)]:after:border-transparent;
&.active-tab {
@apply bg-transparent text-tint-strong [:has(&_+)]:after:border-transparent;
}
}
/* Width of a tab in the strip; these replace the default `max-w-full`. */
.tabs-item-current {
/* Keeps room for the overflow menu button. */
@apply max-w-[calc(100%-3rem)];
}
.tabs-item-measuring {
@apply order-1 max-w-28;
}
.tabs-item-fluid {
@apply max-w-max min-w-0 grow-[1000] basis-0;
}
.tabs-button {
@apply relative inline-flex max-w-full min-w-0 items-center gap-1.5 px-4 py-2.5 text-sm font-medium transition-[color];
}
.tabs-button-icon {
@apply size-4 shrink-0;
}
.tabs-button-label {
@apply min-w-0 truncate;
}
.tabs-panel {
@apply scroll-mt-[calc(var(--content-scroll-margin)+var(--spacing)*20)];
}
.tabs-panel-body {
@apply px-8 py-6;
}
.tabs-panel-blocks {
@apply w-full space-y-4;
}
/* Tables */
.table-block {
@apply flex flex-col gap-3;
}
.table-view {
@apply relative mx-auto grid w-full min-w-0;
}
.table-scroll {
@apply w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-none border-tint-subtle;
}
.table-stack {
@apply flex flex-col;
}
.table-grid-header {
@apply mb-1 flex flex-col rounded-lg border border-tint-subtle bg-tint;
}
.table-native-header {
@apply mb-1 rounded-lg border border-tint-subtle bg-tint;
}
.table-header-clip {
@apply overflow-hidden;
}
.table-grid-header-row {
@apply flex w-full;
}
.table-header-cell {
@apply relative px-3 py-2 text-sm font-medium text-tint-strong;
}
/* First column header when the whole header is already sticky. */
.table-header-cell-pinned {
@apply z-20 bg-tint;
}
.table-header-cell-sticky {
@apply sticky left-0 z-20 bg-tint;
}
.table-grid-body {
@apply flex flex-col [&>*+*]:border-t;
}
.table-native {
@apply w-full table-fixed border-separate border-spacing-0;
}
.table-native-body {
@apply [&>tbody>tr>td[data-table-hovered]]:bg-tint-hover [&>tbody>tr+tr>td]:border-t [&>tbody+tbody>tr:first-child>td]:border-t;
}
.table-native-cell {
@apply relative px-3 py-2 text-sm transition-colors;
}
.table-native-cell-divider {
@apply border-r border-tint-subtle;
}
.table-native-cell-sticky {
@apply sticky left-0 z-10 bg-tint-base;
}
.table-sticky {
@apply relative flex w-full max-w-full min-w-0 flex-col rounded-lg border-tint-subtle data-[scrollable=true]:border;
}
.table-sticky-header {
@apply sticky z-20 w-full max-w-full min-w-0 overflow-hidden rounded-t-[inherit] [top:var(--toc-top-offset,var(--outline-top-offset,0px))];
}
.table-sticky-header-track {
/* The sticky header sits outside the scroll container, so it mirrors the body's scroll position. */
@apply flex flex-col [transform:translateX(var(--table-sticky-scroll-left,0px))];
}
.table-sticky-scroll {
@apply group-data-[scrollable=true]/table:mx-px group-data-[scrollable=true]/table:rounded-none group-data-[scrollable=true]/table:border-0;
}
.record-text {
@apply w-full space-y-2 leading-normal lg:space-y-3;
}
.record-number {
@apply text-base tracking-tighter tabular-nums;
}
.record-rating {
@apply inline-grid;
}
.record-rating-stars {
@apply grid-area-1-1 inline-flex gap-0.5;
}
.record-rating-star {
@apply size-[15px] text-primary/5;
}
.record-rating-star-filled {
@apply size-[15px] text-primary;
}
.record-ref {
@apply flex items-center text-base text-balance;
}
.record-file-link {
@apply flex flex-row items-center gap-2;
}
.record-select {
@apply inline-flex flex-wrap gap-2;
}
.record-select-option {
@apply rounded-sm bg-primary px-2 py-1 text-sm whitespace-pre text-primary-strong;
}
/* Cards view */
.record-cards {
@apply inline-grid grid-cols-1 gap-4;
}
/* Large cards break earlier to avoid becoming *too* big. */
.record-cards-large {
@apply @xl:grid-cols-2;
}
.record-cards-medium {
@apply @sm:grid-cols-2 @2xl:grid-cols-3;
}
/* A one-column grid stretches the card to fill the fixed-width, equal-height track. */
.record-carousel-item {
@apply grid shrink-0 snap-start grid-cols-1;
}
/* Fixed widths so the row overflows and scrolls, mirroring the grid's medium/large sizing. */
.record-carousel-item-medium {
@apply w-[90%] @sm:w-[calc(45%-0.5rem)] @xl:w-[calc(30%-0.66rem)] @5xl:w-[calc(33.33%-0.66rem)];
}
.record-carousel-item-large {
@apply w-[90%] @sm:w-[calc(45%-0.5rem)] @5xl:w-[calc(50%-0.5rem)];
}
/* Mirrors `RecordCardStyles` in Table/styles.ts, mapped from the `RecordCardStyles` design token. */
.record-card {
@apply grid rounded-sm shadow-1xs shadow-tint-9/1 straight-corners:rounded-none circular-corners:rounded-xl depth-flat:shadow-none dark:shadow-transparent;
@apply before:pointer-events-none before:relative before:z-10 before:grid-area-1-1 before:h-full before:w-full before:rounded-[inherit] before:ring-1 before:ring-tint-12/2 before:transition-shadow;
}
.record-card-link {
@apply hover:before:ring-primary-hover;
}
.record-card-body {
@apply grid-area-1-1 relative -inset-px grid h-[calc(100%+2px)] w-[calc(100%+2px)] overflow-hidden rounded-sm bg-tint-base straight-corners:rounded-none circular-corners:rounded-xl;
@apply [&_.heading>div:first-child]:hidden [&_.heading>div]:text-[.8em] @xl:[&_.heading>div]:text-[1em];
/* No padding-top on the first heading in a card. */
@apply [&_.blocks:first-child_.heading]:pt-0;
}
.record-card-body-landscape {
@apply grid-rows-[auto_1fr];
}
/* Square or portrait covers sit on the left with 40% of the card width on mobile. */
.record-card-body-portrait {
@apply grid-cols-[40%__1fr] @sm:grid-cols-none @sm:grid-rows-[auto_1fr];
}
.record-card-body-portrait-dark {
@apply dark:grid-cols-[40%__1fr] dark:@sm:grid-cols-none dark:@sm:grid-rows-[auto_1fr];
}
.record-card-cover {
@apply h-full w-full min-w-0 bg-tint-subtle;
}
.record-card-cover-landscape {
@apply aspect-video h-auto;
}
.record-card-cover-portrait {
@apply @sm:aspect-video @sm:h-auto;
}
.record-card-cover-portrait-dark {
@apply dark:@sm:aspect-video dark:@sm:h-auto;
}
.record-card-content {
@apply flex w-full min-w-0 flex-col gap-3 place-self-start p-4 text-sm text-tint-strong;
}
.record-card-field {
@apply flex flex-col gap-1;
}
.record-card-field-title {
@apply text-sm text-tint;
}
/* Columns */
.column-set {
@apply grid w-full grid-cols-1 gap-x-8 gap-y-4 @2xl:grid-flow-col @2xl:grid-cols-[repeat(var(--grid-slices),minmax(0,1fr))] @2xl:grid-rows-1;
}
.column-set-item {
@apply @container/column flex flex-col justify-start;
}
.column-set-item-middle {
@apply justify-center;
}
.column-set-item-bottom {
@apply justify-end;
}
.column-set-item-sized {
@apply @2xl:flex-shrink-0 @2xl:[grid-column:var(--grid-col)];
}
.column-set-body {
@apply w-full space-y-4;
}
/* Expandables */
.expandable {
@apply scroll-mt-(--content-scroll-margin) border border-b-0 border-tint-subtle bg-tint-base;
@apply mt-0! mb-0 first:mt-5! first:rounded-t-lg;
/* First and last of a run of adjacent expandables. */
@apply [:not(&)_+_&]:mt-5! [:not(&)_+_&]:rounded-t-lg;
@apply [&:not(:has(+_&))]:mb-5 [&:not(:has(+_&))]:rounded-b-lg [&:not(:has(+_&))]:border-b;
}
.expandable-summary {
@apply relative cursor-pointer list-none px-4 py-4 text-tint transition-colors select-none [&::-webkit-details-marker]:hidden;
.expandable[open] & {
@apply text-tint-strong;
}
@media (hover: hover) {
.expandable:hover & {
@apply text-tint-strong;
}
}
}
/* Reserves room for the anchor icon pinned to the right edge. */
.expandable-summary-anchored {
@apply pr-10;
}
.expandable-chevron {
@apply mr-3 mb-1 inline-block size-3 shrink-0;
.expandable[open] & {
@apply rotate-90;
}
}
.expandable-anchor {
@apply absolute top-2 right-4 bottom-2 flex items-center dark:shadow-none dark:ring-0;
}
.expandable-anchor-icon {
@apply inline-block size-3 text-transparent transition-colors;
@media (hover: hover) {
.expandable:hover & {
@apply text-tint-subtle contrast-more-strong:text-tint-strong;
}
}
}
.expandable-body {
@apply space-y-4 px-10 pb-5;
}
/* Stepper */
.stepper-item {
@apply flex flex-row gap-4 md:gap-8;
}
.stepper-step-marker {
@apply relative select-none;
}
.stepper-step-number {
@apply flex size-[calc(1.75rem+1px)] items-center justify-center rounded-full bg-primary-solid tabular-nums theme-muted:bg-tint-base contrast-more-strong:bg-primary-11;
@apply font-medium text-contrast-primary-solid theme-muted:text-tint contrast-more-strong:text-contrast-primary-11;
}
.stepper-step-line {
@apply absolute top-9 bottom-2 left-3.5 w-px bg-primary-7 theme-muted:bg-tint-6;
}
.stepper-step-body {
@apply min-w-0 flex-1 pb-6 [&>*+*]:mt-5;
}
/* File */
.file-block {
@apply flex flex-wrap items-center gap-5 px-5 py-3;
}
.file-block-preview {
@apply flex min-h-8 min-w-14 flex-col items-center justify-center gap-1 border-r border-tint-subtle pr-4;
}
.file-block-image {
@apply h-auto max-h-10 w-auto max-w-10 rounded object-contain;
}
.file-block-icon {
@apply size-5 text-primary;
}
.file-block-info {
@apply min-w-24 flex-1;
}
.file-block-name {
@apply text-base;
}
.file-block-meta {
@apply text-sm text-tint-subtle;
}
.file-block-actions {
@apply flex shrink-0 flex-wrap gap-2;
}
/* Updates */
.updates-block {
@apply flex flex-col gap-20;
}
.update-block {
@apply relative flex flex-col gap-2 md:flex-row md:gap-4 lg:gap-8;
}
.update-block-aside {
/* Sticky only in the row layout; the 0px fallback avoids a jump before JS sets the variable. */
@apply h-fit w-40 min-w-40 shrink-0 md:sticky md:top-[calc(var(--toc-top-offset,0px)+8px)]!;
}
.update-block-date {
@apply inline-flex items-center text-sm font-medium tracking-wide text-neutral-10;
}
.update-block-tags {
@apply mt-2 flex flex-wrap gap-1.5;
}
.update-block-body {
@apply flex flex-1 flex-col [&>*:first-child]:!pt-0 [&>*+*]:mt-5;
}
.updates-filter {
@apply shrink-0 border-b border-tint-subtle pt-px pb-4;
}
.updates-filter-header {
@apply mb-3 ml-3 flex items-center justify-between gap-2;
}
.updates-filter-label {
/* The original `leading-wider` was not a real utility and generated nothing. */
@apply flex items-center gap-1 text-xs font-semibold text-tint uppercase;
}
.updates-filter-tags {
@apply flex flex-wrap gap-1.5 px-3;
}
.updates-chip {
@apply inline-flex max-w-full rounded-full not-focus-visible:outline-0 focus-visible:ring-2 focus-visible:ring-primary straight-corners:rounded-xs circular-corners:rounded-2xl;
}
/* Which face shows is toggled by the generated filter stylesheet (see generateUpdatesFilterCSS). */
.updates-chip-face {
@apply max-w-full items-center gap-1 rounded-full px-2 py-1 text-xs leading-normal font-medium transition-colors straight-corners:rounded-xs circular-corners:rounded-2xl;
}
.updates-chip-selected {
@apply hidden bg-primary-original text-contrast-primary-original hover:bg-primary-solid-hover;
}
.updates-chip-dimmed {
@apply hidden bg-tint-5 text-tint-strong opacity-8 hover:bg-tint-hover hover:opacity-11;
}
.updates-chip-plain {
@apply flex bg-tint-5 text-tint-strong hover:bg-tint-hover;
}
/* Prompt */
.prompt-block {
@apply relative flex w-full flex-col overflow-hidden border border-tint-subtle bg-tint-base text-tint-strong transition contrast-more-strong:border-tint straight-corners:rounded-xs rounded-corners:rounded-xl circular-corners:rounded-2xl;
}
.prompt-block-expanded {
@apply bg-tint depth-subtle:shadow-xs;
}
.prompt-header {
@apply relative flex min-h-9 flex-row items-center justify-between gap-4 p-3 transition-colors;
}
.prompt-header-open {
@apply hover:bg-tint-hover;
}
.prompt-header-closed {
@apply hover:bg-tint-subtle;
}
.prompt-toggle {
@apply absolute inset-0 z-10 cursor-pointer outline-hidden focus-visible:ring-2 focus-visible:ring-primary-hover;
}
.prompt-title {
@apply pointer-events-none relative z-0 flex min-w-0 flex-row items-center gap-2 text-tint-strong;
}
.prompt-body {
@apply border-t border-tint-subtle bg-tint-base;
}
.prompt-actions {
@apply relative z-20 flex shrink-0 items-center gap-2;
}
.prompt-agent {
@apply flex size-4 shrink-0 items-center justify-center rounded-full border border-tint bg-tint-base;
/* Each chip's border cuts into the one behind it, so the marks stay legible however tightly they are stacked. */
& + & {
@apply -ms-1.5;
}
}
}
@@ -1,115 +0,0 @@
@layer utilities {
/* Lists */
.toc-list {
@apply flex flex-col gap-y-0.5;
}
.toc-list-root {
@apply grow border-tint-subtle sidebar-list-line:border-l page-no-toc:hidden;
}
.toc-list-nested {
@apply my-2 ml-5 border-tint-subtle break-anywhere sidebar-list-default:border-l sidebar-list-line:border-l;
}
.page-document-item,
.page-link-item {
@apply flex flex-col [.page-group-item+&]:mt-4;
}
/* Sidebar links (design tokens `ToCLinkItemStyles` / `ToCLinkItemActiveStyles`) */
.toclink {
@apply relative flex flex-row items-center justify-start gap-3 text-balance rounded-md p-1.5 pl-3 font-normal text-sm text-tint-strong/7 transition-colors before:absolute before:inset-y-0 before:-left-px focus-visible:-outline-offset-2 circular-corners:rounded-2xl straight-corners:rounded-none sidebar-list-line:rounded-l-none! sidebar-list-line:before:w-px has-[.openapi-method]:pl-3 [&+div_a]:pl-5 [&+div_a]:sidebar-list-default:rounded-l-none [&+div_a]:sidebar-list-default:before:w-px hover:bg-tint-hover hover:text-tint-strong contrast-more-strong:text-tint-strong contrast-more-strong:hover:text-tint-strong contrast-more-strong:hover:ring-1 contrast-more-strong:hover:ring-tint-12;
}
/* Comes after `.toclink` so equal-specificity rules replace it, like twMerge did. */
.toclink-active {
@apply font-semibold text-primary-subtle before:bg-primary-solid sidebar-list-line:before:w-0.5 sidebar-list-pill:bg-primary [html.sidebar-list-pill.theme-muted_&]:bg-primary-hover [html.sidebar-list-pill.theme-bold.tint_&]:bg-primary-hover [html.sidebar-filled.sidebar-list-pill.theme-muted_&]:bg-primary [html.sidebar-filled.sidebar-list-pill.theme-bold.tint_&]:bg-primary hover:bg-primary-hover hover:text-primary hover:before:bg-primary-solid-hover hover:sidebar-list-pill:bg-primary-hover contrast-more-strong:bg-primary contrast-more-strong:text-primary contrast-more-strong:ring-1 contrast-more-strong:ring-primary contrast-more-strong:hover:text-primary-strong contrast-more-strong:hover:ring-primary-hover;
}
.toclink-label {
@apply flex min-w-0 flex-1 flex-wrap items-center gap-2;
}
.toclink-method {
@apply flex h-[1lh] w-9 shrink-0 self-baseline;
}
.toclink-children {
@apply flex flex-col overflow-hidden;
}
.toclink-external {
@apply mt-1 mr-1 ml-auto size-3 shrink-0 place-self-start text-current opacity-6 transition-all contrast-more-strong:opacity-11;
@media (hover: hover) {
.toclink:hover & {
@apply opacity-11;
}
}
}
/* Overrides on the Button primitive: an open chevron must look like a closed one. */
.toclink-toggle {
@apply -my-0.5 -mr-1 ml-auto min-h-6 min-w-6 text-current hover:bg-tint-base aria-expanded:bg-transparent aria-expanded:text-current aria-expanded:hover:bg-tint-hover;
}
.toc-chevron {
@apply m-0! size-3!;
}
.toclink-toggle .toc-chevron {
@apply opacity-6 group-hover:opacity-11;
}
.toc-icon {
@apply shrink-0 text-base in-[.toclink]:text-tint-strong/6 theme-bold-no-tint:text-primary-subtle theme-gradient-no-tint:text-primary-subtle theme-bold-tint:text-tint-subtle theme-gradient-tint:text-tint-subtle;
.toclink[aria-current="page"] & {
@apply text-inherit!;
}
}
/* Page groups */
.page-group-item {
@apply flex flex-col;
}
/* No opacity transition on ::after: in Chrome it leaves stale pixels over the first child after the list scrolls. */
.toc-group-header {
@apply sticky -top-4 z-1 mt-1 bg-tint-base pt-2.5 pb-0 after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-4 after:bg-linear-to-b after:from-tint-base after:to-transparent after:opacity-0 sidebar-filled:bg-tint-subtle sidebar-filled:after:from-tint-subtle theme-muted:bg-tint-subtle theme-muted:after:from-tint-subtle [html.sidebar-filled.theme-muted_&]:bg-tint-base [html.sidebar-filled.theme-muted_&]:after:from-tint-base [html.sidebar-filled.theme-bold.tint_&]:bg-tint-base [html.sidebar-filled.theme-bold.tint_&]:after:from-tint-base lg:[html.sidebar-default.theme-gradient_&]:bg-gradient-primary lg:[html.sidebar-default.theme-gradient_&]:after:from-primary-2 lg:[html.sidebar-default.theme-gradient.tint_&]:bg-gradient-tint lg:[html.sidebar-default.theme-gradient.tint_&]:after:from-tint-subtle;
}
.toc-group-header-stuck {
@apply after:opacity-100;
}
.toc-group-header-first {
@apply -top-2 -mt-2 rounded-t-md pt-2 circular-corners:rounded-t-2xl;
}
.toc-group {
@apply relative flex min-h-8 w-full appearance-none flex-row items-center justify-start gap-3 text-balance rounded-md border-0 p-1.5 pl-3 text-left font-heading font-semibold text-tint-strong text-xs uppercase tracking-wide transition-colors before:absolute before:inset-y-0 before:-left-px focus-visible:-outline-offset-2 circular-corners:rounded-2xl straight-corners:rounded-none sidebar-list-line:rounded-l-none! sidebar-list-line:before:w-px has-[.openapi-method]:pl-3 [&+div_a]:pl-5 [&+div_a]:sidebar-list-default:rounded-l-none [&+div_a]:sidebar-list-default:before:w-px hover:bg-tint-hover hover:text-tint-strong contrast-more-strong:text-tint-strong contrast-more-strong:hover:text-tint-strong contrast-more-strong:hover:ring-1 contrast-more-strong:hover:ring-tint-12 [&_.toc-group-chevron]:transition-opacity hover:[&_.toc-group-chevron]:opacity-11 focus-visible:[&_.toc-group-chevron]:opacity-11;
&:enabled {
@apply cursor-pointer;
}
}
.toc-group-chevron {
@apply mr-1 ml-auto flex shrink-0 opacity-6 transition-opacity delay-0 duration-150;
/* Lower specificity than the `.toc-group:hover` reveal above, as before. */
[aria-expanded="true"] > & {
@apply pointer-events-none opacity-0 delay-75;
}
}
.toc-group-body {
@apply mt-px grid grid-rows-[1fr] opacity-100 transition-[grid-template-rows,opacity] duration-200 ease-in-out;
}
.toc-group-body-closed {
@apply grid-rows-[0fr] opacity-0;
}
/* Sidebar panel */
/* `-ms-5` compensates for the PagesList padding. */
.toc-sidebar {
@apply relative -ms-5 flex min-h-0 grow flex-col border-tint-subtle layout-wide:no-sidebar:ms-0 layout-default:no-sidebar:lg:max-xl:ms-0 sidebar-filled:rounded-2xl sidebar-filled:bg-tint-subtle theme-muted:bg-tint-subtle straight-corners:rounded-none [html.sidebar-filled.theme-muted_&]:bg-tint-base [html.sidebar-filled.theme-bold.tint_&]:bg-tint-base [html.sidebar-filled.theme-gradient_&]:border max-lg:sidebar-filled:border lg:page-no-toc:bg-transparent! lg:page-no-toc:border-none! [html.sidebar-filled.circular-corners_&]:layout-wide:rounded-4xl;
}
.tag {
@apply inline-flex max-w-full shrink-0 items-center gap-1 rounded-full px-2 py-1 font-medium text-xs leading-normal contrast-more-strong:ring-1 contrast-more-strong:ring-tint;
}
.tag-default {
@apply bg-tint-5 text-tint-strong;
}
.tag-icon {
@apply size-[1em] shrink-0;
}
}
@@ -83,7 +83,11 @@ export const SearchInput = React.forwardRef<HTMLDivElement, SearchInputProps>(
}, [isFrame, isOpen, value.length, onFocus]);
return (
<div className={isFrame ? 'search-input-frame' : 'search-input-header'}>
<div
className={
isFrame ? 'relative flex w-full grow' : '@max-2xl:size-9.5 relative flex grow'
}
>
<Input
data-testid="search-input"
name="search-input"
@@ -106,7 +110,9 @@ export const SearchInput = React.forwardRef<HTMLDivElement, SearchInputProps>(
<Icon
icon="search"
className={
isFrame ? 'search-input-icon-frame' : 'search-input-icon'
isFrame
? 'size-text-lg shrink-0 text-tint-subtle'
: 'size-text-lg shrink-0 text-tint site-header:theme-bold:text-header-link/8'
}
/>
)
@@ -128,7 +134,7 @@ export const SearchInput = React.forwardRef<HTMLDivElement, SearchInputProps>(
}
trailing={
!showAsk && value && resultsCount > 0 ? (
<div className="search-input-count">
<div className="animate-blur-in mr-2 text-sm text-tint-subtle">
{t(language, 'search_results_count', resultsCount.toString())}
</div>
) : undefined
@@ -22,7 +22,6 @@ import { UpdatesFilterProvider } from '@/components/DocumentView/UpdatesFilter';
import { UpdatesFilterScript } from '@/components/DocumentView/UpdatesFilterScript';
import { PageAside } from '@/components/PageAside';
import { PageBody, PageCover } from '@/components/PageBody';
import { cx } from '@/lib/classnames';
import type { GitBookSiteContext } from '@/lib/context';
import { getDataOrNull, getPageDocument } from '@/lib/data';
import {
@@ -35,6 +34,7 @@ import { getPagePath } from '@/lib/pages';
import { resolveContentRef } from '@/lib/references';
import { isPageIndexable, isSiteIndexable } from '@/lib/seo';
import { getSiteSpacePagePaths, resolveSiteSpaceCustomHomePage } from '@/lib/sites';
import { tcls } from '@/lib/tailwind';
import {
generateUpdatesFilterCSS,
getDocumentFilterableTags,
@@ -93,7 +93,11 @@ export async function SitePage(props: SitePageProps & { staticRoute: boolean })
<>
{/* Using `contents` makes the children of this div according to its parent — which keeps them in a single flex row with the TOC by default.
If there's a page cover, we use `flex flex-col` to lay out the PageCover above the PageBody + PageAside instead. */}
<div className={withFullPageCover && page.cover ? 'site-page-cover' : 'contents'}>
<div
className={
withFullPageCover && page.cover ? 'relative flex grow flex-col' : 'contents'
}
>
{withFullPageCover && page.cover ? (
<PageCover
as={page.layout.coverSize === 'background' ? 'background' : 'full'}
@@ -104,9 +108,11 @@ export async function SitePage(props: SitePageProps & { staticRoute: boolean })
) : null}
<div
className={cx(
withFullPageCover && page.cover ? 'site-page-row' : 'contents',
withSections ? 'site-page-scroll-sections' : 'site-page-scroll'
className={tcls(
withFullPageCover && page.cover ? 'flex grow flex-row' : 'contents',
withSections
? '[--content-scroll-margin:calc(var(--spacing)*27)]'
: '[--content-scroll-margin:calc(var(--spacing)*16)]'
)}
>
<PageAside
@@ -1,6 +1,6 @@
import { Icon, type IconName } from '@gitbook/icons';
import { type ClassValue, cx } from '@/lib/classnames';
import { type ClassValue, tcls } from '@/lib/tailwind';
/**
* Icon shown beside a section in the site section tabs.
@@ -11,7 +11,11 @@ export function SectionIcon(props: { icon: IconName; isActive: boolean; classNam
return (
<Icon
icon={icon}
className={cx('section-icon', isActive && 'section-icon-active', className)}
className={tcls(
'size-[1em] shrink-0 text-inherit opacity-8',
isActive && 'text-inherit opacity-10',
className
)}
/>
);
}

Some files were not shown because too many files have changed in this diff Show More