Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit 08a70e4

Browse files
committed
Add test extension
1 parent e681024 commit 08a70e4

File tree

6 files changed

+152
-0
lines changed

6 files changed

+152
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules/
55
.ipynb_checkpoints
66
*.log
77
tsconfig.tsbuildinfo
8+
test-jlab-toastify/yarn.lock

test-jlab-toastify/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# test-jlab-toastify
2+
3+
A dummy JupyterLab extension to test `jupyterlab-toastify`.

test-jlab-toastify/package.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "test-jlab-toastify",
3+
"version": "0.1.0",
4+
"description": "A dummy JupyterLab extension to test `jupyterlab-toastify`.",
5+
"keywords": [
6+
"jupyter",
7+
"jupyterlab",
8+
"jupyterlab-extension"
9+
],
10+
"homepage": "https://github.com/fcollonval/jupyterlab_toastify",
11+
"bugs": {
12+
"url": "https://github.com/fcollonval/jupyterlab_toastify/issues"
13+
},
14+
"license": "BSD-3-Clause",
15+
"author": "Frederic Collonval",
16+
"files": [
17+
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
18+
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
19+
],
20+
"main": "lib/index.js",
21+
"types": "lib/index.d.ts",
22+
"style": "style/index.css",
23+
"repository": {
24+
"type": "git",
25+
"url": "https://github.com/fcollonval/jupyterlab_toastify.git"
26+
},
27+
"scripts": {
28+
"build": "tsc",
29+
"clean": "rimraf lib tsconfig.tsbuildinfo",
30+
"prepare": "jlpm run clean && jlpm run build",
31+
"watch": "tsc -w"
32+
},
33+
"dependencies": {
34+
"@jupyterlab/application": "^2.0.0",
35+
"jupyterlab_toastify": "file:./.."
36+
},
37+
"devDependencies": {
38+
"@types/react": "^16.9.0",
39+
"react": "~16.9.0",
40+
"rimraf": "^2.6.1",
41+
"typescript": "~3.7.0"
42+
},
43+
"peerDependencies": {
44+
"react": "^16.0.0",
45+
"react-dom": "^16.6.0"
46+
},
47+
"sideEffects": [
48+
"style/*.css"
49+
],
50+
"jupyterlab": {
51+
"extension": true
52+
},
53+
"publishConfig": {
54+
"access": "private"
55+
},
56+
"resolutions": {
57+
"@types/react": "~16.9.0"
58+
}
59+
}

test-jlab-toastify/src/index.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import {
2+
JupyterFrontEnd,
3+
JupyterFrontEndPlugin
4+
} from "@jupyterlab/application";
5+
6+
import { INotification } from "jupyterlab_toastify";
7+
8+
/**
9+
* Initialization data for the test-jlab-toastify extension.
10+
*/
11+
const extension: JupyterFrontEndPlugin<void> = {
12+
id: "test-jlab-toastify",
13+
autoStart: true,
14+
activate: async (app: JupyterFrontEnd) => {
15+
// Error message notification - do not close automatically
16+
INotification.error("Error");
17+
// Warning message notification - do not close automatically
18+
INotification.warning("Warning");
19+
// Info message notification
20+
INotification.info("Info");
21+
// Success message notification
22+
INotification.success("Success");
23+
24+
// Background task with progression animation
25+
let id = await INotification.inProgress("Task in progress!");
26+
// -> Update text
27+
INotification.update({
28+
toastId: id,
29+
message: "Updating task..."
30+
});
31+
// -> Update text, status and set closing delay (in ms)
32+
INotification.update({
33+
toastId: id,
34+
message: "Task succeed",
35+
type: "success",
36+
autoClose: 3000
37+
});
38+
39+
// Notification with two buttons
40+
INotification.error("Error with button", {
41+
buttons: [
42+
{
43+
label: "Action1",
44+
callback: () => alert("Action1 was clicked")
45+
},
46+
{
47+
label: "Action2",
48+
callback: () => alert("Action2 was clicked")
49+
}
50+
]
51+
});
52+
53+
// Close a toast specified by its id
54+
INotification.dismiss(id);
55+
56+
// Close all toasts
57+
INotification.dismiss();
58+
59+
// Default call using `toast` function
60+
// See https://github.com/fkhadra/react-toastify
61+
INotification.notify("Default");
62+
}
63+
};
64+
65+
export default extension;

test-jlab-toastify/style/index.css

Whitespace-only changes.

test-jlab-toastify/tsconfig.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"composite": true,
5+
"declaration": true,
6+
"esModuleInterop": true,
7+
"incremental": true,
8+
"jsx": "react",
9+
"module": "esnext",
10+
"moduleResolution": "node",
11+
"noEmitOnError": true,
12+
"noImplicitAny": true,
13+
"noUnusedLocals": true,
14+
"preserveWatchOutput": true,
15+
"resolveJsonModule": true,
16+
"outDir": "lib",
17+
"rootDir": "src",
18+
"strict": true,
19+
"strictNullChecks": false,
20+
"target": "es2017",
21+
"types": []
22+
},
23+
"include": ["src/*"]
24+
}

0 commit comments

Comments
 (0)