diff --git a/packages/gitbook/src/components/AI/server-actions/AIToolCallsSummary.tsx b/packages/gitbook/src/components/AI/server-actions/AIToolCallsSummary.tsx index 290081f693..00abbf8ae1 100644 --- a/packages/gitbook/src/components/AI/server-actions/AIToolCallsSummary.tsx +++ b/packages/gitbook/src/components/AI/server-actions/AIToolCallsSummary.tsx @@ -187,7 +187,7 @@ async function DescriptionForSearchToolCall(props: { ) : null} {hasResults ? ( -
+
    {searchResultsWithHrefs.map((result, index) => (
  1. -
    -
    -
    - - -
    - {announcement.message} - {hasLink ? ( -
    - {contentRef?.icon ? ( - - {contentRef?.icon} - - ) : null} - {announcement.link?.title && ( - {announcement.link?.title} - )} - -
    - ) : null} -
    -
    - {closeable ? ( -
    +
    +
    + + +
    + {announcement.message} + {hasLink ? ( +
    + {contentRef?.icon ? ( + + {contentRef?.icon} + + ) : null} + {announcement.link?.title && ( + {announcement.link?.title} + )} + +
    + ) : null} +
    +
    + {closeable ? ( +
    diff --git a/packages/gitbook/src/components/Footer/Footer.tsx b/packages/gitbook/src/components/Footer/Footer.tsx index f8e0596b7c..c084a4571a 100644 --- a/packages/gitbook/src/components/Footer/Footer.tsx +++ b/packages/gitbook/src/components/Footer/Footer.tsx @@ -32,111 +32,109 @@ export function Footer(props: { context: GitBookSiteContext }) { mobileOnly ? 'xl:hidden' : null )} > -
    -
    -
    - { - // Footer Logo - customization.footer.logo ? ( -
    - Logo -
    - ) : null - } +
    +
    + { + // Footer Logo + customization.footer.logo ? ( +
    + Logo +
    + ) : null + } - { - // Theme Toggle - customization.themes.toggeable ? ( -
    - - - -
    - ) : null - } + { + // Theme Toggle + customization.themes.toggeable ? ( +
    + + + +
    + ) : null + } - { - // Navigation groups (split into equal columns) - customization.footer.groups?.length > 0 ? ( -
    0 ? ( +
    +
    + {partition(customization.footer.groups, FOOTER_COLUMNS).map( + (column, columnIndex) => ( +
    + {column.map((group, groupIndex) => ( + + ))} +
    + ) )} - > -
    - {partition(customization.footer.groups, FOOTER_COLUMNS).map( - (column, columnIndex) => ( -
    - {column.map((group, groupIndex) => ( - - ))} -
    - ) - )} -
    - ) : null - } +
    + ) : null + } - { - // Legal - customization.footer.copyright ? ( -
    -

    {customization.footer.copyright}

    -
    - ) : null - } -
    + { + // Legal + customization.footer.copyright ? ( +
    +

    {customization.footer.copyright}

    +
    + ) : null + }
    diff --git a/packages/gitbook/src/components/Header/Header.tsx b/packages/gitbook/src/components/Header/Header.tsx index f9a32ee88c..80147e41ec 100644 --- a/packages/gitbook/src/components/Header/Header.tsx +++ b/packages/gitbook/src/components/Header/Header.tsx @@ -56,141 +56,137 @@ export function Header(props: { 'theme-bold:shadow-tint-12/2' )} > -
    -
    +
    +
    -
    - - -
    - -
    - 1} - spaceTitle={siteSpace.title} - siteSpaceId={siteSpace.id} - viewport={!withTopHeader ? 'mobile' : undefined} - /> -
    + /> + +
    - {customization.header.links.length > 0 && ( - - {customization.header.links.map((link) => { - return ( - - ); - })} - - +
    + 1} + spaceTitle={siteSpace.title} + siteSpaceId={siteSpace.id} + viewport={!withTopHeader ? 'mobile' : undefined} + />
    + + {customization.header.links.length > 0 && ( + + {customization.header.links.map((link) => { + return ( + + ); + })} + + + )}
    {sections || siteSpaces.length > 1 ? ( -
    -
    +
    +
    -
    - {siteSpaces.length > 1 && ( -
    - -
    + {siteSpaces.length > 1 && ( +
    + +
    + )} + {sections && + (sections.list.some((s) => s.object === 'site-section-group') || // If there's even a single group, show the tabs + sections.list.length > 1) && ( // Otherwise, show the tabs if there's more than one section + )} - {sections && - (sections.list.some((s) => s.object === 'site-section-group') || // If there's even a single group, show the tabs - sections.list.length > 1) && ( // Otherwise, show the tabs if there's more than one section - - )} -
    diff --git a/packages/gitbook/src/components/RootLayout/globals.css b/packages/gitbook/src/components/RootLayout/globals.css index d32cee38a3..8d22180b0c 100644 --- a/packages/gitbook/src/components/RootLayout/globals.css +++ b/packages/gitbook/src/components/RootLayout/globals.css @@ -20,8 +20,7 @@ } } -@utility hide-scroll { - /* hide scroll bar but still scroll */ +@utility no-scrollbar { &::-webkit-scrollbar { display: none; } @@ -29,6 +28,22 @@ -ms-overflow-style: none; } +@utility hide-scrollbar { + /* Hide scrollbar by default */ + scrollbar-color: transparent transparent; + transition: scrollbar-color 0.2s ease-in-out; + + &:hover { + /* Show scrollbar on hover */ + scrollbar-color: unset; + } + + @media (prefers-contrast: more) { + /* Always show scrollbar in high contrast mode */ + scrollbar-color: unset; + } +} + @utility linear-mask-gradient { mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 96px, rgba(0, 0, 0, 0)); mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 96px, rgba(0, 0, 0, 0)); @@ -143,47 +158,6 @@ @apply bg-linear-to-bl from-tint-4 to-tint-base to-60% bg-fixed; } -@utility scroll-nojump { - /** - * Utility to prevent horizontal jumps when the vertical scrollbar appears - * It should be used on main containers of the layout, while preserving horizontal delimiters. - * It basically adds a margin-left with the width of the scrollbar, and a width that compensates for it; when a scrollbar is displayed. - * Inspired by https://aykevl.nl/2014/09/fix-jumping-scrollbar, but adapted to work on child elements of "html" - */ - width: 100%; - @media screen and (min-width: 1536px) { - margin-left: var(--scrollbar-width); - margin-right: 0; - width: calc(100% - var(--scrollbar-width)); - body:has(.page-full-width) & { - margin-left: 0; - width: 100%; - } - } - - /** - * Utility to prevent horizontal jumps when the vertical scrollbar appears - * It should be used on main containers of the layout, while preserving horizontal delimiters. - * It basically adds a margin-left with the width of the scrollbar, and a width that compensates for it; when a scrollbar is displayed. - * Inspired by https://aykevl.nl/2014/09/fix-jumping-scrollbar, but adapted to work on child elements of "html" - */ - width: 100%; - @media screen and (min-width: 1536px) { - margin-left: var(--scrollbar-width); - margin-right: 0; - width: calc(100% - var(--scrollbar-width)); - } -} - -@utility page-full-width { - @media screen and (min-width: 1536px) { - body:has(&) .scroll-nojump { - margin-left: 0; - width: 100%; - } - } -} - @utility elevate-link { & a[href]:not(.link-overlay) { position: relative; @@ -211,15 +185,59 @@ @layer base { :root { - --scrollbar-width: calc(100vw - 100%); @apply leading-relaxed; interpolate-size: allow-keywords; /* Opt-in for modern browsers to interpolate "auto" values in transitions/animations. */ } + + /* Modern browsers with `scrollbar-*` support */ + @supports (scrollbar-color: auto) { + * { + scrollbar-color: theme("colors.tint.7") transparent; + scrollbar-width: thin; + } + + @media (prefers-contrast: more) { + * { + scrollbar-color: theme("colors.tint.11") transparent; + scrollbar-width: auto; + } + } + } + + /* Otherwise, use `::-webkit-scrollbar-*` pseudo-elements */ + @supports selector(::-webkit-scrollbar) { + ::-webkit-scrollbar { + background: transparent; + max-width: 8px; + } + + ::-webkit-scrollbar-thumb { + background: theme("colors.tint.7"); + border-radius: 8px; + transition: background 0.2s ease-in-out; + } + + ::-webkit-scrollbar-thumb:hover { + background: theme("colors.tint.8"); + } + + @media (prefers-contrast: more) { + ::-webkit-scrollbar-thumb { + background: theme("colors.tint.11"); + } + + ::-webkit-scrollbar-thumb:hover { + background: theme("colors.tint.12"); + } + } + } + + body { @apply text-tint-strong antialiased; } html { - @apply gutter-stable; + scrollbar-width: auto; } h1 { @apply tracking-[-0.025em] text-tint-strong text-balance; @@ -250,22 +268,6 @@ @apply subpixel-antialiased; } - /* Light mode */ - ::-webkit-scrollbar { - @apply bg-tint-subtle; - width: 8px; - height: 8px; - } - - ::-webkit-scrollbar-thumb { - @apply bg-tint-7; - border-radius: 8px; - } - - ::-webkit-scrollbar-thumb:hover { - @apply bg-tint-8; - } - .flip-heading-hash { @apply [h1,h2,h3,h4]:content-start; @apply [h1,h2,h3,h4]:auto-cols-[auto_1fr]; diff --git a/packages/gitbook/src/components/Search/SearchContainer.tsx b/packages/gitbook/src/components/Search/SearchContainer.tsx index bbd358d3e4..dc70365445 100644 --- a/packages/gitbook/src/components/Search/SearchContainer.tsx +++ b/packages/gitbook/src/components/Search/SearchContainer.tsx @@ -194,7 +194,7 @@ export function SearchContainer(props: SearchContainerProps) { onOpenAutoFocus: (event) => event.preventDefault(), align: 'start', className: - 'bg-tint-base has-[.empty]:hidden scroll-py-2 w-128 p-2 max-h-[min(32rem,var(--radix-popover-content-available-height))] max-w-[min(var(--radix-popover-content-available-width),32rem)]', + 'bg-tint-base has-[.empty]:hidden gutter-stable scroll-py-2 w-128 p-2 pr-1 max-h-[min(32rem,var(--radix-popover-content-available-height))] max-w-[min(var(--radix-popover-content-available-width),32rem)]', onInteractOutside: (event) => { // Don't close if clicking on the search input itself if (searchInputRef.current?.contains(event.target as Node)) { diff --git a/packages/gitbook/src/components/SiteSections/SiteSectionList.tsx b/packages/gitbook/src/components/SiteSections/SiteSectionList.tsx index 26cb341d7f..7feb98795d 100644 --- a/packages/gitbook/src/components/SiteSections/SiteSectionList.tsx +++ b/packages/gitbook/src/components/SiteSections/SiteSectionList.tsx @@ -38,7 +38,7 @@ export function SiteSectionList(props: { sections: ClientSiteSections; className > {sectionsAndGroups.map((item) => { if (item.object === 'site-section-group') { diff --git a/packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx b/packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx index 216bd5a001..1b2ca97094 100644 --- a/packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx +++ b/packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx @@ -81,82 +81,81 @@ export function SpaceLayout(props: { {customization.ai?.mode === CustomizationAIMode.Assistant ? ( ) : null} -
    -
    -
    - +
    + + +
    + ) + } + innerHeader={ + // displays the search button and/or the space dropdown in the ToC according to the header/variant settings. E.g if there is no header, the search button will be displayed in the ToC. + <> + {!withTopHeader && ( + 1} + spaceTitle={siteSpace.title} + siteSpaceId={siteSpace.id} + className="max-lg:hidden" + viewport="desktop" + /> + )} + {!withTopHeader && withSections && sections && ( + + )} + {isMultiVariants && !sections && ( + - -
    - ) - } - innerHeader={ - // displays the search button and/or the space dropdown in the ToC according to the header/variant settings. E.g if there is no header, the search button will be displayed in the ToC. - <> - {!withTopHeader && ( - 1} - spaceTitle={siteSpace.title} - siteSpaceId={siteSpace.id} - className="max-lg:hidden" - viewport="desktop" - /> - )} - {!withTopHeader && withSections && sections && ( - - )} - {isMultiVariants && !sections && ( - - )} - - } - /> -
    {children}
    -
    + /> + )} + + } + /> +
    {children}
    diff --git a/packages/gitbook/src/components/TableOfContents/TableOfContents.tsx b/packages/gitbook/src/components/TableOfContents/TableOfContents.tsx index 9afcc33d10..5cca5257fa 100644 --- a/packages/gitbook/src/components/TableOfContents/TableOfContents.tsx +++ b/packages/gitbook/src/components/TableOfContents/TableOfContents.tsx @@ -101,12 +101,7 @@ export async function TableOfContents(props: { className={tcls( 'flex grow flex-col p-2', customization.trademark.enabled && 'lg:pb-20', - 'lg:gutter-stable overflow-y-auto', - '[&::-webkit-scrollbar]:bg-transparent', - '[&::-webkit-scrollbar-thumb]:bg-transparent', - '[&::-webkit-scrollbar]:group-hover:bg-tint-subtle', - '[&::-webkit-scrollbar-thumb]:group-hover:bg-tint-7', - '[&::-webkit-scrollbar-thumb:hover]:group-hover:bg-tint-8' + 'hide-scrollbar overflow-y-auto' )} >