@myst-theme/site 0.1.22 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -9
- package/src/components/Bibliography.tsx +1 -1
- package/src/components/ContentBlocks.tsx +19 -4
- package/src/components/DocumentOutline.tsx +4 -1
- package/src/components/Navigation/Navigation.tsx +3 -1
- package/src/components/Navigation/TableOfContents.tsx +7 -9
- package/src/components/Navigation/TopNav.tsx +2 -4
- package/src/pages/Root.tsx +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myst-theme/site",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"main": "./src/index.ts",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -14,19 +14,18 @@
|
|
|
14
14
|
"lint:format": "prettier --check \"src/**/*.{ts,tsx,md}\""
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@curvenote/icons": "^0.0.3",
|
|
18
17
|
"@headlessui/react": "^1.7.8",
|
|
19
18
|
"@heroicons/react": "^2.0.14",
|
|
20
|
-
"@myst-theme/diagrams": "^0.1.
|
|
21
|
-
"@myst-theme/frontmatter": "^0.1.
|
|
22
|
-
"@myst-theme/jupyter": "^0.1.
|
|
23
|
-
"@myst-theme/providers": "^0.1.
|
|
19
|
+
"@myst-theme/diagrams": "^0.1.24",
|
|
20
|
+
"@myst-theme/frontmatter": "^0.1.24",
|
|
21
|
+
"@myst-theme/jupyter": "^0.1.24",
|
|
22
|
+
"@myst-theme/providers": "^0.1.24",
|
|
24
23
|
"classnames": "^2.3.2",
|
|
25
24
|
"lodash.throttle": "^4.1.1",
|
|
26
25
|
"myst-common": "^0.0.12",
|
|
27
|
-
"myst-config": "^0.0.
|
|
28
|
-
"myst-demo": "^0.1.
|
|
29
|
-
"myst-to-react": "^0.1.
|
|
26
|
+
"myst-config": "^0.0.9",
|
|
27
|
+
"myst-demo": "^0.1.24",
|
|
28
|
+
"myst-to-react": "^0.1.24",
|
|
30
29
|
"mystjs": "^0.0.15",
|
|
31
30
|
"nbtx": "^0.2.3",
|
|
32
31
|
"node-cache": "^5.1.2",
|
|
@@ -11,7 +11,7 @@ export function Bibliography() {
|
|
|
11
11
|
if (!filtered || !data || filtered.length === 0) return null;
|
|
12
12
|
const refs = hidden ? filtered.slice(0, HIDE_OVER_N_REFERENCES) : filtered;
|
|
13
13
|
return (
|
|
14
|
-
<section>
|
|
14
|
+
<section className="article-grid article-subgrid-gap col-screen">
|
|
15
15
|
{filtered.length > HIDE_OVER_N_REFERENCES && (
|
|
16
16
|
<button
|
|
17
17
|
onClick={() => setHidden(!hidden)}
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import { useParse, DEFAULT_RENDERERS } from 'myst-to-react';
|
|
2
2
|
import type { Parent } from 'myst-spec';
|
|
3
3
|
import { useNodeRenderers } from '@myst-theme/providers';
|
|
4
|
+
import classNames from 'classnames';
|
|
4
5
|
|
|
5
|
-
function Block({ id, node }: { id: string; node: Parent }) {
|
|
6
|
+
function Block({ id, node, className }: { id: string; node: Parent; className?: string }) {
|
|
6
7
|
const renderers = useNodeRenderers() ?? DEFAULT_RENDERERS;
|
|
7
8
|
const children = useParse(node, renderers);
|
|
8
|
-
|
|
9
|
+
const subGrid = 'article-grid article-subgrid-gap col-screen';
|
|
10
|
+
const dataClassName = typeof node.data?.class === 'string' ? node.data?.class : undefined;
|
|
11
|
+
// Hide the subgrid if either the dataClass or the className exists and includes `col-`
|
|
12
|
+
const noSubGrid =
|
|
13
|
+
(dataClassName && dataClassName.includes('col-')) || (className && className.includes('col-'));
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
id={id}
|
|
17
|
+
className={classNames(className, dataClassName, {
|
|
18
|
+
[subGrid]: !noSubGrid,
|
|
19
|
+
})}
|
|
20
|
+
>
|
|
21
|
+
{children}
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
9
24
|
}
|
|
10
25
|
|
|
11
|
-
export function ContentBlocks({ mdast }: { mdast: Parent }) {
|
|
26
|
+
export function ContentBlocks({ mdast, className }: { mdast: Parent; className?: string }) {
|
|
12
27
|
const blocks = mdast.children as Parent[];
|
|
13
28
|
return (
|
|
14
29
|
<>
|
|
15
30
|
{blocks.map((node, index) => {
|
|
16
|
-
return <Block key={(node as any).key} id={`${index}`} node={node} />;
|
|
31
|
+
return <Block key={(node as any).key} id={`${index}`} node={node} className={className} />;
|
|
17
32
|
})}
|
|
18
33
|
</>
|
|
19
34
|
);
|
|
@@ -151,10 +151,13 @@ const useIntersectionObserver = (highlight: () => void, onScreen: Set<HTMLHeadin
|
|
|
151
151
|
return { observer };
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
+
const DOC_OUTLINE_CLASS =
|
|
155
|
+
'fixed z-10 bottom-0 right-[max(0px,calc(50%-45rem))] w-[14rem] lg:w-[18rem] py-10 px-4 lg:px-8 overflow-y-auto hidden md:block';
|
|
156
|
+
|
|
154
157
|
export const DocumentOutline = ({
|
|
155
158
|
top,
|
|
156
159
|
height,
|
|
157
|
-
className =
|
|
160
|
+
className = DOC_OUTLINE_CLASS,
|
|
158
161
|
}: {
|
|
159
162
|
top?: number;
|
|
160
163
|
height?: number;
|
|
@@ -7,12 +7,14 @@ export function Navigation({
|
|
|
7
7
|
top,
|
|
8
8
|
height,
|
|
9
9
|
hide_toc,
|
|
10
|
+
footer,
|
|
10
11
|
}: {
|
|
11
12
|
children?: React.ReactNode;
|
|
12
13
|
projectSlug?: string;
|
|
13
14
|
top?: number;
|
|
14
15
|
height?: number;
|
|
15
16
|
hide_toc?: boolean;
|
|
17
|
+
footer?: React.ReactNode;
|
|
16
18
|
}) {
|
|
17
19
|
const [open, setOpen] = useNavOpen();
|
|
18
20
|
if (hide_toc) return <>{children}</>;
|
|
@@ -25,7 +27,7 @@ export function Navigation({
|
|
|
25
27
|
></div>
|
|
26
28
|
)}
|
|
27
29
|
{children}
|
|
28
|
-
<TableOfContents projectSlug={projectSlug} top={top} height={height} />
|
|
30
|
+
<TableOfContents projectSlug={projectSlug} top={top} height={height} footer={footer} />
|
|
29
31
|
</>
|
|
30
32
|
);
|
|
31
33
|
}
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { NavLink, useParams, useLocation } from '@remix-run/react';
|
|
4
4
|
import type { SiteManifest } from 'myst-config';
|
|
5
|
-
import { CreatedInCurvenote } from '@curvenote/icons';
|
|
6
5
|
import { useNavOpen, useSiteManifest, useUrlbase, withUrlbase } from '@myst-theme/providers';
|
|
7
6
|
import { getProjectHeadings } from '../../loaders';
|
|
8
7
|
import type { Heading } from '../../types';
|
|
@@ -102,16 +101,19 @@ const Headings = ({ folder, headings, sections }: Props) => {
|
|
|
102
101
|
);
|
|
103
102
|
};
|
|
104
103
|
|
|
104
|
+
const TOC_CLASS =
|
|
105
|
+
'flex-col fixed z-30 bottom-0 left-[max(0px,calc(50%-45rem))] w-[19.5rem] border-r border-stone-200 dark:border-stone-700';
|
|
106
|
+
|
|
105
107
|
export const TableOfContents = ({
|
|
106
108
|
projectSlug,
|
|
107
109
|
top,
|
|
108
110
|
height,
|
|
109
|
-
|
|
111
|
+
footer,
|
|
110
112
|
}: {
|
|
111
113
|
top?: number;
|
|
112
114
|
height?: number;
|
|
113
115
|
projectSlug?: string;
|
|
114
|
-
|
|
116
|
+
footer?: React.ReactNode;
|
|
115
117
|
}) => {
|
|
116
118
|
const [open] = useNavOpen();
|
|
117
119
|
const config = useSiteManifest();
|
|
@@ -124,7 +126,7 @@ export const TableOfContents = ({
|
|
|
124
126
|
if (!headings) return null;
|
|
125
127
|
return (
|
|
126
128
|
<div
|
|
127
|
-
className={classNames('
|
|
129
|
+
className={classNames(TOC_CLASS, 'overflow-hidden', {
|
|
128
130
|
flex: open,
|
|
129
131
|
'bg-white dark:bg-stone-900': open, // just apply when open, so that theme can transition
|
|
130
132
|
'hidden xl:flex': !open,
|
|
@@ -145,11 +147,7 @@ export const TableOfContents = ({
|
|
|
145
147
|
>
|
|
146
148
|
<Headings folder={resolvedProjectSlug} headings={headings} sections={config?.projects} />
|
|
147
149
|
</nav>
|
|
148
|
-
{
|
|
149
|
-
<div className="flex-none py-4">
|
|
150
|
-
<CreatedInCurvenote />
|
|
151
|
-
</div>
|
|
152
|
-
)}
|
|
150
|
+
{footer && <div className="flex-none py-4">{footer}</div>}
|
|
153
151
|
</div>
|
|
154
152
|
);
|
|
155
153
|
};
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
import type { SiteManifest, SiteNavItem } from 'myst-config';
|
|
11
11
|
import { ThemeButton } from './ThemeButton';
|
|
12
12
|
import { useNavOpen, useSiteManifest } from '@myst-theme/providers';
|
|
13
|
-
import { CurvenoteLogo } from '@curvenote/icons';
|
|
14
13
|
import { LoadingBar } from './Loading';
|
|
15
14
|
|
|
16
15
|
export const DEFAULT_NAV_HEIGHT = 60;
|
|
@@ -109,7 +108,7 @@ function NavItem({ item }: { item: SiteNavItem }) {
|
|
|
109
108
|
to={action.url || ''}
|
|
110
109
|
className={({ isActive }) =>
|
|
111
110
|
classNames(
|
|
112
|
-
'block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-black',
|
|
111
|
+
' block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-black ',
|
|
113
112
|
{
|
|
114
113
|
'text-black font-bold': isActive,
|
|
115
114
|
},
|
|
@@ -190,13 +189,12 @@ function HomeLink({ logo, logoText, name }: { logo?: string; logoText?: string;
|
|
|
190
189
|
prefetch="intent"
|
|
191
190
|
>
|
|
192
191
|
{logo && <img src={logo} className="h-9 mr-3" alt={logoText || name} height="2.25rem"></img>}
|
|
193
|
-
{nothingSet && <CurvenoteLogo className="mr-3" fill="#FFF" size={30} />}
|
|
194
192
|
<span
|
|
195
193
|
className={classNames('text-md sm:text-xl tracking-tight sm:mr-5', {
|
|
196
194
|
'sr-only': !(logoText || nothingSet),
|
|
197
195
|
})}
|
|
198
196
|
>
|
|
199
|
-
{logoText || '
|
|
197
|
+
{logoText || 'Made with MyST'}
|
|
200
198
|
</span>
|
|
201
199
|
</Link>
|
|
202
200
|
);
|
package/src/pages/Root.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { ContentReload, renderers } from '../components';
|
|
16
16
|
import { Analytics } from '../seo';
|
|
17
17
|
import { ErrorSiteNotFound } from './ErrorSiteNotFound';
|
|
18
|
+
import classNames from 'classnames';
|
|
18
19
|
|
|
19
20
|
export function Document({
|
|
20
21
|
children,
|
|
@@ -22,15 +23,17 @@ export function Document({
|
|
|
22
23
|
config,
|
|
23
24
|
title,
|
|
24
25
|
CONTENT_CDN_PORT,
|
|
26
|
+
scrollTopClass = 'scroll-p-20',
|
|
25
27
|
}: {
|
|
26
28
|
children: React.ReactNode;
|
|
27
29
|
theme: Theme;
|
|
28
30
|
config?: SiteManifest;
|
|
29
31
|
title?: string;
|
|
30
32
|
CONTENT_CDN_PORT?: number | string;
|
|
33
|
+
scrollTopClass?: string;
|
|
31
34
|
}) {
|
|
32
35
|
return (
|
|
33
|
-
<html lang="en" className={theme}>
|
|
36
|
+
<html lang="en" className={classNames(theme, scrollTopClass)}>
|
|
34
37
|
<head>
|
|
35
38
|
<meta charSet="utf-8" />
|
|
36
39
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
@@ -69,7 +72,7 @@ export function AppCatchBoundary() {
|
|
|
69
72
|
return (
|
|
70
73
|
<Document theme={Theme.light} title={caught.statusText}>
|
|
71
74
|
<article className="content">
|
|
72
|
-
<main className="
|
|
75
|
+
<main className="article-grid article-subgrid-gap col-screen">
|
|
73
76
|
<ErrorSiteNotFound />
|
|
74
77
|
</main>
|
|
75
78
|
</article>
|
|
@@ -81,7 +84,7 @@ export function AppDebugErrorBoundary({ error }: { error: { message: string; sta
|
|
|
81
84
|
return (
|
|
82
85
|
<Document theme={Theme.light} title="Error">
|
|
83
86
|
<div className="mt-16">
|
|
84
|
-
<main className="
|
|
87
|
+
<main className="article-grid article-subgrid-gap col-screen">
|
|
85
88
|
<h1>An Error Occurred</h1>
|
|
86
89
|
<code>{error.message}</code>
|
|
87
90
|
<pre>{error.stack}</pre>
|