website: improve doc nav links UX (?)

This commit is contained in:
Yangshun
2022-02-02 17:51:15 +08:00
parent cb182619de
commit ccaf0c1066
5 changed files with 60 additions and 42 deletions

View File

@ -62,6 +62,15 @@ div[class^='announcementBar_'] {
margin-bottom: 0 !important;
}
.pagination-nav__item:first-child .pagination-nav__label::before,
.pagination-nav__item--next .pagination-nav__label::after {
content: '';
}
.pagination-nav__item .pagination-nav__label {
font-size: 1.5rem;
}
.navbar-icon:before {
background-repeat: no-repeat;
content: '';

View File

@ -80,10 +80,10 @@ export default function DocItem(props) {
</header>
)}
<DocItemFooter {...props} />
<br />
<DocContent />
</div>
<DocItemFooter {...props} />
</article>
<DocPaginator previous={metadata.previous} next={metadata.next} />
<div className="margin-top--md">

View File

@ -6,46 +6,38 @@
*/
import React from 'react';
import Translate, {translate} from '@docusaurus/Translate';
import PaginatorNavLink from '@theme/PaginatorNavLink';
function DocPaginator(props) {
const {
// previous,
next,
} = props;
function DocPaginator({previous, next}) {
return (
<>
<nav
className="pagination-nav docusaurus-mt-lg"
aria-label={translate({
id: 'theme.docs.paginator.navAriaLabel',
message: 'Docs pages navigation',
description: 'The ARIA label for the docs pagination',
})}>
<div className="pagination-nav__item">
{previous && (
<a className="pagination-nav__link" href={previous.permalink}>
<div className="pagination-nav__sublabel">
<Translate
id="theme.docs.paginator.previous"
description="The label used to navigate to the previous doc">
Previous
</Translate>
</div>
<div className="pagination-nav__label">{previous.title}</div>
</a>
)}
</div>
<div className="pagination-nav__item pagination-nav__item--next">
{next && (
<a className="pagination-nav__link" href={next.permalink}>
<div className="pagination-nav__sublabel">
<Translate
id="theme.docs.paginator.next"
description="The label used to navigate to the next doc">
Next
</Translate>
</div>
<div className="pagination-nav__label">{next.title}</div>
</a>
)}
</div>
</nav>
<nav
className="pagination-nav docusaurus-mt-lg"
aria-label={translate({
id: 'theme.docs.paginator.navAriaLabel',
message: 'Docs pages navigation',
description: 'The ARIA label for the docs pagination',
})}>
<div className="pagination-nav__item">
{next && (
<PaginatorNavLink
hasArrow={true}
{...next}
subLabel={
<Translate
id="theme.docs.paginator.next"
description="The label used to navigate to the next doc">
Next page
</Translate>
}
/>
)}
</div>
</nav>
);
}

View File

@ -1,10 +1,14 @@
import React from 'react';
import clsx from 'clsx';
import styles from './styles.module.css';
function PaginatorNavLink({permalink, title, subLabel}) {
function PaginatorNavLink({hasArrow, permalink, title, subLabel, ...rest}) {
console.log(rest);
return (
<a className="pagination-nav__link" href={permalink}>
<a className={clsx('pagination-nav__link', styles.root)} href={permalink}>
{subLabel && <div className="pagination-nav__sublabel">{subLabel}</div>}
<div className="pagination-nav__label">{title}</div>
{hasArrow && <span className={styles.arrow}></span>}
</a>
);
}

View File

@ -0,0 +1,13 @@
.root {
position: relative;
}
.arrow {
font-weight: bold;
font-size: 2rem;
float: right;
transform: scale(2);
position: absolute;
right: 1.5rem;
top: 1rem;
}