@myst-theme/site 0.1.23 → 0.1.25
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myst-theme/site",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"main": "./src/index.ts",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -16,17 +16,16 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@headlessui/react": "^1.7.8",
|
|
18
18
|
"@heroicons/react": "^2.0.14",
|
|
19
|
-
"@myst-theme/diagrams": "^0.1.
|
|
20
|
-
"@myst-theme/frontmatter": "^0.1.
|
|
21
|
-
"@myst-theme/jupyter": "^0.1.
|
|
22
|
-
"@myst-theme/providers": "^0.1.
|
|
19
|
+
"@myst-theme/diagrams": "^0.1.25",
|
|
20
|
+
"@myst-theme/frontmatter": "^0.1.25",
|
|
21
|
+
"@myst-theme/jupyter": "^0.1.25",
|
|
22
|
+
"@myst-theme/providers": "^0.1.25",
|
|
23
23
|
"classnames": "^2.3.2",
|
|
24
24
|
"lodash.throttle": "^4.1.1",
|
|
25
|
-
"myst-common": "^0.0.
|
|
25
|
+
"myst-common": "^0.0.14",
|
|
26
26
|
"myst-config": "^0.0.9",
|
|
27
|
-
"myst-demo": "^0.1.
|
|
28
|
-
"myst-to-react": "^0.1.
|
|
29
|
-
"mystjs": "^0.0.15",
|
|
27
|
+
"myst-demo": "^0.1.25",
|
|
28
|
+
"myst-to-react": "^0.1.25",
|
|
30
29
|
"nbtx": "^0.2.3",
|
|
31
30
|
"node-cache": "^5.1.2",
|
|
32
31
|
"node-fetch": "^2.6.7",
|
|
@@ -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
|
);
|
|
@@ -27,23 +27,24 @@ const Headings = ({ headings, activeId, highlight }: Props) => (
|
|
|
27
27
|
{headings.map((heading) => (
|
|
28
28
|
<li
|
|
29
29
|
key={heading.id}
|
|
30
|
-
className={classNames('border-l-2', {
|
|
30
|
+
className={classNames('border-l-2 hover:border-l-blue-500', {
|
|
31
31
|
'text-blue-600': heading.id === activeId,
|
|
32
|
-
'border-l-gray-300 dark:border-l-gray-50
|
|
33
|
-
heading.id !== activeId,
|
|
32
|
+
'border-l-gray-300 dark:border-l-gray-50': heading.id !== activeId,
|
|
34
33
|
'border-l-blue-500': heading.id === activeId,
|
|
35
34
|
'bg-blue-50 dark:bg-slate-800': heading.id === activeId,
|
|
36
35
|
})}
|
|
37
36
|
>
|
|
38
37
|
<a
|
|
39
|
-
className={classNames('block p-1 pl-2
|
|
40
|
-
'text-
|
|
38
|
+
className={classNames('block p-1 pl-2', {
|
|
39
|
+
'text-slate-900 dark:text-slate-50': heading.level < 3 && heading.id !== activeId,
|
|
40
|
+
'text-slate-500 dark:text-slate-300': heading.level >= 3 && heading.id !== activeId,
|
|
41
|
+
'text-blue-600 dark:text-white font-bold': heading.id === activeId,
|
|
41
42
|
'pr-2': heading.id !== activeId,
|
|
42
|
-
'pl-
|
|
43
|
+
'pl-2': heading.level === 2,
|
|
43
44
|
'pl-4': heading.level === 3,
|
|
44
|
-
'pl-
|
|
45
|
-
'pl-
|
|
46
|
-
'pl-
|
|
45
|
+
'pl-8 text-xs': heading.level === 4,
|
|
46
|
+
'pl-10 text-xs font-light': heading.level === 5,
|
|
47
|
+
'pl-12 text-xs font-extralight': heading.level === 6,
|
|
47
48
|
})}
|
|
48
49
|
href={`#${heading.id}`}
|
|
49
50
|
onClick={(e) => {
|
|
@@ -151,10 +152,13 @@ const useIntersectionObserver = (highlight: () => void, onScreen: Set<HTMLHeadin
|
|
|
151
152
|
return { observer };
|
|
152
153
|
};
|
|
153
154
|
|
|
155
|
+
const DOC_OUTLINE_CLASS =
|
|
156
|
+
'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 lg:block';
|
|
157
|
+
|
|
154
158
|
export const DocumentOutline = ({
|
|
155
159
|
top,
|
|
156
160
|
height,
|
|
157
|
-
className =
|
|
161
|
+
className = DOC_OUTLINE_CLASS,
|
|
158
162
|
}: {
|
|
159
163
|
top?: number;
|
|
160
164
|
height?: number;
|
|
@@ -35,12 +35,13 @@ const HeadingLink = ({
|
|
|
35
35
|
title={title}
|
|
36
36
|
className={({ isActive }: { isActive: boolean }) =>
|
|
37
37
|
classNames('block break-words', {
|
|
38
|
-
'
|
|
38
|
+
'mb-8 lg:mb-3 font-semibold': isIndex,
|
|
39
|
+
'text-slate-900 dark:text-slate-200': isIndex && !exact,
|
|
40
|
+
'text-blue-500 dark:text-blue-400': isIndex && exact,
|
|
41
|
+
'border-l pl-4 text-blue-500 border-current dark:text-blue-400': !isIndex && isActive,
|
|
39
42
|
'font-semibold': isActive,
|
|
40
|
-
'hover:text-slate-
|
|
41
|
-
|
|
42
|
-
'border-stone-200 dark:border-stone-700': isIndex && !exact,
|
|
43
|
-
'border-blue-500': isIndex && exact,
|
|
43
|
+
'border-l pl-4 border-transparent hover:border-slate-400 dark:hover:border-slate-500 text-slate-700 hover:text-slate-900 dark:text-slate-400 dark:hover:text-slate-300':
|
|
44
|
+
!isActive,
|
|
44
45
|
})
|
|
45
46
|
}
|
|
46
47
|
to={withUrlbase(path, urlbase)}
|
|
@@ -55,24 +56,24 @@ const HeadingLink = ({
|
|
|
55
56
|
);
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
const HEADING_CLASSES = 'text-slate-900
|
|
59
|
+
const HEADING_CLASSES = 'text-slate-900 leading-5 dark:text-slate-100';
|
|
59
60
|
const Headings = ({ folder, headings, sections }: Props) => {
|
|
60
61
|
const secs = sections || [];
|
|
61
62
|
return (
|
|
62
|
-
<ul className="
|
|
63
|
+
<ul className="space-y-6 lg:space-y-2">
|
|
63
64
|
{secs.map((sec) => {
|
|
64
65
|
if (sec.slug === folder) {
|
|
65
66
|
return headings.map((heading, index) => (
|
|
66
67
|
<li
|
|
67
68
|
key={heading.slug || index}
|
|
68
|
-
className={classNames('
|
|
69
|
+
className={classNames('', {
|
|
69
70
|
[HEADING_CLASSES]: heading.level === 'index',
|
|
70
71
|
'font-semibold': heading.level === 'index',
|
|
71
|
-
'pl-4': heading.level === 2,
|
|
72
|
-
'pl-6': heading.level === 3,
|
|
73
|
-
'pl-8': heading.level === 4,
|
|
74
|
-
'pl-10': heading.level === 5,
|
|
75
|
-
'pl-12': heading.level === 6,
|
|
72
|
+
// 'pl-4': heading.level === 2,
|
|
73
|
+
// 'pl-6': heading.level === 3,
|
|
74
|
+
// 'pl-8': heading.level === 4,
|
|
75
|
+
// 'pl-10': heading.level === 5,
|
|
76
|
+
// 'pl-12': heading.level === 6,
|
|
76
77
|
})}
|
|
77
78
|
>
|
|
78
79
|
{heading.path ? (
|
|
@@ -84,7 +85,7 @@ const Headings = ({ folder, headings, sections }: Props) => {
|
|
|
84
85
|
{heading.short_title || heading.title}
|
|
85
86
|
</HeadingLink>
|
|
86
87
|
) : (
|
|
87
|
-
<h5 className="
|
|
88
|
+
<h5 className="mb-3 lg:mt-8 font-semibold break-words dark:text-white">
|
|
88
89
|
{heading.short_title || heading.title}
|
|
89
90
|
</h5>
|
|
90
91
|
)}
|
|
@@ -123,28 +124,34 @@ export const TableOfContents = ({
|
|
|
123
124
|
if (!headings) return null;
|
|
124
125
|
return (
|
|
125
126
|
<div
|
|
126
|
-
className=
|
|
127
|
-
flex: open,
|
|
128
|
-
'bg-white dark:bg-stone-900': open, // just apply when open, so that theme can transition
|
|
129
|
-
'hidden xl:flex': !open,
|
|
130
|
-
})}
|
|
127
|
+
className="fixed article-grid article-grid-gap w-screen z-30 pointer-events-none"
|
|
131
128
|
style={{
|
|
132
129
|
top: top ?? 0,
|
|
133
|
-
height:
|
|
134
|
-
typeof document === 'undefined' || (height && height > window.innerHeight - (top ?? 0))
|
|
135
|
-
? undefined
|
|
136
|
-
: height,
|
|
130
|
+
height: `calc(100vh - ${top ?? 0}px)`,
|
|
137
131
|
}}
|
|
138
|
-
suppressHydrationWarning
|
|
139
132
|
>
|
|
140
|
-
<
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
<div
|
|
134
|
+
className={classNames(
|
|
135
|
+
'pointer-events-auto',
|
|
136
|
+
'col-margin-left flex-col',
|
|
137
|
+
'overflow-hidden',
|
|
138
|
+
// 'border-r border-stone-200 dark:border-stone-700',
|
|
139
|
+
{
|
|
140
|
+
flex: open,
|
|
141
|
+
'bg-white dark:bg-stone-900': open, // just apply when open, so that theme can transition
|
|
142
|
+
'hidden xl:flex': !open,
|
|
143
|
+
},
|
|
144
|
+
)}
|
|
144
145
|
>
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
<nav
|
|
147
|
+
aria-label="Table of Contents"
|
|
148
|
+
className="flex-grow overflow-y-auto transition-opacity mt-6 mr-3"
|
|
149
|
+
style={{ opacity: height && height > 150 ? undefined : 0 }}
|
|
150
|
+
>
|
|
151
|
+
<Headings folder={resolvedProjectSlug} headings={headings} sections={config?.projects} />
|
|
152
|
+
</nav>
|
|
153
|
+
{footer && <div className="flex-none py-4">{footer}</div>}
|
|
154
|
+
</div>
|
|
148
155
|
</div>
|
|
149
156
|
);
|
|
150
157
|
};
|
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>
|