Skip to content

Commit 8a71651

Browse files
committed
add basic example with cytoscape
1 parent fd408fa commit 8a71651

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

Diff for: docs/source/_static/custom.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,9 @@ function useJsonPatchCallback(initial) {
13981398
// We CANNOT mutate the part of the document because React checks some
13991399
// attributes of the model (e.g. model.attributes.style is checked for
14001400
// identity).
1401-
doc.current = applyNonMutativePatch(doc, patch);
1401+
doc.current = applyNonMutativePatch(
1402+
doc.current,
1403+
patch);
14021404
} else {
14031405
// We CAN mutate the document here though because we know that nothing above
14041406
// The patch `path` is changing. Thus, maintaining the identity for that section

Diff for: docs/source/custom_js/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: docs/source/examples/cytoscape.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import idom
2+
3+
4+
react_cytoscapejs = idom.web.module_from_template(
5+
# we need to use this template because react-cytoscapejs uses a default export
6+
"react-default",
7+
"react-cytoscapejs",
8+
fallback="⌛",
9+
)
10+
Cytoscape = idom.web.export(react_cytoscapejs, "default")
11+
12+
13+
@idom.component
14+
def CytoscapeGraph():
15+
return Cytoscape(
16+
{
17+
"style": {"width": "100%", "height": "200px"},
18+
"elements": [
19+
{
20+
"data": {"id": "one", "label": "Node 1"},
21+
"position": {"x": 100, "y": 100},
22+
},
23+
{
24+
"data": {"id": "two", "label": "Node 2"},
25+
"position": {"x": 200, "y": 100},
26+
},
27+
{
28+
"data": {
29+
"source": "one",
30+
"target": "two",
31+
"label": "Edge from Node1 to Node2",
32+
}
33+
},
34+
],
35+
}
36+
)
37+
38+
39+
idom.run(CytoscapeGraph)

Diff for: docs/source/index.rst

+8-5
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ A package for building responsive user interfaces in pure Python.
7070

7171
.. grid-item-card::
7272

73-
.. interactive-widget:: slideshow
73+
.. interactive-widget:: cytoscape
7474
:no-activate-button:
7575

7676
.. grid-item-card::
7777

78-
.. interactive-widget:: audio_player
78+
.. interactive-widget:: slideshow
7979
:no-activate-button:
8080

8181
.. grid-item-card::
8282

83-
.. interactive-widget:: todo
83+
.. interactive-widget:: audio_player
8484
:no-activate-button:
8585

8686
.. grid-item::
@@ -93,8 +93,6 @@ A package for building responsive user interfaces in pure Python.
9393
.. interactive-widget:: simple_dashboard
9494
:no-activate-button:
9595

96-
97-
9896
.. grid-item-card::
9997

10098
.. interactive-widget:: matplotlib_plot
@@ -104,3 +102,8 @@ A package for building responsive user interfaces in pure Python.
104102

105103
.. interactive-widget:: material_ui_button_on_click
106104
:no-activate-button:
105+
106+
.. grid-item-card::
107+
108+
.. interactive-widget:: todo
109+
:no-activate-button:

0 commit comments

Comments
 (0)