-
-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add vdom-extension #37
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e1098d1
v0.10.1
gnestor fd2d6f8
Add vdom-extension
gnestor c2420b0
Clean up comments
gnestor 8d368eb
Upgrade to react 15.6.2
gnestor 588d9cf
Add README for vdom-extension
gnestor 6ae319f
Add local type definitions for @nteract/transform-vdom
gnestor 5963731
Add vdom-extension to postBuild
gnestor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
"packages": [ | ||
"packages/*" | ||
], | ||
"version": "0.10.0" | ||
"version": "0.10.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# vdom-extension | ||
|
||
A JupyterLab extension for rendering VirtualDOM using React | ||
|
||
![demo](http://g.recordit.co/EIwAIBsGBh.gif) | ||
|
||
## Prerequisites | ||
|
||
* JupyterLab ^0.27.0 | ||
|
||
## Usage | ||
|
||
To render VDOM output in IPython: | ||
|
||
```python | ||
from IPython.display import display | ||
|
||
def VDOM(data={}): | ||
bundle = {} | ||
bundle['application/vdom.v1+json'] = data | ||
display(bundle, raw=True) | ||
|
||
VDOM({ | ||
'tagName': 'div', | ||
'attributes': {}, | ||
'children': [{ | ||
'tagName': 'h1', | ||
'attributes': {}, | ||
'children': 'Our Incredibly Declarative Example', | ||
'key': 0 | ||
}, { | ||
'tagName': 'p', | ||
'attributes': {}, | ||
'children': ['Can you believe we wrote this ', { | ||
'tagName': 'b', | ||
'attributes': {}, | ||
'children': 'in Python', | ||
'key': 1 | ||
}, '?'], | ||
'key': 1 | ||
}, { | ||
'tagName': 'img', | ||
'attributes': { | ||
'src': 'https://media.giphy.com/media/xUPGcguWZHRC2HyBRS/giphy.gif' | ||
}, | ||
'key': 2 | ||
}, { | ||
'tagName': 'p', | ||
'attributes': {}, | ||
'children': ['What will ', { | ||
'tagName': 'b', | ||
'attributes': {}, | ||
'children': 'you', | ||
'key': 1 | ||
}, ' create next?'], | ||
'key': 3 | ||
}] | ||
}) | ||
``` | ||
|
||
Using the [vdom Python library](https://github.com/nteract/vdom): | ||
|
||
```python | ||
from vdom import h1, p, img, div, b | ||
|
||
div([ | ||
h1('Our Incredibly Declarative Example'), | ||
p(['Can you believe we wrote this ', b('in Python'), '?']), | ||
img(src="https://media.giphy.com/media/xUPGcguWZHRC2HyBRS/giphy.gif"), | ||
p(['What will ', b('you'), ' create next?']), | ||
]) | ||
``` | ||
|
||
To render a `.vdom` or `.vdom.json` file as a tree, simply open it: | ||
|
||
## Install | ||
|
||
```bash | ||
jupyter labextension install @jupyterlab/vdom-extension | ||
``` | ||
|
||
## Development | ||
|
||
```bash | ||
# Clone the repo to your local environment | ||
git clone https://github.com/jupyterlab/jupyter-renderers.git | ||
cd jupyter-renderers | ||
# Install dependencies | ||
npm install | ||
# Build Typescript source | ||
npm run build | ||
# Link your development version of the extension with JupyterLab | ||
jupyter labextension link packages/vdom-extension | ||
# Rebuild Typescript source after making changes | ||
npm run build | ||
# Rebuild JupyterLab after making any changes | ||
jupyter lab build | ||
``` | ||
|
||
## Uninstall | ||
|
||
```bash | ||
jupyter labextension uninstall @jupyterlab/vdom-extension | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "@jupyterlab/vdom-extension", | ||
"version": "0.10.0", | ||
"description": "JupyterLab - VDOM Renderer", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"files": [ | ||
"lib/*.d.ts", | ||
"lib/*.js", | ||
"style/*" | ||
], | ||
"directories": { | ||
"lib": "lib/" | ||
}, | ||
"jupyterlab": { | ||
"mimeExtension": true | ||
}, | ||
"dependencies": { | ||
"@jupyterlab/rendermime-interfaces": "^0.3.0", | ||
"@phosphor/widgets": "^1.3.0", | ||
"@nteract/transform-vdom": "^1.1.1", | ||
"react": "^15.6.2", | ||
"react-dom": "^15.6.2" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^15.0.33", | ||
"@types/react-dom": "^15.5.1", | ||
"rimraf": "^2.5.2", | ||
"typescript": "~2.3.1" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"clean": "rimraf lib", | ||
"watch": "tsc -w" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jupyterlab/jupyter-renderers.git" | ||
}, | ||
"author": "Project Jupyter", | ||
"license": "BSD-3-Clause", | ||
"bugs": { | ||
"url": "https://github.com/jupyterlab/jupyter-renderers/issues" | ||
}, | ||
"homepage": "https://github.com/jupyterlab/jupyter-renderers" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this is merged now -- if you want this to be a little bit more trim
vdom
allows positional arguments instead of arrays, so you can now write:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#44