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; 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 { .navbar-icon:before {
background-repeat: no-repeat; background-repeat: no-repeat;
content: ''; content: '';

View File

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

View File

@ -6,10 +6,15 @@
*/ */
import React from 'react'; import React from 'react';
import Translate, {translate} from '@docusaurus/Translate'; import Translate, {translate} from '@docusaurus/Translate';
import PaginatorNavLink from '@theme/PaginatorNavLink';
function DocPaginator(props) {
const {
// previous,
next,
} = props;
function DocPaginator({previous, next}) {
return ( return (
<>
<nav <nav
className="pagination-nav docusaurus-mt-lg" className="pagination-nav docusaurus-mt-lg"
aria-label={translate({ aria-label={translate({
@ -18,31 +23,18 @@ function DocPaginator({previous, next}) {
description: 'The ARIA label for the docs pagination', description: 'The ARIA label for the docs pagination',
})}> })}>
<div className="pagination-nav__item"> <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 && ( {next && (
<a className="pagination-nav__link" href={next.permalink}> <PaginatorNavLink
<div className="pagination-nav__sublabel"> hasArrow={true}
{...next}
subLabel={
<Translate <Translate
id="theme.docs.paginator.next" id="theme.docs.paginator.next"
description="The label used to navigate to the next doc"> description="The label used to navigate to the next doc">
Next Next page
</Translate> </Translate>
</div> }
<div className="pagination-nav__label">{next.title}</div> />
</a>
)} )}
</div> </div>
</nav> </nav>

View File

@ -1,10 +1,14 @@
import React from 'react'; 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 ( 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>} {subLabel && <div className="pagination-nav__sublabel">{subLabel}</div>}
<div className="pagination-nav__label">{title}</div> <div className="pagination-nav__label">{title}</div>
{hasArrow && <span className={styles.arrow}></span>}
</a> </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;
}