-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Even better uhtml integration with Signals
- Loading branch information
1 parent
e7c6317
commit 1f43667
Showing
15 changed files
with
1,227 additions
and
131 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
<title>uhtml/preactive in Python</title> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/polyscript"></script> | ||
<script type="pyodide" src="./index.py" config="./py-config.toml"></script> | ||
</head> | ||
<body></body> | ||
</html> |
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,28 @@ | ||
from uhtml import local | ||
from js import document | ||
|
||
# grab utilities passing current module name | ||
ui = local(__name__) | ||
|
||
# define handlers and whatnot | ||
def h3_click(event): | ||
print(event.type) | ||
|
||
def button_click(event): | ||
count.value = count.value + 1 | ||
|
||
# define signals and/or computed | ||
count = ui.signal(0) | ||
who = ui.computed(lambda: f"World {count.value}!") | ||
|
||
# render via a callback that can react to changes | ||
ui.render(document.body, lambda: ui.html( | ||
""" | ||
<h3 onclick=${h3_click}> | ||
Hello ${who} | ||
</h3> | ||
<button onclick=${button_click}> | ||
Clicks ${count} | ||
</button> | ||
""" | ||
)) |
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,5 @@ | ||
[js_modules.main] | ||
"https://cdn.jsdelivr.net/npm/uhtml/preactive.js" = "uhtml" | ||
|
||
[[fetch]] | ||
files = ["./template.py", "./uhtml.py"] |
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,5 @@ | ||
[js_modules.main] | ||
"https://cdn.jsdelivr.net/npm/uhtml/preactive.js" = "uhtml" | ||
|
||
[[fetch]] | ||
files = ["./uhtml.py"] |
Oops, something went wrong.