Skip to content

Commit f1bf70c

Browse files
committed
camelCase to snake_case + rewrite util
1 parent 7ee7b98 commit f1bf70c

File tree

42 files changed

+452
-233
lines changed

Some content is hidden

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

42 files changed

+452
-233
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def handle_click(event):
2525
url = sculpture["url"]
2626

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

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

+3-3
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({"on_click": handle_next_click}, "Next"),
3333
html.h2(name, " by ", artist),
3434
html.p(f"({bounded_index + 1} or {len(sculpture_data)})"),
3535
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+
{"on_click": handle_more_click},
39+
f"{('Show' if show_more else 'Hide')} details",
4040
),
4141
(html.p(description) if show_more else ""),
4242
),

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

+3-3
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({"on_click": handle_next_click}, "Next"),
3333
html.h2(name, " by ", artist),
3434
html.p(f"({bounded_index + 1} or {len(sculpture_data)})"),
3535
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+
{"on_click": handle_more_click},
39+
f"{('Show' if show_more else 'Hide')} details",
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def handle_click(event):
3131
url = sculpture["url"]
3232

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

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ 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({"on_click": handle_add_click}, "add term"),
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(
3737
{
3838
"value": definition_to_add,
39-
"onChange": handle_definition_to_add_change,
39+
"on_change": handle_definition_to_add_change,
4040
}
4141
),
4242
),
@@ -45,7 +45,7 @@ def handle_click(event):
4545
html.div(
4646
{"key": term},
4747
html.button(
48-
{"onClick": make_delete_click_handler(term)}, "delete term"
48+
{"on_click": make_delete_click_handler(term)}, "delete term"
4949
),
5050
html.dt(term),
5151
html.dd(definition),

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,18 @@ def handle_email_change(event):
2424
html.label(
2525
"First name: ",
2626
html.input(
27-
{"value": person["first_name"], "onChange": handle_first_name_change},
27+
{"value": person["first_name"], "on_change": handle_first_name_change}
2828
),
2929
),
3030
html.label(
3131
"Last name: ",
3232
html.input(
33-
{"value": person["last_name"], "onChange": handle_last_name_change},
33+
{"value": person["last_name"], "on_change": handle_last_name_change}
3434
),
3535
),
3636
html.label(
3737
"Email: ",
38-
html.input(
39-
{"value": person["email"], "onChange": handle_email_change},
40-
),
38+
html.input({"value": person["email"], "on_change": handle_email_change}),
4139
),
4240
html.p(f"{person['first_name']} {person['last_name']} {person['email']}"),
4341
)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def handle_click(event):
1616

1717
return html.div(
1818
html.h1("Inspiring sculptors:"),
19-
html.input({"value": artist_to_add, "onChange": handle_change}),
20-
html.button({"onClick": handle_click}, "add"),
19+
html.input({"value": artist_to_add, "on_change": handle_change}),
20+
html.button({"on_click": handle_click}, "add"),
2121
html.ul([html.li({"key": name}, name) for name in artists]),
2222
)
2323

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def handle_reverse_click(event):
1515

1616
return html.div(
1717
html.h1("Inspiring sculptors:"),
18-
html.button({"onClick": handle_sort_click}, "sort"),
19-
html.button({"onClick": handle_reverse_click}, "reverse"),
18+
html.button({"on_click": handle_sort_click}, "sort"),
19+
html.button({"on_click": handle_reverse_click}, "reverse"),
2020
html.ul([html.li({"key": name}, name) for name in artists]),
2121
)
2222

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ def handle_click(event):
2424

2525
return html.div(
2626
html.h1("Inspiring sculptors:"),
27-
html.input({"value": artist_to_add, "onChange": handle_change}),
28-
html.button({"onClick": handle_add_click}, "add"),
27+
html.input({"value": artist_to_add, "on_change": handle_change}),
28+
html.button({"on_click": handle_add_click}, "add"),
2929
html.ul(
3030
[
3131
html.li(
3232
{"key": name},
3333
name,
34-
html.button({"onClick": make_handle_delete_click(index)}, "delete"),
34+
html.button(
35+
{"on_click": make_handle_delete_click(index)}, "delete"
36+
),
3537
)
3638
for index, name in enumerate(artists)
3739
]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def handle_click(event):
1717
html.li(
1818
{"key": index},
1919
count,
20-
html.button({"onClick": make_increment_click_handler(index)}, "+1"),
20+
html.button({"on_click": make_increment_click_handler(index)}, "+1"),
2121
)
2222
for index, count in enumerate(counters)
2323
]

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def handle_pointer_move(event):
1717

1818
return html.div(
1919
{
20-
"onPointerMove": handle_pointer_move,
20+
"on_pointer_move": handle_pointer_move,
2121
"style": {
2222
"position": "relative",
2323
"height": "200px",
@@ -36,7 +36,7 @@ async def handle_pointer_move(event):
3636
"left": "-10px",
3737
"top": "-10px",
3838
"transform": f"translate({position['x']}px, {position['y']}px)",
39-
},
39+
}
4040
}
4141
),
4242
)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def handle_pointer_move(event):
1515

1616
return html.div(
1717
{
18-
"onPointerMove": handle_pointer_move,
18+
"on_pointer_move": handle_pointer_move,
1919
"style": {
2020
"position": "relative",
2121
"height": "200px",
@@ -34,7 +34,7 @@ def handle_pointer_move(event):
3434
"left": "-10px",
3535
"top": "-10px",
3636
"transform": f"translate({position['x']}px, {position['y']}px)",
37-
},
37+
}
3838
}
3939
),
4040
)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def handle_click(event):
2020
[
2121
html.div(
2222
{
23-
"onClick": make_handle_click(index),
23+
"on_click": make_handle_click(index),
2424
"style": {
2525
"height": "30px",
2626
"width": "30px",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def handle_click(event):
1717
[
1818
html.div(
1919
{
20-
"onClick": make_handle_click(index),
20+
"on_click": make_handle_click(index),
2121
"style": {
2222
"height": "30px",
2323
"width": "30px",

docs/source/guides/adding-interactivity/multiple-state-updates/_examples/delay_before_count_updater.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async def handle_click(event):
1313

1414
return html.div(
1515
html.h1(number),
16-
html.button({"onClick": handle_click}, "Increment"),
16+
html.button({"on_click": handle_click}, "Increment"),
1717
)
1818

1919

docs/source/guides/adding-interactivity/multiple-state-updates/_examples/delay_before_set_count.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async def handle_click(event):
1313

1414
return html.div(
1515
html.h1(number),
16-
html.button({"onClick": handle_click}, "Increment"),
16+
html.button({"on_click": handle_click}, "Increment"),
1717
)
1818

1919

docs/source/guides/adding-interactivity/multiple-state-updates/_examples/set_color_3_times.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ def handle_reset(event):
1515

1616
return html.div(
1717
html.button(
18-
{"onClick": handle_click, "style": {"backgroundColor": color}}, "Set Color"
18+
{"on_click": handle_click, "style": {"backgroundColor": color}}, "Set Color"
1919
),
2020
html.button(
21-
{"onClick": handle_reset, "style": {"backgroundColor": color}}, "Reset"
21+
{"on_click": handle_reset, "style": {"backgroundColor": color}}, "Reset"
2222
),
2323
)
2424

docs/source/guides/adding-interactivity/multiple-state-updates/_examples/set_state_function.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def handle_click(event):
1717

1818
return html.div(
1919
html.h1(number),
20-
html.button({"onClick": handle_click}, "Increment"),
20+
html.button({"on_click": handle_click}, "Increment"),
2121
)
2222

2323

docs/source/guides/adding-interactivity/responding-to-events/_examples/button_async_handlers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ async def handle_event(event):
99
await asyncio.sleep(delay)
1010
print(message)
1111

12-
return html.button({"onClick": handle_event}, message)
12+
return html.button({"on_click": handle_event}, message)
1313

1414

1515
@component

docs/source/guides/adding-interactivity/responding-to-events/_examples/button_handler_as_arg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@component
55
def Button(display_text, on_click):
6-
return html.button({"onClick": on_click}, display_text)
6+
return html.button({"on_click": on_click}, display_text)
77

88

99
@component

docs/source/guides/adding-interactivity/responding-to-events/_examples/button_prints_event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def Button():
66
def handle_event(event):
77
print(event)
88

9-
return html.button({"onClick": handle_event}, "Click me!")
9+
return html.button({"on_click": handle_event}, "Click me!")
1010

1111

1212
run(Button)

docs/source/guides/adding-interactivity/responding-to-events/_examples/button_prints_message.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def PrintButton(display_text, message_text):
66
def handle_event(event):
77
print(message_text)
88

9-
return html.button({"onClick": handle_event}, display_text)
9+
return html.button({"on_click": handle_event}, display_text)
1010

1111

1212
@component

docs/source/guides/adding-interactivity/responding-to-events/_examples/prevent_default_event_actions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def DoNotChangePages():
77
html.p("Normally clicking this link would take you to a new page"),
88
html.a(
99
{
10-
"onClick": event(lambda event: None, prevent_default=True),
10+
"on_click": event(lambda event: None, prevent_default=True),
1111
"href": "https://google.com",
1212
},
1313
"https://google.com",

docs/source/guides/adding-interactivity/responding-to-events/_examples/stop_event_propagation.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ def DivInDiv():
99

1010
div_in_div = html.div(
1111
{
12-
"onClick": lambda event: set_outer_count(outer_count + 1),
12+
"on_click": lambda event: set_outer_count(outer_count + 1),
1313
"style": {"height": "100px", "width": "100px", "backgroundColor": "red"},
1414
},
1515
html.div(
1616
{
17-
"onClick": event(
17+
"on_click": event(
1818
lambda event: set_inner_count(inner_count + 1),
1919
stop_propagation=stop_propagatation,
2020
),
2121
"style": {"height": "50px", "width": "50px", "backgroundColor": "blue"},
22-
},
22+
}
2323
),
2424
)
2525

2626
return html.div(
2727
html.button(
28-
{"onClick": lambda event: set_stop_propagatation(not stop_propagatation)},
28+
{"on_click": lambda event: set_stop_propagatation(not stop_propagatation)},
2929
"Toggle Propogation",
3030
),
3131
html.pre(f"Will propagate: {not stop_propagatation}"),

docs/source/guides/adding-interactivity/state-as-a-snapshot/_examples/delayed_print_after_set.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async def handle_click(event):
1515

1616
return html.div(
1717
html.h1(number),
18-
html.button({"onClick": handle_click}, "Increment"),
18+
html.button({"on_click": handle_click}, "Increment"),
1919
)
2020

2121

docs/source/guides/adding-interactivity/state-as-a-snapshot/_examples/print_chat_message.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ async def handle_submit(event):
1616
print(f"Sent '{message}' to {recipient}")
1717

1818
return html.form(
19-
{"onSubmit": handle_submit, "style": {"display": "inline-grid"}},
19+
{"on_submit": handle_submit, "style": {"display": "inline-grid"}},
2020
html.label(
21+
{},
2122
"To: ",
2223
html.select(
2324
{
2425
"value": recipient,
25-
"onChange": lambda event: set_recipient(event["target"]["value"]),
26+
"on_change": lambda event: set_recipient(event["target"]["value"]),
2627
},
2728
html.option({"value": "Alice"}, "Alice"),
2829
html.option({"value": "Bob"}, "Bob"),
@@ -33,7 +34,7 @@ async def handle_submit(event):
3334
"type": "text",
3435
"placeholder": "Your message...",
3536
"value": message,
36-
"onChange": lambda event: set_message(event["target"]["value"]),
37+
"on_change": lambda event: set_message(event["target"]["value"]),
3738
}
3839
),
3940
html.button({"type": "submit"}, "Send"),

docs/source/guides/adding-interactivity/state-as-a-snapshot/_examples/print_count_after_set.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def handle_click(event):
1111

1212
return html.div(
1313
html.h1(number),
14-
html.button({"onClick": handle_click}, "Increment"),
14+
html.button({"on_click": handle_click}, "Increment"),
1515
)
1616

1717

docs/source/guides/adding-interactivity/state-as-a-snapshot/_examples/send_message.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def App():
1010
return html.div(
1111
html.h1("Message sent!"),
1212
html.button(
13-
{"onClick": lambda event: set_is_sent(False)}, "Send new message?"
13+
{"on_click": lambda event: set_is_sent(False)}, "Send new message?"
1414
),
1515
)
1616

@@ -20,12 +20,12 @@ def handle_submit(event):
2020
set_is_sent(True)
2121

2222
return html.form(
23-
{"onSubmit": handle_submit, "style": {"display": "inline-grid"}},
23+
{"on_submit": handle_submit, "style": {"display": "inline-grid"}},
2424
html.textarea(
2525
{
2626
"placeholder": "Your message here...",
2727
"value": message,
28-
"onChange": lambda event: set_message(event["target"]["value"]),
28+
"on_change": lambda event: set_message(event["target"]["value"]),
2929
}
3030
),
3131
html.button({"type": "submit"}, "Send"),

0 commit comments

Comments
 (0)