Skip to content

Commit 764a5a8

Browse files
authored
Unify vdom interface (#841)
* begin vdom interface unification * turn script into cli app * misc fixes * convert vdom func usages too * minor fix * start fixes in source/tests/docs * more fixes * correct more tests * improve warning * improve coverage * fix typo * remove console logs * Python<3.10 compat * more cov * skip python<3.9 * misc fixes * better skip * misc typing improvements + fix ico path * error if no files * test py 3.11 * warn on dir does not exist * fix tests * fix old class_name typos * remove unused var
1 parent cc47748 commit 764a5a8

File tree

89 files changed

+1417
-664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1417
-664
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
session-name: test_python_suite
2424
session-arguments: --maxfail=3 --no-cov
2525
runs-on-array: '["ubuntu-latest", "macos-latest", "windows-latest"]'
26-
python-version-array: '["3.7", "3.8", "3.9", "3.10"]'
26+
python-version-array: '["3.7", "3.8", "3.9", "3.10", "3.11"]'
2727
docs:
2828
uses: ./.github/workflows/.nox-session.yml
2929
with:

docs/examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def Wrapper():
122122
def PrintView():
123123
text, set_text = idom.hooks.use_state(print_buffer.getvalue())
124124
print_buffer.set_callback(set_text)
125-
return idom.html.pre({"class": "printout"}, text) if text else idom.html.div()
125+
return idom.html.pre(text, class_name="printout") if text else idom.html.div()
126126

127127
return Wrapper()
128128

docs/source/_custom_js/package-lock.json

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/source/_exts/custom_autosectionlabel.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
from fnmatch import fnmatch
8-
from typing import Any, Dict, cast
8+
from typing import Any, cast
99

1010
from docutils import nodes
1111
from docutils.nodes import Node
@@ -30,7 +30,6 @@ def get_node_depth(node: Node) -> int:
3030

3131
def register_sections_as_label(app: Sphinx, document: Node) -> None:
3232
docname = app.env.docname
33-
print(docname)
3433

3534
for pattern in app.config.autosectionlabel_skip_docs:
3635
if fnmatch(docname, pattern):
@@ -67,7 +66,7 @@ def register_sections_as_label(app: Sphinx, document: Node) -> None:
6766
domain.labels[name] = docname, labelid, sectname
6867

6968

70-
def setup(app: Sphinx) -> Dict[str, Any]:
69+
def setup(app: Sphinx) -> dict[str, Any]:
7170
app.add_config_value("autosectionlabel_prefix_document", False, "env")
7271
app.add_config_value("autosectionlabel_maxdepth", None, "env")
7372
app.add_config_value("autosectionlabel_skip_docs", [], "env")

docs/source/guides/adding-interactivity/components-with-state/_examples/adding_state_variable/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def handle_click(event):
2525
url = sculpture["url"]
2626

2727
return html.div(
28-
html.button({"onClick": handle_click}, "Next"),
28+
html.button("Next", on_click=handle_click),
2929
html.h2(name, " by ", artist),
3030
html.p(f"({bounded_index + 1} of {len(sculpture_data)})"),
31-
html.img({"src": url, "alt": alt, "style": {"height": "200px"}}),
31+
html.img(src=url, alt=alt, style={"height": "200px"}),
3232
html.p(description),
3333
)
3434

docs/source/guides/adding-interactivity/components-with-state/_examples/isolated_state/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ def handle_more_click(event):
2929
url = sculpture["url"]
3030

3131
return html.div(
32-
html.button({"onClick": handle_next_click}, "Next"),
32+
html.button("Next", on_click=handle_next_click),
3333
html.h2(name, " by ", artist),
3434
html.p(f"({bounded_index + 1} or {len(sculpture_data)})"),
35-
html.img({"src": url, "alt": alt, "style": {"height": "200px"}}),
35+
html.img(src=url, alt=alt, style={"height": "200px"}),
3636
html.div(
3737
html.button(
38-
{"onClick": handle_more_click},
39-
f"{'Show' if show_more else 'Hide'} details",
38+
f"{('Show' if show_more else 'Hide')} details",
39+
on_click=handle_more_click,
4040
),
4141
(html.p(description) if show_more else ""),
4242
),
@@ -46,8 +46,8 @@ def handle_more_click(event):
4646
@component
4747
def App():
4848
return html.div(
49-
html.section({"style": {"width": "50%", "float": "left"}}, Gallery()),
50-
html.section({"style": {"width": "50%", "float": "left"}}, Gallery()),
49+
html.section(Gallery(), style={"width": "50%", "float": "left"}),
50+
html.section(Gallery(), style={"width": "50%", "float": "left"}),
5151
)
5252

5353

docs/source/guides/adding-interactivity/components-with-state/_examples/multiple_state_variables/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ def handle_more_click(event):
2929
url = sculpture["url"]
3030

3131
return html.div(
32-
html.button({"onClick": handle_next_click}, "Next"),
32+
html.button("Next", on_click=handle_next_click),
3333
html.h2(name, " by ", artist),
3434
html.p(f"({bounded_index + 1} or {len(sculpture_data)})"),
35-
html.img({"src": url, "alt": alt, "style": {"height": "200px"}}),
35+
html.img(src=url, alt=alt, style={"height": "200px"}),
3636
html.div(
3737
html.button(
38-
{"onClick": handle_more_click},
39-
f"{'Show' if show_more else 'Hide'} details",
38+
f"{('Show' if show_more else 'Hide')} details",
39+
on_click=handle_more_click,
4040
),
4141
(html.p(description) if show_more else ""),
4242
),

docs/source/guides/adding-interactivity/components-with-state/_examples/when_variables_are_not_enough/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ def handle_click(event):
3131
url = sculpture["url"]
3232

3333
return html.div(
34-
html.button({"onClick": handle_click}, "Next"),
34+
html.button("Next", on_click=handle_click),
3535
html.h2(name, " by ", artist),
3636
html.p(f"({bounded_index + 1} or {len(sculpture_data)})"),
37-
html.img({"src": url, "alt": alt, "style": {"height": "200px"}}),
37+
html.img(src=url, alt=alt, style={"height": "200px"}),
3838
html.p(description),
3939
)
4040

docs/source/guides/adding-interactivity/dangers-of-mutability/_examples/dict_remove.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,21 @@ def handle_click(event):
2626
return handle_click
2727

2828
return html.div(
29-
html.button({"onClick": handle_add_click}, "add term"),
29+
html.button("add term", on_click=handle_add_click),
3030
html.label(
3131
"Term: ",
32-
html.input({"value": term_to_add, "onChange": handle_term_to_add_change}),
32+
html.input(value=term_to_add, on_change=handle_term_to_add_change),
3333
),
3434
html.label(
3535
"Definition: ",
3636
html.input(
37-
{
38-
"value": definition_to_add,
39-
"onChange": handle_definition_to_add_change,
40-
}
37+
value=definition_to_add, on_change=handle_definition_to_add_change
4138
),
4239
),
4340
html.hr(),
4441
[
4542
html.div(
46-
html.button(
47-
{"onClick": make_delete_click_handler(term)}, "delete term"
48-
),
43+
html.button("delete term", on_click=make_delete_click_handler(term)),
4944
html.dt(term),
5045
html.dd(definition),
5146
key=term,

docs/source/guides/adding-interactivity/dangers-of-mutability/_examples/dict_update.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,15 @@ def handle_email_change(event):
2323
return html.div(
2424
html.label(
2525
"First name: ",
26-
html.input(
27-
{"value": person["first_name"], "onChange": handle_first_name_change},
28-
),
26+
html.input(value=person["first_name"], on_change=handle_first_name_change),
2927
),
3028
html.label(
3129
"Last name: ",
32-
html.input(
33-
{"value": person["last_name"], "onChange": handle_last_name_change},
34-
),
30+
html.input(value=person["last_name"], on_change=handle_last_name_change),
3531
),
3632
html.label(
3733
"Email: ",
38-
html.input(
39-
{"value": person["email"], "onChange": handle_email_change},
40-
),
34+
html.input(value=person["email"], on_change=handle_email_change),
4135
),
4236
html.p(f"{person['first_name']} {person['last_name']} {person['email']}"),
4337
)

0 commit comments

Comments
 (0)