Skip to content

Commit

Permalink
docs: Incorporate some upstream features of nextra-theme-docs (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpalmer authored Jan 26, 2022
1 parent 63c2c1c commit 7d5b8eb
Show file tree
Hide file tree
Showing 12 changed files with 317 additions and 102 deletions.
4 changes: 0 additions & 4 deletions docs/nextra-theme-docs/config.js

This file was deleted.

5 changes: 5 additions & 0 deletions docs/nextra-theme-docs/config.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";
import { DocsThemeConfig } from "./types";

export const ThemeConfigContext = React.createContext<DocsThemeConfig>({});
export const useConfig = () => React.useContext(ThemeConfigContext);
7 changes: 6 additions & 1 deletion docs/nextra-theme-docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,12 @@ const Layout = ({
<Body
meta={meta}
filepathWithName={filepathWithName}
toc={<ToC headings={config.floatTOC ? headings : null} />}
toc={
<ToC
headings={config.floatTOC ? headings : null}
filepathWithName={filepathWithName}
/>
}
navLinks={
<NavLinks
flatDirectories={flatDocsDirectories}
Expand Down
19 changes: 15 additions & 4 deletions docs/nextra-theme-docs/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import innerText from "react-innertext";
import { useActiveAnchor } from "./misc/active-anchor";
import { getFSRoute } from "./utils/get-fs-route";
import useMenuContext from "./utils/menu-context";

import ArrowRight from "./icons/arrow-right";
import Search from "./flexsearch";
import { useConfig } from "./config";

const TreeState = new Map();

function Folder({ item, anchors }) {
const { asPath, locale } = useRouter();
const routeOriginal = getFSRoute(asPath, locale);
Expand All @@ -38,14 +37,26 @@ function Folder({ item, anchors }) {
render((x) => !x);
}}
>
{item.title}
<span className="flex items-center justify-between gap-2">
{item.title}
<ArrowRight
height="1em"
className={cn(open ? "rotate-90" : "", "transition-transform")}
/>
</span>
</button>
<div
style={{
display: open ? "initial" : "none",
}}
>
<Menu directories={item.children} base={item.route} anchors={anchors} />
{Array.isArray(item.children) && (
<Menu
directories={item.children}
base={item.route}
anchors={anchors}
/>
)}
</div>
</li>
);
Expand Down
49 changes: 24 additions & 25 deletions docs/nextra-theme-docs/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ article h2 a {
@apply dark:text-gray-500;
}
&.nextra-flexsearch ul {
@apply overflow-auto left-0 md:-left-80 md:right-0;
@apply left-0 overflow-auto md:-left-80 md:right-0;
min-height: 100px;
max-height: min(calc(100vh - 12.5rem), 600px);
max-width: min(calc(100vw - 2rem), calc(100% + 20rem));
Expand All @@ -188,7 +188,7 @@ article h2 a {
li {
@apply text-gray-800 break-words mx-2.5 px-2.5 py-2 rounded-md;
.highlight {
@apply underline decoration-blue-400 text-blue-500;
@apply text-blue-500 underline decoration-blue-400;
}
}
li.active,
Expand All @@ -198,11 +198,11 @@ article h2 a {
}
.dark & {
ul {
@apply bg-neutral-800 backdrop-blur-xl bg-opacity-60 text-gray-100 ring-white ring-opacity-10 divide-gray-200/10;
@apply text-gray-100 bg-neutral-800 backdrop-blur-xl bg-opacity-60 ring-white ring-opacity-10 divide-gray-200/10;
li {
@apply text-gray-300;
.highlight {
@apply underline decoration-blue-400 text-blue-500;
@apply text-blue-500 underline decoration-blue-400;
}
}
li.active,
Expand Down Expand Up @@ -308,32 +308,31 @@ article .contains-task-list input[type="checkbox"] {
}

:root {
--shiki-color-text: #414141;
--shiki-color-background: transparent;
--shiki-token-constant: #1976d2;
--shiki-token-string: #22863a;
--shiki-token-comment: #aaa;
--shiki-token-keyword: #d32f2f;
--shiki-token-parameter: #ff9800;
--shiki-token-function: #6f42c1;
--shiki-token-string-expression: #22863a;
--shiki-token-punctuation: #212121;
--shiki-token-link: #22863a;
--shiki-color-text: #24292f;
--shiki-color-background: #ffffff;
--shiki-token-constant: #0550ae;
--shiki-token-string: #24292f;
--shiki-token-comment: #6e7781;
--shiki-token-keyword: #cf222e;
--shiki-token-parameter: #24292f;
--shiki-token-function: #8250df;
--shiki-token-string-expression: #0a3069;
--shiki-token-punctuation: #24292f;
--nextra-shiki-deleted: #f00;
--nextra-shiki-inserted: #f00;
}

.dark {
--shiki-color-text: #d1d1d1;
--shiki-token-constant: #79b8ff;
--shiki-token-string: #ffab70;
--shiki-token-comment: #6b737c;
--shiki-token-keyword: #f97583;
--shiki-token-parameter: #ff9800;
--shiki-token-function: #b392f0;
--shiki-token-string-expression: #4bb74a;
--shiki-token-punctuation: #bbbbbb;
--shiki-token-link: #ffab70;
--shiki-color-text: #c9d1d9;
--shiki-color-background: #0d1117;
--shiki-token-constant: #79c0ff;
--shiki-token-string: #a5d6ff;
--shiki-token-comment: #8b949e;
--shiki-token-keyword: #ff7b72;
--shiki-token-parameter: #c9d1d9;
--shiki-token-function: #d2a8ff;
--shiki-token-string-expression: #a5d6ff;
--shiki-token-punctuation: #c9d1d9;
}

.post-item .post-item-date {
Expand Down
58 changes: 0 additions & 58 deletions docs/nextra-theme-docs/toc.js

This file was deleted.

Loading

1 comment on commit 7d5b8eb

@vercel
Copy link

@vercel vercel bot commented on 7d5b8eb Jan 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.