@myst-theme/site 0.15.1 → 0.16.0

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.15.1",
3
+ "version": "0.16.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -21,11 +21,11 @@
21
21
  "dependencies": {
22
22
  "@headlessui/react": "^1.7.15",
23
23
  "@heroicons/react": "^2.0.18",
24
- "@myst-theme/common": "^0.15.1",
25
- "@myst-theme/diagrams": "^0.15.1",
26
- "@myst-theme/frontmatter": "^0.15.1",
27
- "@myst-theme/providers": "^0.15.1",
28
- "@myst-theme/search": "^0.15.1",
24
+ "@myst-theme/common": "^0.16.0",
25
+ "@myst-theme/diagrams": "^0.16.0",
26
+ "@myst-theme/frontmatter": "^0.16.0",
27
+ "@myst-theme/providers": "^0.16.0",
28
+ "@myst-theme/search": "^0.16.0",
29
29
  "@radix-ui/react-collapsible": "^1.0.3",
30
30
  "@radix-ui/react-dialog": "^1.0.3",
31
31
  "@radix-ui/react-visually-hidden": "^1.1.0",
@@ -33,9 +33,9 @@
33
33
  "lodash.throttle": "^4.1.1",
34
34
  "myst-common": "^1.7.9",
35
35
  "myst-config": "^1.7.9",
36
- "myst-demo": "^0.15.1",
36
+ "myst-demo": "^0.16.0",
37
37
  "myst-spec-ext": "^1.7.9",
38
- "myst-to-react": "^0.15.1",
38
+ "myst-to-react": "^0.16.0",
39
39
  "nbtx": "^0.2.3",
40
40
  "node-cache": "^5.1.2",
41
41
  "node-fetch": "^2.6.11",
@@ -82,7 +82,11 @@ export const ConfigurablePrimaryNavigation = ({
82
82
 
83
83
  // the logic on the following line looks wrong, this will return `null` or `<></>`
84
84
  // we should just return `null` if `hide_toc` is true?
85
- if (hide_toc) return children ? null : <>{children}</>;
85
+ if (!nav && hide_toc) return children ? null : <>{children}</>;
86
+ if (nav && hide_toc) {
87
+ headings = undefined;
88
+ footer = null;
89
+ }
86
90
 
87
91
  return (
88
92
  <>
@@ -98,6 +102,7 @@ export const ConfigurablePrimaryNavigation = ({
98
102
  nav={nav}
99
103
  headings={headings}
100
104
  footer={footer}
105
+ hide_toc={hide_toc}
101
106
  mobileOnly={mobileOnly}
102
107
  />
103
108
  {children}
@@ -84,7 +84,7 @@ export function SidebarNavItem({ item }: { item: SiteNavItem }) {
84
84
  export function SidebarNav({ nav }: { nav?: SiteManifest['nav'] }) {
85
85
  if (!nav) return null;
86
86
  return (
87
- <div className="w-full px-1 dark:text-white">
87
+ <div className="w-full px-1 dark:text-white font-medium">
88
88
  {nav.map((item) => {
89
89
  return <SidebarNavItem key={'url' in item ? item.url : item.title} item={item} />;
90
90
  })}
@@ -126,12 +126,14 @@ export const PrimarySidebar = ({
126
126
  nav,
127
127
  footer,
128
128
  headings,
129
+ hide_toc,
129
130
  mobileOnly,
130
131
  }: {
131
132
  sidebarRef?: React.RefObject<HTMLElement>;
132
133
  nav?: SiteManifest['nav'];
133
134
  headings?: Heading[];
134
135
  footer?: React.ReactNode;
136
+ hide_toc?: boolean;
135
137
  mobileOnly?: boolean;
136
138
  }) => {
137
139
  const top = useThemeTop();
@@ -156,6 +158,7 @@ export const PrimarySidebar = ({
156
158
  'fixed',
157
159
  `xl:${grid}`, // for example, xl:article-grid
158
160
  'grid-gap xl:w-screen xl:pointer-events-none overflow-auto max-xl:min-w-[300px]',
161
+ { 'lg:hidden': nav && hide_toc },
159
162
  { hidden: !open, 'z-30': open, 'z-10': !open },
160
163
  )}
161
164
  style={{ top }}
@@ -2,9 +2,15 @@ import React, { useEffect } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import * as Collapsible from '@radix-ui/react-collapsible';
4
4
  import type { Heading } from '@myst-theme/common';
5
- import { useBaseurl, useNavLinkProvider, useNavOpen, withBaseurl } from '@myst-theme/providers';
5
+ import {
6
+ useBaseurl,
7
+ useLinkProvider,
8
+ useNavLinkProvider,
9
+ useNavOpen,
10
+ withBaseurl,
11
+ } from '@myst-theme/providers';
6
12
  import { useLocation, useNavigation } from '@remix-run/react';
7
- import { ChevronRightIcon } from '@heroicons/react/24/solid';
13
+ import { ChevronRightIcon, ArrowTopRightOnSquareIcon } from '@heroicons/react/24/solid';
8
14
 
9
15
  type NestedHeading = Heading & { id: string; children: NestedHeading[] };
10
16
 
@@ -72,9 +78,34 @@ function LinkItem({
72
78
  heading: NestedHeading;
73
79
  onClick?: () => void;
74
80
  }) {
81
+ const Link = useLinkProvider();
75
82
  const NavLink = useNavLinkProvider();
76
83
  const baseurl = useBaseurl();
77
84
  const [, setOpen] = useNavOpen();
85
+ // Render external URL
86
+ if (heading.url) {
87
+ const target = heading.open_in_same_tab ? '_self' : '_blank';
88
+ return (
89
+ <Link
90
+ title={`${heading.enumerator ? `${heading.enumerator} ` : ''}${heading.title}`}
91
+ className={classNames(
92
+ 'block break-words focus:outline outline-blue-200 outline-2 rounded',
93
+ className,
94
+ )}
95
+ to={heading.url}
96
+ onClick={() => {
97
+ onClick?.();
98
+ setOpen(false);
99
+ }}
100
+ target={target}
101
+ >
102
+ <span className="inline align-middle">
103
+ {`${heading.enumerator ? `${heading.enumerator} ` : ''}${heading.title}`}
104
+ </span>
105
+ <ArrowTopRightOnSquareIcon className="inline h-4 w-4 align-middle ml-[0.2rem]" />
106
+ </Link>
107
+ );
108
+ }
78
109
  if (!heading.path) {
79
110
  return (
80
111
  <div
@@ -84,7 +115,9 @@ function LinkItem({
84
115
  onClick?.();
85
116
  }}
86
117
  >
87
- {`${heading.enumerator ? `${heading.enumerator} ` : ''}${heading.short_title || heading.title}`}
118
+ {`${heading.enumerator ? `${heading.enumerator} ` : ''}${
119
+ heading.short_title || heading.title
120
+ }`}
88
121
  </div>
89
122
  );
90
123
  }
@@ -102,7 +135,9 @@ function LinkItem({
102
135
  setOpen(false);
103
136
  }}
104
137
  >
105
- {`${heading.enumerator ? `${heading.enumerator} ` : ''}${heading.short_title || heading.title}`}
138
+ {`${heading.enumerator ? `${heading.enumerator} ` : ''}${
139
+ heading.short_title || heading.title
140
+ }`}
106
141
  </NavLink>
107
142
  );
108
143
  }
@@ -11,8 +11,8 @@ export function ThemeButton({ className = 'w-8 h-8 mx-3' }: { className?: string
11
11
  'theme rounded-full aspect-square border border-stone-700 dark:border-white hover:bg-neutral-100 border-solid overflow-hidden text-stone-700 dark:text-white hover:text-stone-500 dark:hover:text-neutral-800',
12
12
  className,
13
13
  )}
14
- title={`Toggle theme between light and dark mode.`}
15
- aria-label={`Toggle theme between light and dark mode.`}
14
+ title={`Toggle theme between light and dark mode`}
15
+ aria-label={`Toggle theme between light and dark mode`}
16
16
  onClick={nextTheme}
17
17
  >
18
18
  <MoonIcon className="h-full w-full p-0.5 hidden dark:block" />
@@ -112,8 +112,13 @@ export function TopNav({ hideToc, hideSearch }: { hideToc?: boolean; hideSearch?
112
112
  <div className="bg-white/80 backdrop-blur dark:bg-stone-900/80 shadow dark:shadow-stone-700 p-3 md:px-8 sticky w-screen top-0 z-30 h-[60px]">
113
113
  <nav className="flex items-center justify-between flex-nowrap max-w-[1440px] mx-auto">
114
114
  <div className="flex flex-row xl:min-w-[19.5rem] mr-2 sm:mr-7 justify-start items-center shrink-0">
115
- {!hideToc && (
116
- <div className="block xl:hidden">
115
+ {
116
+ <div
117
+ className={classNames('block', {
118
+ 'lg:hidden': nav && hideToc,
119
+ 'xl:hidden': !(nav && hideToc),
120
+ })}
121
+ >
117
122
  <button
118
123
  className="flex items-center border-stone-400 text-stone-800 hover:text-stone-900 dark:text-stone-200 hover:dark:text-stone-100"
119
124
  onClick={() => {
@@ -124,7 +129,7 @@ export function TopNav({ hideToc, hideSearch }: { hideToc?: boolean; hideSearch?
124
129
  <span className="sr-only">Open Menu</span>
125
130
  </button>
126
131
  </div>
127
- )}
132
+ }
128
133
  <HomeLink name={title} logo={logo} logoDark={logo_dark} logoText={logo_text} />
129
134
  </div>
130
135
  <div className="flex items-center flex-grow w-auto">