-
Notifications
You must be signed in to change notification settings - Fork 78
Migrate onto the Moderne design system and rework the header #538
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
82a883f
feat(design): migrate onto the Moderne design system and rework the h…
zieka 73df896
fix(design): space the header row and pin card-hover text on mint
zieka bb94b12
feat(nav): rework sections, add a Releases menu, and restyle the land…
zieka 942958d
feat(footer): one row of links with social, replacing the stacked def…
zieka b8edbb5
fix(footer): point YouTube at the Moderne and OpenRewrite channel
zieka de220aa
fix(footer): drop Terms and Privacy
zieka 289bebf
fix(sidebar): drop the duplicated navbar offset above the first item
zieka a8fe61e
fix(design): drop the category-page backdrop, breadcrumb pill and pag…
zieka 27a22b5
feat(search): bind DocSearch to design-system tokens
zieka 778b01c
fix(design): bump tokens to 7.4.0, share the chevron, pin the table o…
zieka ab43a68
fix(design): stack admonitions, and resolve sections from the sidebar…
zieka 7fe9b59
feat(design): capitalise the generic admonition labels
zieka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,110 @@ | ||
| /** | ||
| * Section navigation, below the primary navbar. Desktop only: on mobile the | ||
| * sidebar still lists every section, so this bar would only repeat it. | ||
| */ | ||
|
|
||
| .secondaryNav { | ||
| display: none; | ||
| height: var(--ifm-secondary-nav-height); | ||
| padding: 0 var(--mod-spacing_4); | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| /* Hairline that defines the header's lower edge. */ | ||
| border-bottom: 1px solid var(--mod-color-border-primary); | ||
| } | ||
|
|
||
| @media (min-width: 997px) { | ||
| .secondaryNav { | ||
| display: flex; | ||
| } | ||
| } | ||
|
|
||
| .sections { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: var(--mod-spacing_3); | ||
| min-width: 0; | ||
| } | ||
|
|
||
| .section { | ||
| font-size: var(--mod-font-size-default); | ||
| font-weight: var(--mod-font-weight-medium); | ||
| color: var(--mod-color-text-primary); | ||
| text-decoration: none; | ||
| white-space: nowrap; | ||
| transition: color 0.2s ease; | ||
| } | ||
|
|
||
| .section:hover { | ||
| color: var(--mod-color-action-default); | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| /* Both active states take the same colour; custom.css owns the light/dark pair. */ | ||
| .sectionActive, | ||
| .sectionActive:hover, | ||
| .dropdownItemActive, | ||
| .dropdownItemActive:hover { | ||
| color: var(--docs-color-active); | ||
| } | ||
|
|
||
| .menu { | ||
| position: relative; | ||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| .menuButton { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: var(--mod-spacing_1_2); | ||
| padding: var(--mod-spacing_1) 0; | ||
| background: transparent; | ||
| border: none; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| /* One definition of this glyph, shared with the sidebar caret in custom.css. | ||
| background-color + mask means it follows currentColor like an inline SVG. */ | ||
| .chevron { | ||
| width: 10px; | ||
| height: 6px; | ||
| flex-shrink: 0; | ||
| background-color: currentColor; | ||
| mask-image: var(--docs-chevron-down); | ||
| mask-repeat: no-repeat; | ||
| mask-size: contain; | ||
| mask-position: center; | ||
| transition: transform 0.2s ease; | ||
| } | ||
|
|
||
| .chevronOpen { | ||
| transform: rotate(180deg); | ||
| } | ||
|
|
||
| .dropdown { | ||
| position: absolute; | ||
| top: 100%; | ||
| right: 0; | ||
| min-width: 200px; | ||
| padding: var(--mod-spacing_1) 0; | ||
| background-color: var(--mod-color-surface-raised); | ||
| border: 1px solid var(--mod-color-border-primary); | ||
| border-radius: var(--mod-border-radius-input); | ||
| box-shadow: var(--docs-shadow-dropdown); | ||
| z-index: var(--ifm-z-index-dropdown); | ||
| } | ||
|
|
||
| .dropdownItem { | ||
| display: block; | ||
| padding: var(--mod-spacing_1) var(--mod-spacing_2); | ||
| font-size: var(--mod-font-size-default); | ||
| color: var(--mod-color-text-primary); | ||
| text-decoration: none; | ||
| white-space: nowrap; | ||
| } | ||
|
|
||
| .dropdownItem:hover { | ||
| background-color: var(--mod-color-surface-row-hover); | ||
| color: var(--mod-color-text-primary); | ||
| text-decoration: none; | ||
| } | ||
This file contains hidden or 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,126 @@ | ||
| import Link from '@docusaurus/Link'; | ||
| import { useLocation } from '@docusaurus/router'; | ||
| import clsx from 'clsx'; | ||
| import { type FunctionComponent, useCallback, useEffect, useRef, useState } from 'react'; | ||
| import type { NavSection } from '@site/src/config/navSections'; | ||
| import { findSection } from '@site/src/theme/DocSidebarItems/filterUtils'; | ||
| import styles from './SecondaryNav.module.css'; | ||
|
|
||
| export type SecondaryNavProps = { | ||
| /** Sections rendered as direct links, left-aligned. */ | ||
| sections: NavSection[]; | ||
| /** Label for the right-aligned dropdown. */ | ||
| menuLabel: string; | ||
| /** Items inside that dropdown. */ | ||
| menuItems: NavSection[]; | ||
| }; | ||
|
|
||
| /** Chevron for the dropdown. Masked from --docs-chevron-down rather than | ||
| * inlined, so this glyph has one definition shared with the sidebar caret. The | ||
| * mask takes its colour from currentColor, as an inline SVG would. */ | ||
| const Chevron: FunctionComponent<{ open: boolean }> = ({ open }) => ( | ||
| <span className={clsx(styles.chevron, open && styles.chevronOpen)} aria-hidden="true" /> | ||
| ); | ||
|
Comment on lines
+21
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wasn't the chevron also inlined as a data+svg in custom.css? |
||
|
|
||
| /** | ||
| * Section navigation, shown below the primary navbar on desktop. | ||
| * | ||
| * Picks the section; the sidebar then shows that section's contents (see | ||
| * src/theme/DocSidebarItems, which scopes on desktop only). Hidden below 997px, | ||
| * where the drawer keeps every section and this bar would duplicate it. | ||
| */ | ||
| export const SecondaryNav: FunctionComponent<SecondaryNavProps> = ({ | ||
| sections, | ||
| menuLabel, | ||
| menuItems, | ||
| }) => { | ||
| const [open, setOpen] = useState(false); | ||
| const menuRef = useRef<HTMLDivElement>(null); | ||
| const location = useLocation(); | ||
|
|
||
| // Same matcher the sidebar filter uses, so the highlighted section and the | ||
| // scoped sidebar can never disagree. | ||
| const activeHref = findSection(location.pathname)?.href; | ||
| const isMenuActive = menuItems.some((item) => item.href === activeHref); | ||
|
|
||
| const close = useCallback(() => setOpen(false), []); | ||
|
|
||
| // Close on outside click and on Escape, so the menu never outlives its context. | ||
| useEffect(() => { | ||
| if (!open) { | ||
| return; | ||
| } | ||
| // mousedown + touchstart + focusin is the set theme-classic's own | ||
| // DropdownNavbarItem listens on; mousedown alone leaves the menu open on a | ||
| // touch tap and when focus moves away by keyboard. | ||
| const onOutside = (event: MouseEvent | TouchEvent | FocusEvent) => { | ||
| if (menuRef.current && !menuRef.current.contains(event.target as Node)) { | ||
| close(); | ||
| } | ||
| }; | ||
| const onKeyDown = (event: KeyboardEvent) => { | ||
| if (event.key === 'Escape') { | ||
| close(); | ||
| } | ||
| }; | ||
| const events = ['mousedown', 'touchstart', 'focusin'] as const; | ||
| events.forEach((name) => document.addEventListener(name, onOutside)); | ||
| document.addEventListener('keydown', onKeyDown); | ||
| return () => { | ||
| events.forEach((name) => document.removeEventListener(name, onOutside)); | ||
| document.removeEventListener('keydown', onKeyDown); | ||
| }; | ||
| }, [open, close]); | ||
|
|
||
| // A route change means the menu's job is done. | ||
| useEffect(close, [location.pathname, close]); | ||
|
|
||
| return ( | ||
| <nav className={styles.secondaryNav} aria-label="Documentation sections"> | ||
| <div className={styles.sections}> | ||
| {sections.map((section) => { | ||
| const active = section.href === activeHref; | ||
| return ( | ||
| <Link | ||
| key={section.href} | ||
| to={section.href} | ||
| className={clsx(styles.section, active && styles.sectionActive)} | ||
| aria-current={active ? 'page' : undefined} | ||
| > | ||
| {section.name} | ||
| </Link> | ||
| ); | ||
| })} | ||
| </div> | ||
|
|
||
| <div className={styles.menu} ref={menuRef}> | ||
| <button | ||
| type="button" | ||
| className={clsx(styles.section, styles.menuButton, isMenuActive && styles.sectionActive)} | ||
| onClick={() => setOpen((prev) => !prev)} | ||
| aria-expanded={open} | ||
| aria-haspopup="true" | ||
| > | ||
| {menuLabel} | ||
| <Chevron open={open} /> | ||
| </button> | ||
| {open && ( | ||
| <div className={styles.dropdown} role="menu"> | ||
| {menuItems.map((item) => ( | ||
| <Link | ||
| key={item.href} | ||
| to={item.href} | ||
| className={clsx(styles.dropdownItem, item.href === activeHref && styles.dropdownItemActive)} | ||
| role="menuitem" | ||
| > | ||
| {item.name} | ||
| </Link> | ||
| ))} | ||
| </div> | ||
| )} | ||
| </div> | ||
| </nav> | ||
| ); | ||
| }; | ||
|
|
||
| SecondaryNav.displayName = 'SecondaryNav'; | ||
This file contains hidden or 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,2 @@ | ||
| export { SecondaryNav } from './SecondaryNav'; | ||
| export type { SecondaryNavProps } from './SecondaryNav'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit i think we have a breakpoint design token?