diff --git a/packages/gitbook/src/components/AIChat/AIChat.tsx b/packages/gitbook/src/components/AIChat/AIChat.tsx index 74230a5c8..0daf45a4a 100644 --- a/packages/gitbook/src/components/AIChat/AIChat.tsx +++ b/packages/gitbook/src/components/AIChat/AIChat.tsx @@ -229,7 +229,7 @@ export function AIChatBody(props: { className="shrink grow basis-80 animate-fade-in-slow [container-type:size]" contentClassName="p-4 gutter-stable flex flex-col gap-4" orientation="vertical" - fadeEdges={['leading']} + trailing={{ fade: false, button: true }} active={`#message-group-${chat.messages.filter((message) => message.role === 'user').length - 1}`} > {isEmpty ? ( diff --git a/packages/gitbook/src/components/Embeddable/EmbeddableDocsPage.tsx b/packages/gitbook/src/components/Embeddable/EmbeddableDocsPage.tsx index 69fc08b49..6edc6cc83 100644 --- a/packages/gitbook/src/components/Embeddable/EmbeddableDocsPage.tsx +++ b/packages/gitbook/src/components/Embeddable/EmbeddableDocsPage.tsx @@ -79,7 +79,7 @@ export async function EmbeddableDocsPage( orientation="vertical" className="not-hydrated:animate-blur-in-slow" contentClassName="p-4" - fadeEdges={context.sections ? [] : ['leading']} + leading={{ fade: !context.sections, button: true }} >
diff --git a/packages/gitbook/src/components/TableOfContents/TableOfContents.tsx b/packages/gitbook/src/components/TableOfContents/TableOfContents.tsx index 66c7c5aa8..66fa4e0a1 100644 --- a/packages/gitbook/src/components/TableOfContents/TableOfContents.tsx +++ b/packages/gitbook/src/components/TableOfContents/TableOfContents.tsx @@ -74,7 +74,7 @@ export async function TableOfContents(props: { 'lg:page-no-toc:[html[style*="--outline-top-offset"]_&]:top-(--outline-top-offset)!', 'lg:page-no-toc:[html[style*="--outline-height"]_&]:top-(--outline-height)!', - 'pt-6 pb-4', + 'pt-4 pb-4', 'lg:sidebar-filled:pr-6', 'lg:page-no-toc:pr-0', 'max-lg:pl-8', @@ -88,7 +88,7 @@ export async function TableOfContents(props: {
+
); diff --git a/packages/gitbook/src/components/primitives/ScrollContainer.tsx b/packages/gitbook/src/components/primitives/ScrollContainer.tsx index aea4079a2..f5a5e132e 100644 --- a/packages/gitbook/src/components/primitives/ScrollContainer.tsx +++ b/packages/gitbook/src/components/primitives/ScrollContainer.tsx @@ -4,7 +4,7 @@ import { tString, useLanguage } from '@/intl/client'; import { tcls } from '@/lib/tailwind'; import * as React from 'react'; import { useScrollListener } from '../hooks/useScrollListener'; -import { Button } from './Button'; +import { Button, type ButtonProps } from './Button'; /** * A container that encapsulates a scrollable area with usability features. @@ -17,17 +17,26 @@ export type ScrollContainerProps = { className?: string; contentClassName?: string; - /** Optional class(es) to apply when there the container can be scrolled on the leading (left or top) edge */ - leadingEdgeScrollClassName?: string; - - /** Optional class(es) to apply when there the container can be scrolled on the trailing (right or bottom) edge */ - trailingEdgeScrollClassName?: string; - /** The direction of the scroll container. */ orientation: 'horizontal' | 'vertical'; - /** Whether to fade out the edges of the container. */ - fadeEdges?: ('leading' | 'trailing')[]; + leading?: { + /** Whether to fade out the leading edge of the container. */ + fade: boolean; + /** Whether to show a button to scroll back. */ + button: boolean | ButtonProps; + /** Optional class(es) to apply when there the container can be scrolled on the leading (left or top) edge */ + className?: string; + }; + + trailing?: { + /** Whether to fade out the trailing edge of the container. */ + fade: boolean; + /** Whether to show a button to scroll forward. */ + button: boolean | ButtonProps; + /** Optional class(es) to apply when there the container can be scrolled on the trailing (right or bottom) edge */ + className?: string; + }; /** The ID or ref of the active item to scroll to. */ active?: string | React.RefObject; @@ -39,10 +48,9 @@ export function ScrollContainer(props: ScrollContainerProps) { className, contentClassName, orientation, - fadeEdges = ['leading', 'trailing'], active, - leadingEdgeScrollClassName, - trailingEdgeScrollClassName, + leading = { fade: true, button: true }, + trailing = { fade: true, button: true }, ...rest } = props; @@ -140,28 +148,30 @@ export function ScrollContainer(props: ScrollContainerProps) { return (
0 ? leadingEdgeScrollClassName : '', - scrollPosition < scrollSize ? trailingEdgeScrollClassName : '' + scrollPosition > 0 ? leading?.className : '', + scrollPosition < scrollSize ? trailing?.className : '' )} {...rest} > {/* Scrollable content */}
0 + leading.fade && scrollPosition > 0 ? orientation === 'horizontal' - ? 'mask-l-from-[calc(100%-2rem)]' - : 'mask-t-from-[calc(100%-2rem)]' + ? 'mask-l-from-[calc(100%-1.5rem)]' + : 'mask-t-from-[calc(100%-1.5rem)]' : '', - fadeEdges.includes('trailing') && scrollPosition < scrollSize + trailing.fade && scrollPosition < scrollSize ? orientation === 'horizontal' - ? 'mask-r-from-[calc(100%-2rem)]' - : 'mask-b-from-[calc(100%-2rem)]' + ? 'mask-r-from-[calc(100%-1.5rem)]' + : 'mask-b-from-[calc(100%-1.5rem)]' : '', contentClassName )} @@ -171,44 +181,52 @@ export function ScrollContainer(props: ScrollContainerProps) {
{/* Scroll buttons back & forward */} -
); }