diff --git a/examples/README.md b/examples/README.md index 23994c99b83..997b94c9201 100644 --- a/examples/README.md +++ b/examples/README.md @@ -17,7 +17,7 @@ Have a look at Yew's [starter templates](https://yew.rs/docs/getting-started/sta git clone https://github.com/yewstack/yew.git cd yew/examples ./build.sh minimal # example subfolder -python3 -m http.server --directory static # open localhost:8000 in browser +cd static && python3 -m http.server # open localhost:8000 in browser ``` diff --git a/examples/common/Cargo.toml b/examples/common/Cargo.toml new file mode 100644 index 00000000000..c2fa06438f0 --- /dev/null +++ b/examples/common/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "common" +version = "0.1.0" +authors = ["Martin Matusiak "] +edition = "2018" +description="A useful utility for handing markdown which is used by other examples – not an example in itself!" + +[dependencies] +yew = { path = "../../yew" } +pulldown-cmark = { version = "0.7.0", default-features = false } diff --git a/examples/common/src/lib.rs b/examples/common/src/lib.rs new file mode 100644 index 00000000000..163a4fba821 --- /dev/null +++ b/examples/common/src/lib.rs @@ -0,0 +1 @@ +pub mod markdown; diff --git a/examples/crm/src/markdown.rs b/examples/common/src/markdown.rs similarity index 100% rename from examples/crm/src/markdown.rs rename to examples/common/src/markdown.rs diff --git a/examples/crm/Cargo.toml b/examples/crm/Cargo.toml index c440ff5ab34..14032fb4036 100644 --- a/examples/crm/Cargo.toml +++ b/examples/crm/Cargo.toml @@ -8,4 +8,4 @@ edition = "2018" serde = "1" serde_derive = "1" yew = { path = "../../yew" } -pulldown-cmark = { version = "0.7.0", default-features = false } +common = { path = "../common" } diff --git a/examples/crm/src/lib.rs b/examples/crm/src/lib.rs index 12ed58982f6..22b0cb8d1f9 100644 --- a/examples/crm/src/lib.rs +++ b/examples/crm/src/lib.rs @@ -1,10 +1,9 @@ -#![recursion_limit = "128"] +#![recursion_limit = "256"] #[macro_use] extern crate serde_derive; -mod markdown; - +use common::markdown; use yew::format::Json; use yew::services::storage::Area; use yew::services::{DialogService, StorageService}; @@ -152,6 +151,7 @@ impl Component for Model { match self.scene { Scene::ClientsList => html! {
+

{"List of clients"}

{ for self.database.clients.iter().map(Renderable::render) }
@@ -161,10 +161,17 @@ impl Component for Model { }, Scene::NewClientForm(ref client) => html! {
+

{"Add a new client"}

- { client.view_first_name_input(&self.link) } - { client.view_last_name_input(&self.link) } - { client.view_description_textarea(&self.link) } +
+ { client.view_first_name_input(&self.link) } +
+
+ { client.view_last_name_input(&self.link) } +
+
+ { client.view_description_textarea(&self.link) } +
@@ -173,6 +180,7 @@ impl Component for Model { }, Scene::Settings => html! {
+

{"Settings"}

@@ -184,7 +192,7 @@ impl Component for Model { impl Renderable for Client { fn render(&self) -> Html { html! { -
+

{ format!("First Name: {}", self.first_name) }

{ format!("Last Name: {}", self.last_name) }

{ "Description:" }

@@ -215,7 +223,7 @@ impl Client { fn view_description_textarea(&self, link: &ComponentLink) -> Html { html! {