Skip to content
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

feat(theme-classic): allow stylizing doc paginator arrows #6053

Merged
merged 6 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"clsx": "^1.1.1",
"copy-text-to-clipboard": "^3.0.1",
"globby": "^11.0.2",
"infima": "0.2.0-alpha.36",
"infima": "0.2.0-alpha.37",
"lodash": "^4.17.20",
"postcss": "^8.3.7",
"prism-react-renderer": "^1.2.1",
Expand Down
17 changes: 13 additions & 4 deletions packages/docusaurus-theme-classic/src/theme-classic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,22 @@ declare module '@theme/CodeBlock' {
declare module '@theme/DocPaginator' {
import type {PropNavigation} from '@docusaurus/plugin-content-docs';

type PageInfo = {readonly permalink: string; readonly title: string};

// May be simpler to provide a {navigation: PropNavigation} prop?
export interface Props extends PropNavigation {}

const DocPaginator: (props: Props) => JSX.Element;
export default DocPaginator;
export default function DocPaginator(props: Props): JSX.Element;
}

declare module '@theme/DocPaginatorNavLink' {
import type {PropNavigationLink} from '@docusaurus/plugin-content-docs';

// May be simpler to provide a {navigation: PropNavigation} prop?
export interface Props {
navLink: PropNavigationLink;
next?: boolean;
}

export default function DocPaginatorNavLink(props: Props): JSX.Element;
}

declare module '@theme/DocSidebar' {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

import React from 'react';
import Link from '@docusaurus/Link';
import Translate, {translate} from '@docusaurus/Translate';
import type {PropNavigation} from '@docusaurus/plugin-content-docs';
import {translate} from '@docusaurus/Translate';
import DocPaginatorNavLink from '@theme/DocPaginatorNavLink';
import type {Props} from '@theme/DocPaginator';

function DocPaginator(props: PropNavigation): JSX.Element {
function DocPaginator(props: Props): JSX.Element {
const {previous, next} = props;

return (
Expand All @@ -22,34 +22,10 @@ function DocPaginator(props: PropNavigation): JSX.Element {
description: 'The ARIA label for the docs pagination',
})}>
<div className="pagination-nav__item">
{previous && (
<Link className="pagination-nav__link" to={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">
&laquo; {previous.title}
</div>
</Link>
)}
{previous && <DocPaginatorNavLink navLink={previous} />}
</div>
<div className="pagination-nav__item pagination-nav__item--next">
{next && (
<Link className="pagination-nav__link" to={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} &raquo;</div>
</Link>
)}
{next && <DocPaginatorNavLink navLink={next} next />}
</div>
</nav>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import clsx from 'clsx';
import Link from '@docusaurus/Link';
import Translate from '@docusaurus/Translate';
import type {Props} from '@theme/DocPaginatorNavLink';

function DocPaginatorNavLink(props: Props): JSX.Element {
const {navLink, next} = props;
return (
<Link className={clsx('pagination-nav__link')} to={navLink.permalink}>
<div className="pagination-nav__sublabel">
{next ? (
<Translate
id="theme.docs.paginator.next"
description="The label used to navigate to the next doc">
Next
</Translate>
) : (
<Translate
id="theme.docs.paginator.previous"
description="The label used to navigate to the previous doc">
Previous
</Translate>
)}
</div>
<div className="pagination-nav__label">{navLink.title}</div>
</Link>
);
}

export default DocPaginatorNavLink;
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10645,10 +10645,10 @@ infer-owner@^1.0.3, infer-owner@^1.0.4:
resolved "https://registry.yarnpkg.com/infer-owner/-/infer-owner-1.0.4.tgz#c4cefcaa8e51051c2a40ba2ce8a3d27295af9467"
integrity sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==

infima@0.2.0-alpha.36:
version "0.2.0-alpha.36"
resolved "https://registry.yarnpkg.com/infima/-/infima-0.2.0-alpha.36.tgz#205515680e2dc588ec1a07b6ce108e49b29cc810"
integrity sha512-tlhQa7S09+QzQs8hCZ9oBeD6xOFap1f2zDO4I5HRZ4SMFKKGk9sIhwaou1FWpYoqM6aaoK2YN+G1fND+Sad1Qw==
infima@0.2.0-alpha.37:
version "0.2.0-alpha.37"
resolved "https://registry.yarnpkg.com/infima/-/infima-0.2.0-alpha.37.tgz#b87ff42d528d6d050098a560f0294fbdd12adb78"
integrity sha512-4GX7Baw+/lwS4PPW/UJNY89tWSvYG1DL6baKVdpK6mC593iRgMssxNtORMTFArLPJ/A/lzsGhRmx+z6MaMxj0Q==

inflight@^1.0.4:
version "1.0.6"
Expand Down