Skip to content

Commit 7c06fe1

Browse files
authored
feat: Jupyter accepts children (#4663)
* Fixes an issue where I forgot to allow a children prop in JupyterRoot * Also moves the Jupyter components to a subdirectory * Also fixes the Plasmic styling
1 parent d496064 commit 7c06fe1

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

apps/frontend/components/widgets/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
JupyterRootMeta,
2121
JupyterNotebookMeta,
2222
JupyterConsoleMeta,
23-
} from "@/components/widgets/jupyter-meta";
23+
} from "@/components/widgets/jupyter/jupyter-meta";
2424
import { Markdown, MarkdownMeta } from "@/components/widgets/markdown";
2525
import {
2626
MonacoEditor,
@@ -47,15 +47,15 @@ export function registerAllWidgets(PLASMIC: NextJsPlasmicComponentLoader) {
4747
AlgoliaSearchListMeta,
4848
);
4949
PLASMIC.registerComponent(
50-
dynamic(() => import("./jupyter-root"), { ssr: false }),
50+
dynamic(() => import("./jupyter/jupyter-root"), { ssr: false }),
5151
JupyterRootMeta,
5252
);
5353
PLASMIC.registerComponent(
54-
dynamic(() => import("./jupyter-notebook"), { ssr: false }),
54+
dynamic(() => import("./jupyter/jupyter-notebook"), { ssr: false }),
5555
JupyterNotebookMeta,
5656
);
5757
PLASMIC.registerComponent(
58-
dynamic(() => import("./jupyter-console"), { ssr: false }),
58+
dynamic(() => import("./jupyter/jupyter-console"), { ssr: false }),
5959
JupyterConsoleMeta,
6060
);
6161

apps/frontend/components/widgets/jupyter-console.tsx renamed to apps/frontend/components/widgets/jupyter/jupyter-console.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22
import { Console } from "@datalayer/jupyter-react";
3-
import type { JupyterConsoleProps } from "@/components/widgets/jupyter-meta";
3+
import type { JupyterConsoleProps } from "@/components/widgets/jupyter/jupyter-meta";
44

55
function JupyterConsole(props: JupyterConsoleProps) {
66
return (

apps/frontend/components/widgets/jupyter-meta.tsx renamed to apps/frontend/components/widgets/jupyter/jupyter-meta.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
"use client";
22

3+
import { ReactElement } from "react";
34
import { CodeComponentMeta } from "@plasmicapp/loader-nextjs";
45
import type { JupyterProps, INotebookProps } from "@datalayer/jupyter-react";
56

67
type JupyterRootProps = Partial<JupyterProps> & {
78
className?: string;
9+
children?: ReactElement;
810
};
911

1012
const JupyterRootMeta: CodeComponentMeta<JupyterRootProps> = {
1113
name: "JupyterRoot",
1214
description: "Root wrapper for Jupyter components",
1315
props: {
16+
children: "slot",
1417
jupyterServerUrl: "string",
1518
jupyterServerToken: "string",
1619
lite: "boolean",
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
"use client";
22
import { Notebook } from "@datalayer/jupyter-react";
3-
import type { JupyterNotebookProps } from "@/components/widgets/jupyter-meta";
3+
import type { JupyterNotebookProps } from "@/components/widgets/jupyter/jupyter-meta";
44

55
function JupyterNotebook(props: JupyterNotebookProps) {
6-
return <Notebook className={props.className} {...props} />;
6+
const { className, ...restProps } = props;
7+
return (
8+
<div className={className}>
9+
<Notebook {...restProps} />
10+
</div>
11+
);
712
}
813

914
export default JupyterNotebook;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
"use client";
22

33
import { Jupyter } from "@datalayer/jupyter-react";
4-
import type { JupyterRootProps } from "@/components/widgets/jupyter-meta";
4+
import type { JupyterRootProps } from "@/components/widgets/jupyter/jupyter-meta";
55

66
function JupyterRoot(props: JupyterRootProps) {
7-
return <Jupyter className={props.className} {...props} />;
7+
const { className, children, ...restProps } = props;
8+
return (
9+
<div className={className}>
10+
<Jupyter {...restProps}>{children}</Jupyter>;
11+
</div>
12+
);
813
}
914

1015
export default JupyterRoot;

0 commit comments

Comments
 (0)