-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
packages/docusaurus-theme/src/theme/DocPaginator/index.tsx
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,55 @@ | ||
import { css } from '@emotion/react'; | ||
import Translate, { translate } from '@docusaurus/Translate'; | ||
import PaginatorNavLink from '@theme-original/PaginatorNavLink'; | ||
import type { Props } from '@theme-original/DocPaginator'; | ||
|
||
const styles = { | ||
pagination: css` | ||
// docusaurus reset, we add spacing via the | ||
// horizontal rule in Layout instead | ||
margin-top: 0; | ||
`, | ||
}; | ||
|
||
export default function DocPaginator(props: Props): JSX.Element { | ||
const { previous, next } = props; | ||
return ( | ||
<nav | ||
className="pagination-nav docusaurus-mt-lg" | ||
css={styles.pagination} | ||
aria-label={translate({ | ||
id: 'theme.docs.paginator.navAriaLabel', | ||
message: 'Docs pages', | ||
description: 'The ARIA label for the docs pagination', | ||
})} | ||
> | ||
{previous && ( | ||
<PaginatorNavLink | ||
{...previous} | ||
subLabel={ | ||
<Translate | ||
id="theme.docs.paginator.previous" | ||
description="The label used to navigate to the previous doc" | ||
> | ||
Previous | ||
</Translate> | ||
} | ||
/> | ||
)} | ||
{next && ( | ||
<PaginatorNavLink | ||
{...next} | ||
subLabel={ | ||
<Translate | ||
id="theme.docs.paginator.next" | ||
description="The label used to navigate to the next doc" | ||
> | ||
Next | ||
</Translate> | ||
} | ||
isNext | ||
/> | ||
)} | ||
</nav> | ||
); | ||
} |
63 changes: 63 additions & 0 deletions
63
packages/docusaurus-theme/src/theme/PaginatorNavLink/index.tsx
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,63 @@ | ||
import clsx from 'clsx'; | ||
import { css } from '@emotion/react'; | ||
import Link from '@docusaurus/Link'; | ||
import type { Props } from '@theme-original/PaginatorNavLink'; | ||
import { useEuiMemoizedStyles, UseEuiTheme, EuiIcon } from '@elastic/eui'; | ||
|
||
const getStyles = ({ euiTheme }: UseEuiTheme) => { | ||
return { | ||
link: css` | ||
--ifm-pagination-nav-color-hover: ${euiTheme.colors.primary}; | ||
border: ${euiTheme.border.thin}; | ||
.pagination-nav__label { | ||
display: flex; | ||
align-items: center; | ||
font-size: var(--eui-font-size-m); | ||
line-height: var(--eui-line-height-l); | ||
} | ||
&.pagination-nav__link--next .pagination-nav__label { | ||
justify-content: flex-end; | ||
} | ||
.pagination-nav__label::before, | ||
.pagination-nav__label::after { | ||
content: ''; | ||
} | ||
.pagination-nav__sublabel { | ||
margin-block-end: ${euiTheme.size.xs}; | ||
font-size: var(--eui-font-size-s); | ||
line-height: var(--eui-line-height-l); | ||
} | ||
`, | ||
}; | ||
}; | ||
|
||
export default function PaginatorNavLink(props: Props): JSX.Element { | ||
const { permalink, title, subLabel, isNext } = props; | ||
const isPrev = !isNext; | ||
const styles = useEuiMemoizedStyles(getStyles); | ||
|
||
return ( | ||
<Link | ||
className={clsx( | ||
'pagination-nav__link', | ||
isNext ? 'pagination-nav__link--next' : 'pagination-nav__link--prev' | ||
)} | ||
css={styles.link} | ||
to={permalink} | ||
> | ||
{subLabel && <div className="pagination-nav__sublabel">{subLabel}</div>} | ||
|
||
<div className="pagination-nav__label"> | ||
{isPrev && <EuiIcon type="arrowLeft" />} | ||
{title} | ||
{isNext && <EuiIcon type="arrowRight" />} | ||
</div> | ||
</Link> | ||
); | ||
} |