-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * Render::update_node
- Loading branch information
Showing
12 changed files
with
213 additions
and
29 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 |
---|---|---|
|
@@ -5,5 +5,6 @@ members = [ | |
"examples/components", | ||
"examples/counter", | ||
"examples/hello", | ||
"examples/todomvc", | ||
"docs", | ||
] |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
authors = ["Luke Chu <[email protected]>"] | ||
edition = "2018" | ||
name = "components" | ||
publish = false | ||
version = "0.1.0" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
authors = ["Luke Chu <[email protected]>"] | ||
edition = "2018" | ||
name = "counter" | ||
publish = false | ||
version = "0.1.0" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
authors = ["Luke Chu <[email protected]>"] | ||
edition = "2018" | ||
name = "hello" | ||
publish = false | ||
version = "0.1.0" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.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,19 @@ | ||
[package] | ||
authors = ["Luke Chu <[email protected]>"] | ||
edition = "2018" | ||
name = "todomvc" | ||
publish = false | ||
version = "0.1.0" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
console_error_panic_hook = "0.1.6" | ||
console_log = "0.2.0" | ||
log = "0.4.14" | ||
maple-core = {path = "../../maple-core"} | ||
wasm-bindgen = "0.2.71" | ||
|
||
[dependencies.web-sys] | ||
features = ["HtmlInputElement", "InputEvent"] | ||
version = "0.3" |
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,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<title>Todos</title> | ||
|
||
<style> | ||
body { | ||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; | ||
} | ||
</style> | ||
</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,52 @@ | ||
#![allow(non_snake_case)] | ||
|
||
use maple_core::prelude::*; | ||
use wasm_bindgen::JsCast; | ||
use web_sys::{Event, HtmlInputElement}; | ||
|
||
fn TodoItem(item: String) -> TemplateResult { | ||
template! { | ||
li { (item.clone()) } | ||
} | ||
} | ||
|
||
fn App() -> TemplateResult { | ||
let todos: Signal<Vec<String>> = Signal::new(Vec::new()); | ||
|
||
let value = Signal::new(String::new()); | ||
|
||
let handle_input = cloned!((value) => move |event: Event| { | ||
let target: HtmlInputElement = event.target().unwrap().dyn_into().unwrap(); | ||
value.set(target.value()); | ||
}); | ||
|
||
let handle_click = cloned!((todos) => move |_| { | ||
let mut tmp = todos.get().as_ref().clone(); | ||
tmp.push(value.get().as_ref().clone()); | ||
|
||
todos.set(tmp); | ||
}); | ||
|
||
template! { | ||
main { | ||
h1 { | ||
"todos" | ||
} | ||
|
||
input(placeholder="What needs to be done?", on:input=handle_input) | ||
button(on:click=handle_click) { "Add todo" } | ||
|
||
ul { | ||
h1 { "Test" } | ||
(todos.get().iter().map(|todo| template! { TodoItem(todo.clone()) }).collect::<TemplateList>()) | ||
} | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
console_error_panic_hook::set_once(); | ||
console_log::init_with_level(log::Level::Debug).unwrap(); | ||
|
||
render(|| template! { App() }); | ||
} |
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
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
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
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
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