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

chore: update docusaurus template #785

Merged
merged 1 commit into from
Jul 7, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ module.exports = {
showLastUpdateAuthor: true,
showLastUpdateTime: true,
disableVersioning: false,
include: ['**/*.md', '**/*.mdx', '**/*.jsx']
include: ['**/*.md', '**/*.mdx', '**/*.jsx'],
docLayoutComponent: '@theme/RoutedDocPage'
}
],
'@docusaurus/plugin-content-pages',
Expand Down
18 changes: 1 addition & 17 deletions docs/src/theme/API.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
import React from 'react'
import useBaseUrl from '@docusaurus/useBaseUrl'
import { useActiveVersion } from '@theme/hooks/useDocs'
import Redoc from '@theme/Redoc'
import styles from './API.module.css'

function join(...args) {
return args
.map((part, i) => {
if (i === 0) {
return part.trim().replace(/[\/]*$/g, '')
} else {
return part.trim().replace(/(^[\/]*|[\/]*$)/g, '')
}
})
.filter((x) => x.length)
.join('/')
}
import './API.module.css'

function API({ spec }) {
const { path } = useActiveVersion()
return <Redoc spec={spec} />
}

Expand Down
6 changes: 3 additions & 3 deletions docs/src/theme/API.module.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
:global .container {
:global #route-identifier[data-route*='reference/api'] .container {
width: 100% !important;
max-width: 100% !important;
}

:global .container .col {
:global #route-identifier[data-route*='reference/api'] .container .col {
width: 100% !important;
max-width: 100% !important;
}

:global .container .col.col--3 {
:global #route-identifier[data-route*='reference/api'] .container .col.col--3 {
display: none;
}
7 changes: 7 additions & 0 deletions docs/src/theme/RoutedDocPage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import type {Props} from '@theme/DocPage';
import DocPage from '@theme/DocPage'

export default function RoutedDocPage(props: Props): JSX.Element {
return <div id={"route-identifier"} data-route={props.location.pathname}><DocPage {...props}/></div>
}
80 changes: 80 additions & 0 deletions docs/src/theme/RoutedDocPage/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* 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.
*/

:root {
--doc-sidebar-width: 300px;
--doc-sidebar-hidden-width: 30px;
}

:global(.docs-wrapper) {
display: flex;
}

.docPage,
.docMainContainer {
display: flex;
width: 100%;
}

@media (min-width: 997px) {
.docMainContainer {
flex-grow: 1;
max-width: calc(100% - var(--doc-sidebar-width));
}

.docMainContainerEnhanced {
max-width: calc(100% - var(--doc-sidebar-hidden-width));
}

.docSidebarContainer {
width: var(--doc-sidebar-width);
margin-top: calc(-1 * var(--ifm-navbar-height));
border-right: 1px solid var(--ifm-toc-border-color);
will-change: width;
transition: width var(--ifm-transition-fast) ease;
clip-path: inset(0);
}

.docSidebarContainerHidden {
width: var(--doc-sidebar-hidden-width);
cursor: pointer;
}

.collapsedDocSidebar {
position: sticky;
top: 0;
height: 100%;
max-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
transition: background-color var(--ifm-transition-fast) ease;
}

.collapsedDocSidebar:hover,
.collapsedDocSidebar:focus {
background-color: var(--ifm-color-emphasis-200);
}

.expandSidebarButtonIcon {
transform: rotate(0);
}
html[dir='rtl'] .expandSidebarButtonIcon {
transform: rotate(180deg);
}

html[data-theme='dark'] .collapsedDocSidebar:hover,
html[data-theme='dark'] .collapsedDocSidebar:focus {
background-color: var(--collapse-button-bg-color-dark);
}

.docItemWrapperEnhanced {
max-width: calc(
var(--ifm-container-width) + var(--doc-sidebar-width)
) !important;
}
}