-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
41684d0
commit 5fe7adb
Showing
12 changed files
with
130 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'gitbook': patch | ||
--- | ||
|
||
RND-3532: drop down menu for hidden links at small screen size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { CustomizationHeaderLink } from '@gitbook/api'; | ||
import React from 'react'; | ||
|
||
import { ContentRefContext, resolveContentRef } from '@/lib/references'; | ||
|
||
import { Dropdown, DropdownChevron, DropdownMenu, DropdownMenuItem } from './Dropdown'; | ||
import styles from './headerLinks.module.css'; | ||
|
||
/** | ||
* Dropdown menu for header links hidden at small screen size. | ||
*/ | ||
export function HeaderLinkMore(props: { | ||
label: React.ReactNode; | ||
links: CustomizationHeaderLink[]; | ||
context: ContentRefContext; | ||
}) { | ||
const { label, links, context } = props; | ||
|
||
const renderButton = () => ( | ||
<button className="px-1"> | ||
<span className="sr-only">{label}</span> | ||
<DropdownChevron /> | ||
</button> | ||
); | ||
|
||
return ( | ||
<div className={`${styles.linkEllipsis} items-center`}> | ||
<Dropdown button={renderButton} className="-translate-x-48 md:translate-x-0"> | ||
<DropdownMenu> | ||
{links.map((link, index) => ( | ||
<MoreMenuLink key={index} link={link} context={context} /> | ||
))} | ||
</DropdownMenu> | ||
</Dropdown> | ||
</div> | ||
); | ||
} | ||
|
||
async function MoreMenuLink(props: { context: ContentRefContext; link: CustomizationHeaderLink }) { | ||
const { context, link } = props; | ||
|
||
const target = await resolveContentRef(link.to, context); | ||
|
||
if (!target) { | ||
return null; | ||
} | ||
|
||
return <DropdownMenuItem href={target.href}>{link.title}</DropdownMenuItem>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters