Move docs to their own modules (#11)

This commit is contained in:
Yohan Boogaert 2020-09-24 09:55:48 +02:00 committed by GitHub
parent 62adb912bd
commit cdbd52cc17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 180 additions and 185 deletions

31
src/buttons/doc.rs Normal file
View file

@ -0,0 +1,31 @@
use yew::prelude::*;
pub struct ButtonDoc;
impl Component for ButtonDoc {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _link: ComponentLink<Self>) -> Self {
ButtonDoc
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
true
}
fn view(&self) -> Html {
let source = crate::include_example!("example.rs");
html! {
<div>
<h1>{"Button"}</h1>
<div>{source}</div>
</div>
}
}
}

View file

@ -1,3 +1,6 @@
#[cfg(feature = "doc")]
pub mod doc;
use crate::{Icon, IconName, Intent};
use yew::prelude::*;
@ -71,38 +74,3 @@ impl Component for Button {
}
}
}
#[cfg(feature = "doc")]
pub mod doc {
use yew::prelude::*;
pub struct ButtonDoc;
impl Component for ButtonDoc {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _link: ComponentLink<Self>) -> Self {
ButtonDoc
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
true
}
fn view(&self) -> Html {
let source = crate::include_example!("example.rs");
html! {
<div>
<h1>{"Button"}</h1>
<div>{source}</div>
</div>
}
}
}
}

31
src/collapse/doc.rs Normal file
View file

@ -0,0 +1,31 @@
use yew::prelude::*;
pub struct CollapseDoc;
impl Component for CollapseDoc {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _link: ComponentLink<Self>) -> Self {
CollapseDoc
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
true
}
fn view(&self) -> Html {
let source = crate::include_example!("example.rs");
html! {
<div>
<h1>{"Tree"}</h1>
<div>{source}</div>
</div>
}
}
}

View file

@ -1,3 +1,6 @@
#[cfg(feature = "doc")]
pub mod doc;
use std::time::Duration;
use web_sys::Element;
use yew::prelude::*;
@ -196,38 +199,3 @@ impl Component for Collapse {
}
}
}
#[cfg(feature = "doc")]
pub mod doc {
use yew::prelude::*;
pub struct CollapseDoc;
impl Component for CollapseDoc {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _link: ComponentLink<Self>) -> Self {
CollapseDoc
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
true
}
fn view(&self) -> Html {
let source = crate::include_example!("example.rs");
html! {
<div>
<h1>{"Tree"}</h1>
<div>{source}</div>
</div>
}
}
}
}

31
src/icon/doc.rs Normal file
View file

@ -0,0 +1,31 @@
use yew::prelude::*;
pub struct IconDoc;
impl Component for IconDoc {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _link: ComponentLink<Self>) -> Self {
IconDoc
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
true
}
fn view(&self) -> Html {
let source = crate::include_example!("example.rs");
html! {
<div>
<h1>{"Icon"}</h1>
<div>{source}</div>
</div>
}
}
}

View file

@ -1,3 +1,6 @@
#[cfg(feature = "doc")]
pub mod doc;
use crate::Intent;
use yew::prelude::*;
@ -93,38 +96,3 @@ impl Component for Icon {
}
}
}
#[cfg(feature = "doc")]
pub mod doc {
use yew::prelude::*;
pub struct IconDoc;
impl Component for IconDoc {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _link: ComponentLink<Self>) -> Self {
IconDoc
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
true
}
fn view(&self) -> Html {
let source = crate::include_example!("example.rs");
html! {
<div>
<h1>{"Icon"}</h1>
<div>{source}</div>
</div>
}
}
}
}

41
src/switch/doc.rs Normal file
View file

@ -0,0 +1,41 @@
use super::*;
pub struct SwitchDoc {
props: Props,
}
#[derive(Clone, PartialEq, Properties)]
pub struct Props {
pub dark_theme: bool,
pub onclick: Callback<MouseEvent>,
}
impl Component for SwitchDoc {
type Message = ();
type Properties = Props;
fn create(props: Self::Properties, _link: ComponentLink<Self>) -> Self {
SwitchDoc { props }
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
true
}
fn view(&self) -> Html {
html! {
<div>
<h1>{"Switch"}</h1>
<Switch
onclick=self.props.onclick.clone()
checked=self.props.dark_theme
label="Dark theme"
/>
</div>
}
}
}

View file

@ -1,3 +1,6 @@
#[cfg(feature = "doc")]
pub mod doc;
use yew::prelude::*;
pub struct Switch {
@ -52,48 +55,3 @@ impl Component for Switch {
}
}
}
#[cfg(feature = "doc")]
pub mod doc {
use super::*;
pub struct SwitchDoc {
props: Props,
}
#[derive(Clone, PartialEq, Properties)]
pub struct Props {
pub dark_theme: bool,
pub onclick: Callback<MouseEvent>,
}
impl Component for SwitchDoc {
type Message = ();
type Properties = Props;
fn create(props: Self::Properties, _link: ComponentLink<Self>) -> Self {
SwitchDoc { props }
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
true
}
fn view(&self) -> Html {
html! {
<div>
<h1>{"Switch"}</h1>
<Switch
onclick=self.props.onclick.clone()
checked=self.props.dark_theme
label="Dark theme"
/>
</div>
}
}
}
}

31
src/tree/doc.rs Normal file
View file

@ -0,0 +1,31 @@
use yew::prelude::*;
pub struct TreeDoc;
impl Component for TreeDoc {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _link: ComponentLink<Self>) -> Self {
TreeDoc
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
true
}
fn view(&self) -> Html {
let source = crate::include_example!("example.rs");
html! {
<div>
<h1>{"Tree"}</h1>
<div>{source}</div>
</div>
}
}
}

View file

@ -9,6 +9,9 @@ use std::hash::{Hash, Hasher};
use std::rc::Rc;
use yew::prelude::*;
#[cfg(feature = "doc")]
pub mod doc;
#[derive(Clone)]
pub struct TreeData<T> {
tree: Rc<RefCell<id_tree::Tree<NodeData<T>>>>,
@ -362,38 +365,3 @@ impl Component for TreeNode {
}
}
}
#[cfg(feature = "doc")]
pub mod doc {
use yew::prelude::*;
pub struct TreeDoc;
impl Component for TreeDoc {
type Message = ();
type Properties = ();
fn create(_: Self::Properties, _link: ComponentLink<Self>) -> Self {
TreeDoc
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
true
}
fn view(&self) -> Html {
let source = crate::include_example!("example.rs");
html! {
<div>
<h1>{"Tree"}</h1>
<div>{source}</div>
</div>
}
}
}
}