Skip to content

Commit d051eed

Browse files
committed
feat: a heckton of changes
1 parent eaff142 commit d051eed

39 files changed

+1137
-318
lines changed

website/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@
1212
"clsx": "^1.1.1",
1313
"copy-text-to-clipboard": "^3.0.1",
1414
"glob": "^7.2.0",
15+
"mdast-util-from-markdown": "^1.2.0",
16+
"mdast-util-to-markdown": "^1.3.0",
1517
"next": "12.1.0",
1618
"next-mdx-remote": "^4.0.0",
1719
"prism-react-renderer": "^1.2.1",
1820
"react": "17.0.2",
1921
"react-dom": "17.0.2",
2022
"rehype-katex": "^6.0.2",
23+
"rehype-stringify": "^9.0.3",
24+
"remark-gfm": "^3.0.1",
2125
"remark-math": "^5.1.1",
2226
"remark-parse": "^10.0.0",
27+
"remark-rehype": "^10.1.0",
2328
"remark-stringify": "^10.0.0",
2429
"sass": "^1.49.7",
2530
"unified": "^10.1.0"

website/src/components/Collapsible/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ type CollapsibleElementType = React.ElementType<
150150
* with JS
151151
*/
152152
function getSSRStyle(collapsed: boolean) {
153-
if (canUseDOM) {
153+
if (!canUseDOM) {
154154
return undefined;
155155
}
156156
return collapsed ? CollapsedStyles : ExpandedStyles;

website/src/components/Sidebar/DesktopSidebar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
* LICENSE-docusaurus file in the root directory of the website source tree.
66
*/
77

8+
import c from "clsx";
9+
810
import SidebarItems from "./SidebarItems";
911

12+
import { markdown } from "@/mdx/markdown.module.scss";
1013
import s from "./styles.module.scss";
1114

1215
import type { SidebarProps } from ".";
1316

1417
const DesktopSidebar = ({ items, activePath }: SidebarProps): JSX.Element => {
1518
return (
16-
<nav className={s.desktop}>
19+
<nav className={c(markdown, s.desktop)}>
1720
<ul className={s.items}>
1821
<SidebarItems items={items} activePath={activePath} />
1922
</ul>

website/src/components/Sidebar/SidebarItem.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import s from "./styles.module.scss";
1616

1717
import type { SidebarCategory as SidebarCategoryType, SidebarDoc as SidebarDocType, SidebarItem as SidebarItemType } from "@/lib/helpers/sidebar";
1818
import type { SidebarProps } from ".";
19+
import { canUseDOM } from "@/utils/environment";
1920

2021
interface SidebarItemProps extends Omit<SidebarProps, 'items'>, React.AnchorHTMLAttributes<HTMLAnchorElement> {
2122
item: SidebarItemType
@@ -32,18 +33,19 @@ const SidebarCategory = ({ item, activePath, ...props }: SidebarItemProps): JSX.
3233
const { items, label, href } = item as SidebarCategoryType;
3334

3435
const isActive = isActiveSidebarItem(item, activePath);
35-
const { collapsed, toggleCollapsed } = useCollapsible(!isActive);
36+
const { collapsed, toggleCollapsed } = useCollapsible(!canUseDOM ? true : !isActive);
3637

3738
return (
3839
<li>
3940
<div className={s.category}>
40-
{/* given we have sidebar, could instead just make these buttons that collapse the category maybe? */}
41+
{/* TODO: given we have sidebar, could instead just make these buttons that collapse the category maybe? */}
4142
<Link href={href}><a
4243
className={c(s.link, isActive && s.active)}
44+
// TODO: fix SSR error here
4345
aria-expanded={!collapsed}
44-
>
45-
{label}
46-
</a></Link>
46+
// we construct the label from our locally sourced files so we can assume it's safe
47+
dangerouslySetInnerHTML={{ __html: label }}
48+
/></Link>
4749
<button
4850
className={c(s.arrow, collapsed && s.collapsed)}
4951
aria-label={`toggle the sidebar category '${label}'`}
@@ -71,7 +73,7 @@ const SidebarCategory = ({ item, activePath, ...props }: SidebarItemProps): JSX.
7173
}
7274

7375
const SidebarDoc = ({ item, activePath, ...props }: SidebarItemProps) => {
74-
const { href, title } = item as SidebarDocType;
76+
const { href, label } = item as SidebarDocType;
7577
const isActive = isActiveSidebarItem(item, activePath);
7678

7779
return (
@@ -81,10 +83,10 @@ const SidebarDoc = ({ item, activePath, ...props }: SidebarItemProps) => {
8183
s.link,
8284
isActive && s.active,
8385
)}
86+
// we construct the label from our locally sourced files so we can assume it's safe
87+
dangerouslySetInnerHTML={{ __html: label }}
8488
{...props}
85-
>
86-
{title}
87-
</a></Link>
89+
/></Link>
8890
</li>
8991
)
9092
}

website/src/components/Sidebar/styles.module.scss

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ $arrow-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg
5151

5252
.arrow {
5353
margin: 0 0 0 0.1rem;
54-
cursor: pointer;
5554
align-items: center;
56-
55+
cursor: pointer;
56+
5757
&::before {
5858
content: '';
5959
background: $arrow-icon 50% / 2rem 2rem;
@@ -68,10 +68,6 @@ $arrow-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg
6868
}
6969
}
7070

71-
.active {
72-
color: colors.$red;
73-
}
74-
7571
/* desktop sidebar */
7672

7773
$desktop-sidebar-width: 300px;

website/src/hooks/useIsBrowser.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { useEffect, useState } from "react";
2+
3+
/**
4+
* hook for checking whether the current environment is a browser,
5+
* AND triggers a rerender on first render
6+
*/
7+
export const useIsBrowser = () => {
8+
const [isBrowser, setIsBrowser] = useState(false);
9+
10+
useEffect(() => {
11+
setIsBrowser(true);
12+
}, []);
13+
14+
return isBrowser;
15+
}

website/src/layouts/Layout/styles.module.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ $navbar-height: navbar.$navbar-height;
3939
}
4040

4141
.contentContainer {
42-
padding: 1rem;
42+
padding: 2rem;
4343
margin: 0 auto;
4444
width: 100%;
4545
max-width: 1200px - $sidebar-width; // TODO: pick less arbitrary value
46+
47+
@include mixins.desktop() {
48+
padding: 1rem;
49+
}
4650
}
4751
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Link from "next/link";
2+
import c from "clsx";
3+
4+
import s from "./styles.module.scss";
5+
6+
import type { CategoryPageProps, Item } from "../types";
7+
8+
const itemEmojis: Record<Item['type'], string> = {
9+
doc: '📄️',
10+
category: '📁',
11+
}
12+
13+
const CategoryPage = ({ breadcrumb, items }: CategoryPageProps): JSX.Element => {
14+
15+
return (
16+
<div className={s.grid}>
17+
{items.map(({ type, href, title, description }) => (
18+
<Link key={href} href={href}>
19+
<a className={s.card}>
20+
{/* we construct the label from our locally sourced files so we can assume it's safe */}
21+
<h3 className={c(s.title, s.truncate)} dangerouslySetInnerHTML={{ __html: `${itemEmojis[type]} ${title}` }} />
22+
<p className={c(s.description, s.truncate)} dangerouslySetInnerHTML={{ __html: description ?? '' }} />
23+
</a>
24+
</Link>
25+
))}
26+
</div>
27+
)
28+
}
29+
30+
export default CategoryPage;

website/src/layouts/pages/WorkshopIndexPage/styles.module.scss renamed to website/src/layouts/pages/CategoryPage/styles.module.scss

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,37 @@ $gap: 2rem;
22

33
.grid {
44
display: grid;
5-
grid-template-columns: 1fr 1fr;
5+
grid-template-columns: repeat(auto-fill, minmax(360px , 1fr)); // TODO
66
gap: $gap;
77
}
88

99
.card {
1010
$border-color: #eeeeee; // TODO: unify colors
1111
$shadow-color: hsla(0deg 0% 0% / 20%); // TODO: unify colors
1212

13-
height: 8rem;
1413
border: 1px solid $border-color;
1514
border-radius: 1rem;
16-
padding: 1rem;
17-
15+
padding: 2rem;
16+
17+
transition: box-shadow 400ms ease 0s;
1818
box-shadow: 0 2px 4px $shadow-color;
1919
&:hover {
2020
box-shadow: 0 4px 8px $shadow-color;
2121
}
2222

23-
transition: box-shadow 400ms ease 0s;
23+
.truncate {
24+
overflow: hidden;
25+
white-space: nowrap;
26+
text-overflow: ellipsis;
27+
}
28+
29+
.title {
30+
margin-bottom: 1rem;
31+
}
32+
33+
.description {
34+
flex: 1 1 0;
35+
color: #808080; // TODO
36+
font-size: 0.8rem;
37+
}
2438
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { MDXRemote } from "next-mdx-remote";
2+
import c from "clsx";
3+
4+
import MDXComponents from "@/mdx/components";
5+
6+
import { markdown, content } from "@/mdx/markdown.module.scss";
7+
8+
import type { DocPageProps } from "../types";
9+
10+
const DocPage = ({ breadcrumb, source }: DocPageProps) => {
11+
return (
12+
<article className={c(markdown, content)}>
13+
<MDXRemote {...source} components={MDXComponents} />
14+
</article>
15+
);
16+
}
17+
18+
export default DocPage;

0 commit comments

Comments
 (0)