forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sidebar refactor: scope css + more (github#20837)
* refactor sidebar, scope css, wire up nav events to link component, update tests * remove link onClick analytics event * fix: missing key on breadcrumbs
- Loading branch information
1 parent
76dc14a
commit c433c43
Showing
14 changed files
with
218 additions
and
335 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
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 was deleted.
Oops, something went wrong.
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
File renamed without changes.
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,53 @@ | ||
import { useRouter } from 'next/router' | ||
import { LinkExternalIcon } from '@primer/octicons-react' | ||
|
||
import { useVersion } from 'components/hooks/useVersion' | ||
import { useMainContext } from 'components/context/MainContext' | ||
import { Link } from 'components/Link' | ||
|
||
import { AllProductsLink } from './AllProductsLink' | ||
|
||
export const SidebarHomepage = () => { | ||
const router = useRouter() | ||
const { currentVersion } = useVersion() | ||
const { activeProducts, isFPT } = useMainContext() | ||
|
||
return ( | ||
<ul data-testid="sidebar" className="mt-4"> | ||
{!isFPT && <AllProductsLink />} | ||
|
||
{activeProducts.map((product) => { | ||
if (!isFPT && !product.versions?.includes(currentVersion) && !product.external) { | ||
return null | ||
} | ||
|
||
const href = `${!product.external ? `/${router.locale}` : ''}${ | ||
product.versions?.includes(currentVersion) && !isFPT | ||
? `/${currentVersion}/${product.id}` | ||
: product.href | ||
}` | ||
|
||
return ( | ||
<li | ||
key={product.id} | ||
title={`${product.name}${product.external ? '(External Site)' : ''}`} | ||
className="my-3" | ||
> | ||
<Link | ||
href={href} | ||
target={product.external ? '_blank' : undefined} | ||
className="f4 pl-4 pr-5 py-2 color-text-primary no-underline" | ||
> | ||
{product.name} | ||
{product.external && ( | ||
<span className="ml-1"> | ||
<LinkExternalIcon size="small" /> | ||
</span> | ||
)} | ||
</Link> | ||
</li> | ||
) | ||
})} | ||
</ul> | ||
) | ||
} |
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,46 @@ | ||
import { useRouter } from 'next/router' | ||
import { MarkGithubIcon } from '@primer/octicons-react' | ||
|
||
import { Link } from 'components/Link' | ||
import { useTranslation } from 'components/hooks/useTranslation' | ||
import { useMainContext } from 'components/context/MainContext' | ||
import { SidebarProduct } from './SidebarProduct' | ||
import { SidebarHomepage } from './SidebarHomepage' | ||
|
||
export const SidebarNav = () => { | ||
const router = useRouter() | ||
const { error, relativePath } = useMainContext() | ||
const { t } = useTranslation('header') | ||
|
||
return ( | ||
<div | ||
className="d-none d-lg-block color-bg-tertiary position-sticky top-0 overflow-y-auto flex-shrink-0 pb-5" | ||
style={{ width: 286, height: '100vh' }} | ||
> | ||
<div | ||
className="d-flex flex-items-center p-4 position-sticky top-0 color-bg-tertiary" | ||
style={{ zIndex: 3 }} | ||
id="github-logo" | ||
role="banner" | ||
> | ||
<Link | ||
href={`/${router.locale}`} | ||
className="color-text-primary" | ||
aria-hidden="true" | ||
tabIndex={-1} | ||
> | ||
<MarkGithubIcon size={32} /> | ||
</Link> | ||
<Link | ||
href={`/${router.locale}`} | ||
className="h4-mktg color-text-primary no-underline no-wrap pl-2 flex-auto" | ||
> | ||
{t('github_docs')} | ||
</Link> | ||
</div> | ||
<nav> | ||
{error === '404' || relativePath === 'index.md' ? <SidebarHomepage /> : <SidebarProduct />} | ||
</nav> | ||
</div> | ||
) | ||
} |
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,13 @@ | ||
.sidebarArticle::before { | ||
content: ""; | ||
position: absolute; | ||
left: 26px; | ||
height: 100%; | ||
border-left: 1px solid var(--color-text-primary); | ||
width: 1px; | ||
top: 0; | ||
} | ||
|
||
.sidebarArticleActive::before { | ||
border-left-width: 2px; | ||
} |
Oops, something went wrong.