From 17df1be3ef1620e9d5e35d05c4213feefb6de83e Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Thu, 12 Jun 2025 19:38:31 +0200 Subject: [PATCH] Second iteration, ready --- .../DocumentView/Tabs/DynamicTabs.tsx | 171 +++++++++--------- 1 file changed, 85 insertions(+), 86 deletions(-) diff --git a/packages/gitbook/src/components/DocumentView/Tabs/DynamicTabs.tsx b/packages/gitbook/src/components/DocumentView/Tabs/DynamicTabs.tsx index 8c6966975..0638e5ba1 100644 --- a/packages/gitbook/src/components/DocumentView/Tabs/DynamicTabs.tsx +++ b/packages/gitbook/src/components/DocumentView/Tabs/DynamicTabs.tsx @@ -84,7 +84,8 @@ export function DynamicTabs( ); }, [id, tabs, tabsState]); - const position: string = 'top'; + const position: string = 'top'; // TODO: Get position from tab block options + const description = null; // TODO: Get description from tabs // To avoid issue with hydration, we only use the state from localStorage // once the component has been mounted. @@ -145,16 +146,23 @@ export function DynamicTabs( return (
3 ? 'md:flex-wrap' : '', - // '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' + 'overflow-x-auto', + 'md:overflow-hidden', + + 'gap-1', + 'pb-2', + 'flex-row', + + position === 'left' || position === 'right' + ? 'gap-2 md:max-w-[40%] md:flex-col' + : '', + 'snap-x', + 'snap-mandatory', + + // We need to inset the tablist to make edge-to-edge scrolling work. + '-mx-4', + 'px-4', + 'scroll-px-4', + 'sm:-mx-6', + 'sm:px-6', + 'sm:scroll-px-6', + 'md:mx-0', + 'md:px-0', + 'md:scroll-px-0' )} > {tabs.map((tab) => ( - + ))}
{tabs.map((tab, index) => ( @@ -274,6 +272,7 @@ export function DynamicTabs( className={tcls( 'p-4', 'rounded-lg', + 'flex-1', 'straight-corners:rounded-none', 'circular-corners:rounded-2xl', 'grow',