Standardize props

This commit is contained in:
Thomas Gideon 2020-06-03 15:33:25 -04:00
parent 96b6152d7b
commit c833bb1957
17 changed files with 358 additions and 252 deletions

19
examples/Cargo.toml Normal file
View file

@ -0,0 +1,19 @@
[package]
name = "examples"
version = "0.1.0"
authors = ["Thomas Gideon <cmdln@thecommandline.net>"]
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
bootstrap-rs = { path = "../" }
yew = "~0.16.2"
log = "~0.4.8"
anyhow = "^1.0.28"
wasm-bindgen = "~0.2.61"
web-sys = "~0.3.38"
wasm-logger = "~0.2.0"
yew-router = "~0.13.0"
yew-components = "~0.1.2"

52
examples/src/lib.rs Normal file
View file

@ -0,0 +1,52 @@
use bootstrap_rs::{prelude::*, Breadcrumb, BreadcrumbItem, Container, Jumbotron};
use yew::{html::Children, prelude::*};
pub struct Example {
props: Props,
}
#[derive(Properties, Clone, PartialEq)]
pub struct Props {
#[prop_or_default]
pub children: Children,
}
impl Component for Example {
type Properties = Props;
type Message = ();
fn create(props: Self::Properties, _: ComponentLink<Self>) -> Self {
Self { props }
}
fn update(&mut self, _: Self::Message) -> ShouldRender {
false
}
fn change(&mut self, props: Self::Properties) -> ShouldRender {
render_on_change(&mut self.props, props)
}
fn view(&self) -> Html {
html! {
<Container>
<Jumbotron>
<h1>{ "Example!" }</h1>
</Jumbotron>
<Breadcrumb
margin=Margin(Edge::Bottom, 3)
>
<BreadcrumbItem active=false>
{ "Grandparent" }
</BreadcrumbItem>
<BreadcrumbItem active=false>
{ "Parent" }
</BreadcrumbItem>
<BreadcrumbItem active=true>
{ "Active" }
</BreadcrumbItem>
</Breadcrumb>
</Container>
}
}
}