CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/components/demo-cell.tsx
Views: 687
1
import { TAG_TO_FEATURE } from "@cocalc/util/db-schema/accounts";
2
import Markdown from "@cocalc/frontend/editors/slate/static-markdown";
3
import { FileContext } from "@cocalc/frontend/lib/file-context";
4
5
interface DemoCellProps {
6
tag: keyof typeof TAG_TO_FEATURE;
7
style?: React.CSSProperties;
8
}
9
10
export default function DemoCell({
11
tag,
12
style = { maxWidth: "800px", margin: "auto" },
13
}: Readonly<DemoCellProps>) {
14
const x = TAG_TO_FEATURE[tag];
15
if (x == null) return null;
16
const { language, welcome } = x;
17
const value = "```" + language + "\n" + (welcome ?? "2+3") + "\n```\n";
18
return (
19
<FileContext.Provider value={{ jupyterApiEnabled: true }}>
20
<Markdown value={value} style={style} />
21
</FileContext.Provider>
22
);
23
}
24
25