Skip to content

Commit 49417d1

Browse files
committed
no more build config
1 parent 6867394 commit 49417d1

34 files changed

+390
-879
lines changed

docs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ADD README.md ./
2424
ADD idom/client/app/favicon.ico ./
2525

2626
RUN pip install -e .[all]
27-
RUN IDOM_SHOW_SPINNER=false python -m idom install victory semantic-ui-react @material-ui/core
27+
RUN python -m idom install victory semantic-ui-react @material-ui/core
2828

2929
# Build the Docs
3030
# --------------

docs/main.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
from idom.client.manage import APP_DIR
1212
from idom.server.sanic import PerClientStateServer
1313

14-
idom_build_config = {
15-
"js_dependencies": [
16-
"@material-ui/core",
17-
"victory",
18-
"semantic-ui-react",
19-
]
20-
}
21-
2214
here = Path(__file__).parent
2315

2416
app = Sanic(__name__)
@@ -75,11 +67,12 @@ def production():
7567

7668

7769
def local(path=""):
78-
import webbrowser
70+
from selenium.webdriver import Chrome
7971

8072
thread = server.daemon("127.0.0.1", 5000)
8173
path = f"docs/{path}" if path else ""
82-
webbrowser.open(f"http://127.0.0.1:5000/{path}")
74+
driver = Chrome()
75+
driver.get(f"http://127.0.0.1:5000/{path}")
8376
thread.join()
8477

8578

docs/source/_exts/widget_example.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from pathlib import Path
22

33
from sphinx.application import Sphinx
4-
from docutils.parsers.rst import Directive, directives
4+
from sphinx.util.docutils import SphinxDirective
5+
from docutils.parsers.rst import directives
56
from docutils.statemachine import StringList
67

78
from sphinx_panels.tabs import TabbedDirective
@@ -10,7 +11,7 @@
1011
examples = here.parent / "examples"
1112

1213

13-
class WidgetExample(Directive):
14+
class WidgetExample(SphinxDirective):
1415

1516
has_content = False
1617
required_arguments = 1
@@ -24,7 +25,10 @@ def run(self):
2425

2526
py_ex_path = examples / f"{example_name}.py"
2627
if not py_ex_path.exists():
27-
raise ValueError(f"No example file named {py_ex_path}")
28+
src_file, line_num = self.get_source_info()
29+
raise ValueError(
30+
f"Missing example file named {py_ex_path} referenced by document {src_file}:{line_num}"
31+
)
2832

2933
py_code_tab = TabbedDirective(
3034
"WidgetExample",

docs/source/examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Assuming you already installed ``victory`` as in the :ref:`Install Javascript Mo
7171

7272
Click the bars to trigger an event 👇
7373

74-
.. example:: custom_chart
74+
.. example:: super_simple_chart
7575

7676

7777
Material UI Slider

docs/source/examples/custom_chart.js

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

docs/source/examples/custom_chart.py

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

docs/source/examples/material_ui_button_no_action.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import idom
22

3-
material_ui = idom.Module("@material-ui/core")
4-
MaterialButton = material_ui.Import("Button", fallback="loading...")
3+
material_ui = idom.install("@material-ui/core")
4+
MaterialButton = material_ui.use("Button", fallback="loading...")
55

66
idom.run(
77
idom.element(

docs/source/examples/material_ui_button_on_click.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import idom
44

55

6-
material_ui = idom.Module("@material-ui/core")
7-
MaterialButton = material_ui.Import("Button", fallback="loading...")
6+
material_ui = idom.install("@material-ui/core")
7+
MaterialButton = material_ui.use("Button", fallback="loading...")
88

99

1010
@idom.element

docs/source/examples/material_ui_slider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import idom
44

55

6-
material_ui = idom.Module("@material-ui/core", fallback="loading...")
7-
MaterialSlider = material_ui.Import("Slider")
6+
material_ui = idom.install("@material-ui/core")
7+
MaterialSlider = material_ui.use("Slider", fallback="loading...")
88

99

1010
@idom.element

docs/source/examples/simple_dashboard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from idom.widgets.html import Input
77

88

9-
VictoryLine = idom.Module("victory").Import("VictoryLine", fallback="loading...")
9+
VictoryLine = idom.install("victory").use("VictoryLine", fallback="loading...")
1010

1111

1212
@idom.element
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import React from "./react.js";
2+
import htm from "./htm.js";
3+
4+
const html = htm.bind(React.createElement);
5+
6+
export function SuperSimpleChart(props) {
7+
const data = props.data;
8+
const lastDataIndex = data.length - 1;
9+
10+
const options = {
11+
height: props.height || 100,
12+
width: props.width || 100,
13+
color: props.color || "blue",
14+
lineWidth: props.lineWidth || 2,
15+
axisColor: props.axisColor || "black",
16+
};
17+
18+
const xData = data.map((point) => point.x);
19+
const yData = data.map((point) => point.y);
20+
21+
const domain = {
22+
xMin: Math.min(...xData),
23+
xMax: Math.max(...xData),
24+
yMin: Math.min(...yData),
25+
yMax: Math.max(...yData),
26+
};
27+
28+
return html`<svg
29+
width="${options.width}px"
30+
height="${options.height}px"
31+
viewBox="0 0 ${options.width} ${options.height}"
32+
>
33+
${makePath(props, domain, data, options)} ${makeAxis(props, options)}
34+
</svg>`;
35+
}
36+
37+
function makePath(props, domain, data, options) {
38+
const { xMin, xMax, yMin, yMax } = domain;
39+
const { width, height } = options;
40+
const getSvgX = (x) => ((x - xMin) / (xMax - xMin)) * width;
41+
const getSvgY = (y) => height - ((y - yMin) / (yMax - yMin)) * height;
42+
43+
let pathD = "M " + getSvgX(data[0].x) + " " + getSvgY(data[0].y) + " ";
44+
pathD += data.map((point, i) => {
45+
return "L " + getSvgX(point.x) + " " + getSvgY(point.y) + " ";
46+
});
47+
48+
return html`<path
49+
d="${pathD}"
50+
style=${{
51+
stroke: options.color,
52+
strokeWidth: options.lineWidth,
53+
fill: "none",
54+
}}
55+
/>`;
56+
}
57+
58+
function makeAxis(props, options) {
59+
return html`<g>
60+
<line
61+
x1="0"
62+
y1=${options.height}
63+
x2=${options.width}
64+
y2=${options.height}
65+
style=${{ stroke: options.axisColor, strokeWidth: options.lineWidth * 2 }}
66+
/>
67+
<line
68+
x1="0"
69+
y1="0"
70+
x2="0"
71+
y2=${options.height}
72+
style=${{ stroke: options.axisColor, strokeWidth: options.lineWidth * 2 }}
73+
/>
74+
</g>`;
75+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from pathlib import Path
2+
3+
import idom
4+
5+
6+
path_to_source_file = Path(__file__).parent / "super_simple_chart.js"
7+
super_simple_chart = idom.Module("super-simple-chart", source_file=path_to_source_file)
8+
SuperSimpleChart = super_simple_chart.use("SuperSimpleChart")
9+
10+
11+
idom.run(
12+
idom.element(
13+
lambda: SuperSimpleChart(
14+
{
15+
"data": [
16+
{"x": 1, "y": 2},
17+
{"x": 2, "y": 4},
18+
{"x": 3, "y": 7},
19+
{"x": 4, "y": 3},
20+
{"x": 5, "y": 5},
21+
{"x": 6, "y": 9},
22+
{"x": 7, "y": 6},
23+
],
24+
"height": 300,
25+
"width": 500,
26+
"color": "#24909d",
27+
"lineWidth": 4,
28+
"axisColor": "#bdc3c7",
29+
}
30+
)
31+
)
32+
)

docs/source/examples/victory_chart.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import idom
22

3-
victory = idom.Module("victory", fallback="loading...")
4-
5-
VictoryBar = victory.Import("VictoryBar")
3+
victory = idom.install("victory")
4+
VictoryBar = victory.use("VictoryBar", fallback="loading...")
65

76
idom.run(
87
idom.element(

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Libraries for defining and controlling interactive webpages with Python
1212
getting-started
1313
life-cycle-hooks
1414
core-concepts
15-
custom-javascript
15+
javascript-modules
1616
examples
1717

1818
.. toctree::

docs/source/installation.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ Installation
1414
1515
pip install idom[stable]
1616
17-
* - Javascript Packages
18-
- Installing Javascript packages with IDOM requires npm_.
19-
20-
.. code-block::
21-
22-
idom install some-js-package
23-
24-
For more info see the :ref:`Custom Javascript` section.
25-
2617
* - Extra Features
2718

2819
- To install **specific** features see :ref:`Extra Features`, but to install all of them:

0 commit comments

Comments
 (0)