From 84c2dab4200c37c818d83c95f85445ee00d83bf6 Mon Sep 17 00:00:00 2001 From: jelemux Date: Sun, 18 Oct 2020 22:40:57 +0200 Subject: initial commit --- src/view.rs | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/view.rs (limited to 'src/view.rs') diff --git a/src/view.rs b/src/view.rs new file mode 100644 index 0000000..81634ed --- /dev/null +++ b/src/view.rs @@ -0,0 +1,83 @@ +use crate::model::BCard; +use wasm_bindgen::prelude::*; +use yew::prelude::*; + +struct Form { + link: ComponentLink, + bcard: BCard, +} + +impl Component for Form { // probably not necessary but who knows + type Message = (); + type Properties = (); + + fn create(_: Self::Properties, link: ComponentLink) -> Self { + Self { link } + } + + fn update(&mut self, _: Self::Message) -> ShouldRender { + false + } + + fn change(&mut self, _: Self::Properties) -> ShouldRender { + false + } + + fn view(&self) -> Html { + html! { + + } + } +} + +// example + +struct Model { + link: ComponentLink, + value: i64, +} + +enum Msg { + AddOne, + Input(BCard), +} + +impl Component for Model { + type Message = Msg; + type Properties = (); + + fn create(_: Self::Properties, link: ComponentLink) -> Self { + Self { + link, + value: 0, + } + } + + fn update(&mut self, msg: Self::Message) -> ShouldRender { + match msg { + Msg::AddOne => self.value += 1 + } + true + } + + fn change(&mut self, _props: Self::Properties) -> ShouldRender { + // Should only return "true" if new properties are different to + // previously received properties. + // This component has no properties so we will always return "false". + false + } + + fn view(&self) -> Html { + html! { +
+ +

{ self.value }

+
+ } + } +} + +#[wasm_bindgen(start)] +pub fn run_app() { + App::::new().mount_to_body(); +} \ No newline at end of file -- cgit v1.2.3