Skip to content

Commit eb7d264

Browse files
authored
Merge pull request #10 from Quansight/namespaces
commit for all recent work updating cards.
2 parents 1ac0488 + 5487f81 commit eb7d264

File tree

10 files changed

+221
-87
lines changed

10 files changed

+221
-87
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ lib
55
labextension
66
tsconfig.tsbuildinfo
77
yarn.lock
8+
.DS_Store

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@rjsf/core": "^2.4.2",
5555
"@types/lodash": "^4.14.168",
5656
"bootstrap": "^4.6.0",
57+
"framer-motion": "^4.0.3",
5758
"lodash": "^4.17.21",
5859
"react-ace": "^9.3.0",
5960
"react-bootstrap": "^1.5.2",

src/components/cardgrid.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React from "react";
2+
import Form from "@rjsf/bootstrap-4";
3+
import Card from "react-bootstrap/Card";
4+
import Col from "react-bootstrap/Col";
5+
import Row from "react-bootstrap/Row";
6+
import { iPyCardSchema } from "../ipyschema";
7+
import { motion } from "framer-motion";
8+
9+
const CardGrid = (props: any): JSX.Element => {
10+
const { cardPayload, handleSubmit } = props;
11+
12+
const cardWidget = (props: any) => {
13+
return (
14+
<Row className="pl-2 pr-2">
15+
{cardPayload.map((ipyinfo: any) => (
16+
<Col key={ipyinfo.kernel_name}>
17+
<motion.div className="pt-3 pb-3" whileHover={{ scale: 1.1 }}>
18+
<a
19+
style={{ cursor: "pointer" }}
20+
onClick={() => handleSubmit(ipyinfo.kernel_name)}
21+
>
22+
<Card
23+
style={{
24+
width: "18rem",
25+
height: "12rem",
26+
}}
27+
>
28+
<Card.Body>
29+
<Card.Title>Jupyter: {ipyinfo.jupyter_name}</Card.Title>
30+
<Card.Title>Kernel: {ipyinfo.kernel_name}</Card.Title>
31+
</Card.Body>
32+
</Card>
33+
</a>
34+
</motion.div>
35+
</Col>
36+
))}
37+
</Row>
38+
);
39+
};
40+
41+
const uiSchema = {
42+
"ui:ArrayFieldTemplate": cardWidget,
43+
};
44+
45+
return (
46+
<div>
47+
<Form schema={iPyCardSchema} uiSchema={uiSchema} children={" "} />
48+
</div>
49+
);
50+
};
51+
52+
export default CardGrid;

src/components/ipyform.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//import React from "react";
2+
//import { JSONSchema7 } from "json-schema";
3+
//import Form from "@rjsf/bootstrap-4";
4+
//import Card from "react-bootstrap/Card";
5+
//import { motion } from "framer-motion";
6+
//
7+
//const iPyArgumentControl = (props: any): JSX.Element => {
8+
// return (
9+
// <div>
10+
// <h1> Hello </h1>
11+
// </div>
12+
// );
13+
//};
14+
//
15+
//const iPyEnvironmentControl = (props: any): JSX.Element => {
16+
// return (
17+
// <div>
18+
// <p>{JSON.stringify(props)}</p>
19+
// </div>
20+
// );
21+
//};
22+
//
23+
//export const iPyForm = (props: any): JSX.Element => {
24+
// return (
25+
// <div>
26+
// <p> {JSON.stringify(props)} </p>
27+
// </div>
28+
// );
29+
//};

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { MainAreaWidget } from "@jupyterlab/apputils";
77

88
import { ILauncher } from "@jupyterlab/launcher";
99

10-
import { CounterWidget } from "./widget";
10+
import { iPyKernelWidget } from "./widget";
1111
/*
1212
* The command IDs used by the react-widget plugin.
1313
*/
@@ -31,8 +31,8 @@ const extension: JupyterFrontEndPlugin<void> = {
3131
label: "ksmm",
3232
icon: (args) => (args["isPalette"] ? null : null),
3333
execute: () => {
34-
const content = new CounterWidget();
35-
const widget = new MainAreaWidget<CounterWidget>({ content });
34+
const content = new iPyKernelWidget();
35+
const widget = new MainAreaWidget<iPyKernelWidget>({ content });
3636
widget.title.label = "ksmm";
3737
app.shell.add(widget, "main");
3838
},

src/ipyschema.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* This file is a special file that houses
3+
* the schema definitions for this entire application.
4+
*
5+
* rjsf is used effectively throughout the application for many purposes,
6+
* and then can be edited for form edits.
7+
*/
8+
import { JSONSchema7 } from "json-schema";
9+
10+
/*
11+
* The following schema complies to iPython Kernel
12+
* Standards. When making changes, note that the UI
13+
* is also subject to change based on the types.
14+
*/
15+
export const iPySchema: JSONSchema7 = {
16+
title: "ipykernel mm",
17+
type: "object",
18+
properties: {
19+
argv: { type: "array", items: { type: "string" } },
20+
env: { type: "object" },
21+
display_name: { type: "string" },
22+
language: { type: "string" },
23+
interrupt_mode: { type: "string" },
24+
metadata: { type: "object" },
25+
},
26+
required: [
27+
"argv",
28+
"display_name",
29+
"env",
30+
"interrupt_mode",
31+
"language",
32+
"metadata",
33+
],
34+
};
35+
36+
/*
37+
* This is the schema for the display cards rendered for
38+
* each kernel. It can be obtained by using the generation
39+
* function. When called on the ipyschema object, the function
40+
* returns a ipyCardSchema.
41+
*/
42+
export const iPyCardSchema: JSONSchema7 = {
43+
title: "iPyKernel Manager",
44+
type: "array",
45+
items: {
46+
type: "object",
47+
properties: {
48+
kernel_name: { type: "string" },
49+
jupyter_name: { type: "string" },
50+
},
51+
},
52+
};

src/selector.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)