Skip to content

Commit

Permalink
styling breadcrumbs and toc
Browse files Browse the repository at this point in the history
  • Loading branch information
nahbee10 committed Nov 12, 2024
1 parent 9b2b4ea commit 30d2966
Show file tree
Hide file tree
Showing 29 changed files with 618 additions and 20 deletions.
1 change: 1 addition & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ module.exports = {
require.resolve('./src/css/custom.css'),
require.resolve('./src/css/font.css'),
require.resolve('./src/css/types.css'),
require.resolve('./src/css/index.css'),
],
},
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"postcss": "^8.4.47",
"prettier": "3.3.3",
"tailwindcss": "^3.4.13",
"typescript": "^4.8.4"
"typescript": "^4.8.4",
"postcss-import": "^16.1.0"
},
"engines": {
"npm": "please-use-yarn",
Expand Down
8 changes: 8 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('postcss').PostcssConfig} */
module.exports = {
plugins: {
'postcss-import': {},
tailwindcss: {},
autoprefixer: {},
},
};
10 changes: 10 additions & 0 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@
:root {
/* add override here */
}

.breadcrumbs__link {
@apply !text-light-neutral-1 dark:!text-dark-neutral-1 !bg-transparent !p-0 !body-3;
}
.breadcrumbs__item:first-child, .breadcrumbs__item:first-child:after {
@apply !hidden;
}
.breadcrumbs__item:not(:last-child):after {
@apply !text-light-neutral-1 dark:!text-dark-neutral-1;
}
27 changes: 10 additions & 17 deletions src/css/font.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,70 @@

@font-face {
font-family: 'Basel Grotesk';
src: url('/fonts/baselGrotesk/Basel-Grotesk-Regular.woff2');
src: url('/static/fonts/baselGrotesk/Basel-Grotesk-Regular.woff2');
font-weight: '400';
font-style: 'normal';
}

@font-face {
font-family: 'Basel Grotesk';
src: url('/fonts/baselGrotesk/Basel-Grotesk-Regular-Italic.woff2');
src: url('/static/fonts/baselGrotesk/Basel-Grotesk-Regular-Italic.woff2');
font-weight: '400';
font-style: 'italic';
}

@font-face {
font-family: 'Basel Grotesk';
src: url('/fonts/baselGrotesk/Basel-Grotesk-Book.woff2');
src: url('/static/fonts/baselGrotesk/Basel-Grotesk-Book.woff2');
font-weight: '500';
font-style: 'normal';
}

@font-face {
font-family: 'Basel Grotesk';
src: url('/fonts/baselGrotesk/Basel-Grotesk-Book-Italic.woff2');
src: url('/static/fonts/baselGrotesk/Basel-Grotesk-Book-Italic.woff2');
font-weight: '500';
font-style: 'italic';
}

@font-face {
font-family: 'Basel Grotesk';
src: url('/fonts/baselGrotesk/Basel-Grotesk-Medium.woff2');
src: url('/static/fonts/baselGrotesk/Basel-Grotesk-Medium.woff2');
font-weight: '600';
font-style: 'normal';
}

@font-face {
font-family: 'Basel Grotesk';
src: url('/fonts/baselGrotesk/Basel-Grotesk-Medium-Italic.woff2');
font-weight: '600';
font-style: 'italic';
}

@font-face {
font-family: 'Riegraf';
src: url('/fonts/riegraf/Riegraf-Light.otf');
src: url('/static/fonts/riegraf/Riegraf-Light.otf');
font-weight: '300';
font-style: 'normal';
}

@font-face {
font-family: 'Riegraf';
src: url('/fonts/riegraf/Riegraf-Regular.otf');
src: url('/static/fonts/riegraf/Riegraf-Regular.otf');
font-weight: '400';
font-style: 'normal';
}

@font-face {
font-family: 'Riegraf';
src: url('/fonts/riegraf/Riegraf-Regular-Italic.otf');
src: url('/static/fonts/riegraf/Riegraf-Regular-Italic.otf');
font-weight: '400';
font-style: 'italic';
}

@font-face {
font-family: 'Riegraf';
src: url('/fonts/riegraf/Riegraf-Medium.otf');
src: url('/static/fonts/riegraf/Riegraf-Medium.otf');
font-weight: '500';
font-style: 'normal';
}

@font-face {
font-family: 'Riegraf';
src: url('/fonts/riegraf/Riegraf-Bold.otf');
src: url('/static/fonts/riegraf/Riegraf-Bold.otf');
font-weight: '600';
font-style: 'normal';
}
Empty file added src/css/index.css
Empty file.
2 changes: 1 addition & 1 deletion src/theme/DocBreadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SentimentTracking from '../components/SentimentTracking'
export default function DocBreadcrumbs(props) {

Check warning on line 7 in src/theme/DocBreadcrumbs.tsx

View workflow job for this annotation

GitHub Actions / Run linters

'props' is defined but never used. Allowed unused args must match /_/u

Check warning on line 7 in src/theme/DocBreadcrumbs.tsx

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

'props' is defined but never used. Allowed unused args must match /_/u
return (
<div>
<OriginalDocBreadcrumbs {...props} />
<OriginalDocBreadcrumbs />
<div>
<SentimentTracking analyticsSection={DocsSentimentSection.TOP_SECTION} />
</div>
Expand Down
38 changes: 38 additions & 0 deletions src/theme/DocItem/Content/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';

Check failure on line 1 in src/theme/DocItem/Content/index.js

View workflow job for this annotation

GitHub Actions / Run linters

Run autofix to sort these imports!

Check failure on line 1 in src/theme/DocItem/Content/index.js

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

Run autofix to sort these imports!
import clsx from 'clsx';
import {ThemeClassNames} from '@docusaurus/theme-common';
import {useDoc} from '@docusaurus/theme-common/internal';
import Heading from '@theme/Heading';
import MDXContent from '@theme/MDXContent';
/**
Title can be declared inside md content or declared through
front matter and added manually. To make both cases consistent,
the added title is added under the same div.markdown block
See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
We render a "synthetic title" if:
- user doesn't ask to hide it with front matter
- the markdown content does not already contain a top-level h1 heading
*/
function useSyntheticTitle() {
const {metadata, frontMatter, contentTitle} = useDoc();
const shouldRender =
!frontMatter.hide_title && typeof contentTitle === 'undefined';
if (!shouldRender) {
return null;
}
return metadata.title;
}
export default function DocItemContent({children}) {

Check failure on line 26 in src/theme/DocItem/Content/index.js

View workflow job for this annotation

GitHub Actions / Run linters

'children' is missing in props validation

Check failure on line 26 in src/theme/DocItem/Content/index.js

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

'children' is missing in props validation
const syntheticTitle = useSyntheticTitle();
return (
<div className={clsx(ThemeClassNames.docs.docMarkdown, 'markdown')}>
{syntheticTitle && (
<header>
<Heading as="h1">{syntheticTitle}</Heading>
</header>
)}
<MDXContent>{children}</MDXContent>
</div>
);
}
68 changes: 68 additions & 0 deletions src/theme/DocItem/Footer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React from 'react';

Check failure on line 1 in src/theme/DocItem/Footer/index.js

View workflow job for this annotation

GitHub Actions / Run linters

Run autofix to sort these imports!

Check failure on line 1 in src/theme/DocItem/Footer/index.js

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

Run autofix to sort these imports!
import clsx from 'clsx';
import {ThemeClassNames} from '@docusaurus/theme-common';
import {useDoc} from '@docusaurus/theme-common/internal';
import LastUpdated from '@theme/LastUpdated';
import EditThisPage from '@theme/EditThisPage';
import TagsListInline from '@theme/TagsListInline';
import styles from './styles.module.css';
function TagsRow(props) {
return (
<div
className={clsx(
ThemeClassNames.docs.docFooterTagsRow,
'row margin-bottom--sm',
)}>
<div className="col">
<TagsListInline {...props} />
</div>
</div>
);
}
function EditMetaRow({
editUrl,

Check failure on line 23 in src/theme/DocItem/Footer/index.js

View workflow job for this annotation

GitHub Actions / Run linters

'editUrl' is missing in props validation

Check failure on line 23 in src/theme/DocItem/Footer/index.js

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

'editUrl' is missing in props validation
lastUpdatedAt,

Check failure on line 24 in src/theme/DocItem/Footer/index.js

View workflow job for this annotation

GitHub Actions / Run linters

'lastUpdatedAt' is missing in props validation

Check failure on line 24 in src/theme/DocItem/Footer/index.js

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

'lastUpdatedAt' is missing in props validation
lastUpdatedBy,

Check failure on line 25 in src/theme/DocItem/Footer/index.js

View workflow job for this annotation

GitHub Actions / Run linters

'lastUpdatedBy' is missing in props validation

Check failure on line 25 in src/theme/DocItem/Footer/index.js

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

'lastUpdatedBy' is missing in props validation
formattedLastUpdatedAt,

Check failure on line 26 in src/theme/DocItem/Footer/index.js

View workflow job for this annotation

GitHub Actions / Run linters

'formattedLastUpdatedAt' is missing in props validation

Check failure on line 26 in src/theme/DocItem/Footer/index.js

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

'formattedLastUpdatedAt' is missing in props validation
}) {
return (
<div className={clsx(ThemeClassNames.docs.docFooterEditMetaRow, 'row')}>
<div className="col">{editUrl && <EditThisPage editUrl={editUrl} />}</div>

<div className={clsx('col', styles.lastUpdated)}>
{(lastUpdatedAt || lastUpdatedBy) && (
<LastUpdated
lastUpdatedAt={lastUpdatedAt}
formattedLastUpdatedAt={formattedLastUpdatedAt}
lastUpdatedBy={lastUpdatedBy}
/>
)}
</div>
</div>
);
}
export default function DocItemFooter() {
const {metadata} = useDoc();
const {editUrl, lastUpdatedAt, formattedLastUpdatedAt, lastUpdatedBy, tags} =
metadata;
const canDisplayTagsRow = tags.length > 0;
const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy);
const canDisplayFooter = canDisplayTagsRow || canDisplayEditMetaRow;
if (!canDisplayFooter) {
return null;
}
return (
<footer
className={clsx(ThemeClassNames.docs.docFooter, 'docusaurus-mt-lg')}>
{canDisplayTagsRow && <TagsRow tags={tags} />}
{canDisplayEditMetaRow && (
<EditMetaRow
editUrl={editUrl}
lastUpdatedAt={lastUpdatedAt}
lastUpdatedBy={lastUpdatedBy}
formattedLastUpdatedAt={formattedLastUpdatedAt}
/>
)}
</footer>
);
}
11 changes: 11 additions & 0 deletions src/theme/DocItem/Footer/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.lastUpdated {
margin-top: 0.2rem;
font-style: italic;
font-size: smaller;
}

@media (min-width: 997px) {
.lastUpdated {
text-align: right;
}
}
53 changes: 53 additions & 0 deletions src/theme/DocItem/Layout/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';

Check failure on line 1 in src/theme/DocItem/Layout/index.js

View workflow job for this annotation

GitHub Actions / Run linters

Run autofix to sort these imports!

Check failure on line 1 in src/theme/DocItem/Layout/index.js

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

Run autofix to sort these imports!
import clsx from 'clsx';
import {useWindowSize} from '@docusaurus/theme-common';
import {useDoc} from '@docusaurus/theme-common/internal';
import DocItemPaginator from '@theme/DocItem/Paginator';
import DocVersionBanner from '@theme/DocVersionBanner';
import DocVersionBadge from '@theme/DocVersionBadge';
import DocItemFooter from '@theme/DocItem/Footer';
import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile';
import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop';
import DocItemContent from '@theme/DocItem/Content';
import DocBreadcrumbs from '@theme/DocBreadcrumbs';
import styles from './styles.module.css';
/**
* Decide if the toc should be rendered, on mobile or desktop viewports
*/
function useDocTOC() {
const {frontMatter, toc} = useDoc();
const windowSize = useWindowSize();
const hidden = frontMatter.hide_table_of_contents;
const canRender = !hidden && toc.length > 0;
const mobile = canRender ? <DocItemTOCMobile /> : undefined;
const desktop =
canRender && (windowSize === 'desktop' || windowSize === 'ssr') ? (
<DocItemTOCDesktop />
) : undefined;
return {
hidden,
mobile,
desktop,
};
}
export default function DocItemLayout({children}) {

Check failure on line 33 in src/theme/DocItem/Layout/index.js

View workflow job for this annotation

GitHub Actions / Run linters

'children' is missing in props validation

Check failure on line 33 in src/theme/DocItem/Layout/index.js

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

'children' is missing in props validation
const docTOC = useDocTOC();
return (
<div className="row">
<div className={clsx('col', !docTOC.hidden && styles.docItemCol)}>
<DocVersionBanner />
<div className={styles.docItemContainer}>
<article>
<DocBreadcrumbs />
<DocVersionBadge />
{docTOC.mobile}
<DocItemContent>{children}</DocItemContent>
<DocItemFooter />
</article>
<DocItemPaginator />
</div>
</div>
{docTOC.desktop && <div className="col col--3">On this page {docTOC.desktop}</div>}
</div>
);
}
10 changes: 10 additions & 0 deletions src/theme/DocItem/Layout/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.docItemContainer header + *,
.docItemContainer article > *:first-child {
margin-top: 0;
}

@media (min-width: 997px) {
.docItemCol {
max-width: 75% !important;
}
}
14 changes: 14 additions & 0 deletions src/theme/DocItem/Metadata/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';

Check failure on line 1 in src/theme/DocItem/Metadata/index.js

View workflow job for this annotation

GitHub Actions / Run linters

Run autofix to sort these imports!

Check failure on line 1 in src/theme/DocItem/Metadata/index.js

View workflow job for this annotation

GitHub Actions / Check uniswap Benchmarks

Run autofix to sort these imports!
import {PageMetadata} from '@docusaurus/theme-common';
import {useDoc} from '@docusaurus/theme-common/internal';
export default function DocItemMetadata() {
const {metadata, frontMatter, assets} = useDoc();
return (
<PageMetadata
title={metadata.title}
description={metadata.description}
keywords={frontMatter.keywords}
image={assets.image ?? frontMatter.image}
/>
);
}
11 changes: 11 additions & 0 deletions src/theme/DocItem/Paginator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import {useDoc} from '@docusaurus/theme-common/internal';
import DocPaginator from '@theme/DocPaginator';
/**
* This extra component is needed, because <DocPaginator> should remain generic.
* DocPaginator is used in non-docs contexts too: generated-index pages...
*/
export default function DocItemPaginator() {
const {metadata} = useDoc();
return <DocPaginator previous={metadata.previous} next={metadata.next} />;
}
15 changes: 15 additions & 0 deletions src/theme/DocItem/TOC/Desktop/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import {ThemeClassNames} from '@docusaurus/theme-common';
import {useDoc} from '@docusaurus/theme-common/internal';
import TOC from '@theme/TOC';
export default function DocItemTOCDesktop() {
const {toc, frontMatter} = useDoc();
return (
<TOC
toc={toc}
minHeadingLevel={frontMatter.toc_min_heading_level}
maxHeadingLevel={frontMatter.toc_max_heading_level}
className={ThemeClassNames.docs.docTocDesktop}
/>
);
}
17 changes: 17 additions & 0 deletions src/theme/DocItem/TOC/Mobile/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import clsx from 'clsx';
import {ThemeClassNames} from '@docusaurus/theme-common';
import {useDoc} from '@docusaurus/theme-common/internal';
import TOCCollapsible from '@theme/TOCCollapsible';
import styles from './styles.module.css';
export default function DocItemTOCMobile() {
const {toc, frontMatter} = useDoc();
return (
<TOCCollapsible
toc={toc}
minHeadingLevel={frontMatter.toc_min_heading_level}
maxHeadingLevel={frontMatter.toc_max_heading_level}
className={clsx(ThemeClassNames.docs.docTocMobile, styles.tocMobile)}
/>
);
}
12 changes: 12 additions & 0 deletions src/theme/DocItem/TOC/Mobile/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@media (min-width: 997px) {
/* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
.tocMobile {
display: none;
}
}

@media print {
.tocMobile {
display: none;
}
}
Loading

0 comments on commit 30d2966

Please sign in to comment.