Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase search bar size on sites with few header links #2766

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Header links and search button styling
  • Loading branch information
zenoachtig committed Jan 23, 2025
commit 3c21a5e8202a486e5af4c873d09226694a118eea
17 changes: 12 additions & 5 deletions packages/gitbook/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -37,6 +37,8 @@ export function Header(props: {
const hasSiteSections = sections && sections.list.length > 1;
const isMultiVariants = site && spaces.length > 1;

// customization.header.links = customization.header.links.slice(0,4);

return (
<header
className={tcls(
@@ -54,7 +56,7 @@ export function Header(props: {
'dark:bg-dark',
withTopHeader ? null : 'lg:hidden',
'text-sm',
'bg-opacity-8',
'bg-opacity-9',
'dark:bg-opacity-9',
'backdrop-blur-lg',
'contrast-more:bg-opacity-11',
@@ -75,7 +77,7 @@ export function Header(props: {
<div
className={tcls(
'gap-4',
'lg:gap-8',
'lg:gap-6',
'flex',
'items-center',
'justify-between',
@@ -121,11 +123,12 @@ export function Header(props: {
MAX_HEADER_LINKS_FOR_BIG_SEARCHBAR
? [
'lg:grow',
'lg:min-w-40',
'max-w-lg',
'lg:ml-[max(calc((100%-18rem-48rem-4rem)/2),1rem)]',
'xl:ml-[max(calc((100%-18rem-48rem-14rem-4rem)/2),1rem)]',
'lg:ml-[max(calc((100%-18rem-48rem-3rem)/2),1.5rem)]',
'xl:ml-[max(calc((100%-18rem-48rem-14rem-3rem)/2),1.5rem)]',
'lg:mr-auto',
'page-no-toc:lg:ml-[max(calc((100%-18rem-48rem-18rem-4rem)/2),1rem)]',
'page-no-toc:lg:ml-[max(calc((100%-18rem-48rem-18rem-3rem)/2),1.5rem)]',
'order-last',
'lg:order-[unset]',
]
@@ -170,7 +173,9 @@ export function Header(props: {
'text-header-link/8',
'dark:text-header-link/8',
'hover:text-header-link',
'focus:text-header-link',
'dark:hover:text-header-link',
'dark:focus:text-header-link',

'ring-header-link/4',
'dark:ring-header-link/4',
@@ -180,7 +185,9 @@ export function Header(props: {
'[&_svg]:text-header-link/10',
'dark:[&_svg]:text-header-link/10',
'[&_.shortcut]:text-header-link/8',
'[&_.shortcut_kbd]:border-header-link/2',
'dark:[&_.shortcut]:text-header-link/8',
'dark:[&_.shortcut_kbd]:border-header-link/2',

'contrast-more:bg-header-background',
'contrast-more:text-header-link',
6 changes: 3 additions & 3 deletions packages/gitbook/src/components/Header/HeaderLink.tsx
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ export async function HeaderLink(props: {
if (link.links && link.links.length > 0) {
return (
<Dropdown
className="shrink"
className="shrink left-auto right-0"
button={(buttonProps) => {
if (!target || !link.to) {
return (
@@ -59,7 +59,7 @@ export async function HeaderLink(props: {
);
}}
>
<DropdownMenu>
<DropdownMenu >
{link.links.map((subLink, index) => (
<SubHeaderLink key={index} {...props} link={subLink} />
))}
@@ -159,7 +159,7 @@ function getHeaderLinkClassName(props: { headerPreset: CustomizationHeaderPreset
return tcls(
'flex items-center shrink',
'hover:text-header-link-400 dark:hover:text-light',
'min-w-0',
'min-w-0 hover:min-w-max',
'contrast-more:underline',

props.headerPreset === CustomizationHeaderPreset.Default
2 changes: 1 addition & 1 deletion packages/gitbook/src/components/Header/HeaderLinkMore.tsx
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ export function HeaderLinkMore(props: {

return (
<div className={`${styles.linkEllipsis} items-center z-20`}>
<Dropdown button={renderButton} className="-translate-x-48 md:translate-x-0">
<Dropdown button={renderButton} className="left-auto right-0 md:right-auto md:left-0">
<DropdownMenu>
{links.map((link, index) => (
<MoreMenuLink key={index} link={link} context={context} />
72 changes: 68 additions & 4 deletions packages/gitbook/src/components/Header/headerLinks.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
.containerHeaderlinks {
container-type: inline-size;
container-name: headerlinks;
}


.linkEllipsis {
display: none;
@@ -10,6 +7,73 @@
}
}

@media(max-width:1023px) {
.containerHeaderlinks {
container-type: inline-size;
container-name: headerlinks;
}
}

@media(max-width:1279px) {
.containerHeaderlinks > :nth-child(n + 5) {
display: none;
}
.containerHeaderlinks > :nth-child(n + 5) ~ .linkEllipsis {
display: flex;
& div > a:nth-of-type(n + 6) {
display: flex;
}
}
}

@media (max-width: 1535px) {
.containerHeaderlinks > :nth-child(n + 6) {
display: none;
}
.containerHeaderlinks > :nth-child(n + 6) ~ .linkEllipsis {
display: flex;
& div > a:nth-of-type(n + 6) {
display: flex;
}
}
}

/* @media (max-width: 1024px) {
.containerHeaderlinks > :nth-child(n + 4) {
display: none;
}
.containerHeaderlinks > :nth-child(n + 4) ~ .linkEllipsis {
display: flex;
& div > a:nth-of-type(n + 4) {
display: flex;
}
}
}

@media (max-width: 1280px) {
.containerHeaderlinks > :nth-child(n + 5) {
display: none;
}
.containerHeaderlinks > :nth-child(n + 5) ~ .linkEllipsis {
display: flex;
& div > a:nth-of-type(n + 5) {
display: flex;
}
}
}

@media (max-width: 1536px) {
.containerHeaderlinks > :nth-child(n + 6) {
display: none;
}
.containerHeaderlinks > :nth-child(n + 6) ~ .linkEllipsis {
display: flex;
& div > a:nth-of-type(n + 6) {
display: flex;
}
}
} */

@container headerlinks ( width < 150px ) {
.containerHeaderlinks > :nth-child(n + 1) {
display: none;
14 changes: 12 additions & 2 deletions packages/gitbook/src/components/Search/SearchButton.tsx
Original file line number Diff line number Diff line change
@@ -131,18 +131,28 @@ const Shortcut = () => {
className={tcls(
'shortcut',
'hidden',
'md:inline',
'md:flex',
'justify-end',
'text-xs',
'font-mono',
'text-dark/7',
'leading-none',
'contrast-more:text-dark',
'dark:text-light-4/7',
'contrast-more:dark:text-light',
'whitespace-nowrap',
`[font-feature-settings:"calt",_"case"]`,
'gap-0.5',
'shrink-0',
'-mr-1',
)}
>
{operatingSystem === 'mac' ? '⌘' : 'Ctrl +'} K
<kbd
className={`rounded border border-dark/2 dark:border-light/2 px-1 min-w-5 h-5 flex justify-center items-center ${operatingSystem === 'mac' ? 'text-sm' : ''}`}
>
{operatingSystem === 'mac' ? '⌘' : 'Ctrl'}
</kbd>
<kbd className="rounded border border-dark/2 dark:border-light/2 size-5 flex justify-center items-center">K</kbd>
</div>
);
};