From 0fdb8414ab679c2fa68e563d6a7c7a7213c035f0 Mon Sep 17 00:00:00 2001 From: Nolann Biron Date: Tue, 22 Jul 2025 17:24:26 +0200 Subject: [PATCH] Remove scroll-nojump utility and update layout structure Eliminated the .scroll-nojump utility and related CSS from globals.css and refactored layout components (Header, Footer, AnnouncementBanner, SpaceLayout) to remove unnecessary wrapper divs. Updated scrollbar styling to use native CSS properties for improved consistency and maintainability. --- .../Announcement/AnnouncementBanner.tsx | 120 +++++----- .../gitbook/src/components/Footer/Footer.tsx | 198 ++++++++-------- .../gitbook/src/components/Header/Header.tsx | 218 +++++++++--------- .../src/components/RootLayout/globals.css | 38 +-- .../components/SpaceLayout/SpaceLayout.tsx | 121 +++++----- 5 files changed, 328 insertions(+), 367 deletions(-) diff --git a/packages/gitbook/src/components/Announcement/AnnouncementBanner.tsx b/packages/gitbook/src/components/Announcement/AnnouncementBanner.tsx index e4a55c6e03..117b44e49e 100644 --- a/packages/gitbook/src/components/Announcement/AnnouncementBanner.tsx +++ b/packages/gitbook/src/components/Announcement/AnnouncementBanner.tsx @@ -34,68 +34,66 @@ export function AnnouncementBanner(props: { className="theme-bold:bg-header-background pt-4 pb-2" data-nosnippet="" > -
-
-
- +
+ + +
+ {announcement.message} + {hasLink ? ( +
+ {contentRef?.icon ? ( + + {contentRef?.icon} + + ) : null} + {announcement.link?.title && ( + {announcement.link?.title} + )} + +
+ ) : null} +
+
+ {closeable ? ( + - ) : null} -
+ + + ) : null}
diff --git a/packages/gitbook/src/components/Footer/Footer.tsx b/packages/gitbook/src/components/Footer/Footer.tsx index 31c2c5fd59..8deba384eb 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 abc24f53f8..763c82792f 100644 --- a/packages/gitbook/src/components/Header/Header.tsx +++ b/packages/gitbook/src/components/Header/Header.tsx @@ -56,136 +56,132 @@ export function Header(props: { 'theme-bold:shadow-tint-12/2' )} > -
-
+
+
-
- - -
- -
- {search} -
+ /> + +
- {customization.header.links.length > 0 && ( - - {customization.header.links.map((link) => { - return ( - - ); - })} - - +
+ {search}
+ + {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 9bff7fc6c0..cb94319990 100644 --- a/packages/gitbook/src/components/RootLayout/globals.css +++ b/packages/gitbook/src/components/RootLayout/globals.css @@ -4,9 +4,12 @@ @layer base { :root { - --scrollbar-width: calc(100vw - 100%); @apply leading-relaxed; } + * { + scrollbar-color: theme("colors.tint.7") theme("colors.tint.2"); + scrollbar-width: thin; + } body { @apply text-tint-strong antialiased; } @@ -37,22 +40,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 [&:is(h1,h2,h3,h4)]:flex-row-reverse; @apply [&:is(h1,h2,h3,h4)]:[justify-content:start]; @@ -118,23 +105,6 @@ @apply bg-gradient-to-bl from-tint-4 to-tint-base to-60% bg-fixed; } - /** - * 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" - */ - .scroll-nojump { - width: 100%; - } - @media screen and (min-width: 1536px) { - .scroll-nojump { - margin-left: var(--scrollbar-width); - margin-right: 0; - width: calc(100% - var(--scrollbar-width)); - } - } - .elevate-link { & a[href]:not(.link-overlay) { position: relative; diff --git a/packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx b/packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx index f57aec64cd..095a5febad 100644 --- a/packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx +++ b/packages/gitbook/src/components/SpaceLayout/SpaceLayout.tsx @@ -89,70 +89,69 @@ export function SpaceLayout(props: { {aiMode === 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 && searchAndAI} + {!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 && searchAndAI} - {!withTopHeader && withSections && sections && ( - - )} - {isMultiVariants && !sections && ( - - )} - - } - /> -
{children}
-
+ /> + )} + + } + /> +
{children}