-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/DenisKolodin/yew into typ…
…ed-fetch
- Loading branch information
Showing
26 changed files
with
364 additions
and
145 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 |
---|---|---|
|
@@ -2,6 +2,8 @@ language: rust | |
|
||
dist: trusty | ||
sudo: false | ||
addons: | ||
chrome: stable | ||
|
||
rust: | ||
- stable | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "mount_point" | ||
version = "0.1.0" | ||
authors = ["Ben Berman <ben@standardbots.com>"] | ||
|
||
[dependencies] | ||
yew = { path = "../.." } | ||
stdweb = "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,67 @@ | ||
#[macro_use] | ||
extern crate yew; | ||
#[macro_use] | ||
extern crate stdweb; | ||
|
||
use yew::html::{App, Html, InputData}; | ||
use stdweb::web::{IElement, document, INode}; | ||
|
||
struct Context {} | ||
|
||
struct Model { | ||
name: String, | ||
} | ||
|
||
enum Msg { | ||
UpdateName(String), | ||
} | ||
|
||
fn update(_: &mut Context, model: &mut Model, msg: Msg) { | ||
match msg { | ||
Msg::UpdateName(new_name) => { | ||
model.name = new_name; | ||
} | ||
} | ||
} | ||
|
||
fn view(model: &Model) -> Html<Msg> { | ||
html! { | ||
<div> | ||
<input value=&model.name, oninput=|e: InputData| Msg::UpdateName(e.value), /> | ||
<p>{ model.name.chars().rev().collect::<String>() }</p> | ||
</div> | ||
} | ||
} | ||
|
||
fn main() { | ||
yew::initialize(); | ||
let body = document().query_selector("body").unwrap(); | ||
|
||
// This canvas won't be overwritten by yew! | ||
let canvas = document().create_element("canvas"); | ||
body.append_child(&canvas); | ||
|
||
js! { | ||
const canvas = document.querySelector("canvas"); | ||
canvas.width = 100; | ||
canvas.height = 100; | ||
const ctx = canvas.getContext("2d"); | ||
ctx.fillStyle = "green"; | ||
ctx.fillRect(10, 10, 50, 50); | ||
}; | ||
|
||
let mount_class = "mount-point"; | ||
let mount_point = document().create_element("div"); | ||
mount_point.class_list().add(mount_class); | ||
body.append_child(&mount_point); | ||
|
||
let mut app = App::new(); | ||
let context = Context {}; | ||
let model = Model { | ||
name: "Reversed".to_owned(), | ||
}; | ||
|
||
let mount_point = format!(".{}", mount_class); | ||
app.mount_to(&mount_point, context, model, update, view); | ||
yew::run_loop(); | ||
} |
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
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,6 @@ | ||
## Yew TodoMVC Demo | ||
|
||
This it an implementationt of [TodoMVC](http://todomvc.com/) app. | ||
|
||
Unlike other implementations, this stores the full state of the model in the storage, | ||
including: all entries, entered text and choosed filter. |
Oops, something went wrong.