-
-
Notifications
You must be signed in to change notification settings - Fork 303
/
SandboxList.tsx
72 lines (67 loc) · 2.38 KB
/
SandboxList.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { Fragment, ReactElement } from "react";
import qs from "qs";
import {
Card,
CardActions,
CardContent,
CardHeader,
CardTitle,
} from "@react-md/card";
import { TextIconSpacing } from "@react-md/icon";
import { CodeSVGIcon, OpenInBrowserSVGIcon } from "@react-md/material-icons";
import { Typography } from "@react-md/typography";
import LinkButton from "components/LinkButton";
import sandboxes from "constants/sandboxes";
import { toId, toTitle } from "utils/toTitle";
import styles from "./SandboxList.module.scss";
export default function SandboxList(): ReactElement {
return (
<div className={styles.container}>
{Object.entries(sandboxes).map(([packageName, lookups]) => {
const pkgName = toTitle(packageName, " ", true);
return (
<Card key={pkgName} className={styles.card}>
<CardHeader>
<CardTitle id={`${toId(pkgName)}`}>{pkgName}</CardTitle>
</CardHeader>
<Fragment key={pkgName}>
{Object.keys(lookups).map((demoName) => {
const name = toTitle(demoName, " ", true);
const href = `/sandbox?${qs.stringify({ pkg: pkgName, name })}`;
const demoHref = `/packages/${toTitle(
packageName,
"-",
true
).toLowerCase()}/demos#${toId(name)}-title`;
if (name.endsWith("-js")) {
return null;
}
return (
<Fragment key={name}>
<CardContent>
<Typography type="headline-6" margin="none">
{name}
</Typography>
</CardContent>
<CardActions>
<LinkButton href={href}>
<TextIconSpacing icon={<CodeSVGIcon />}>
View Code
</TextIconSpacing>
</LinkButton>
<LinkButton href={demoHref}>
<TextIconSpacing icon={<OpenInBrowserSVGIcon />}>
View Demo
</TextIconSpacing>
</LinkButton>
</CardActions>
</Fragment>
);
})}
</Fragment>
</Card>
);
})}
</div>
);
}