Change the intent menus in example's props into select (#52)

This commit is contained in:
Yohan Boogaert 2020-10-17 12:19:07 +02:00 committed by GitHub
parent 69e271f565
commit b2ab172466
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 133 deletions

View file

@ -3,7 +3,7 @@ mod example;
use crate::ExampleContainer;
use example::*;
use yew::prelude::*;
use yewprint::{Intent, Menu, MenuItem, Switch, H1, H5};
use yewprint::{HtmlSelect, Intent, Switch, H1, H5};
pub struct CalloutDoc {
callback: Callback<ExampleProps>,
@ -84,47 +84,19 @@ crate::build_example_prop_component! {
label="Show/hide title"
/>
<p>{"Select intent:"}</p>
<Menu>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: None,
..props
})
text=html!{"None"}
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Primary),
..props
})
text=html!{"Primary"}
intent=Intent::Primary
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Success),
..props
})
text=html!{"Success"}
intent=Intent::Success
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Warning),
..props
})
text=html!{"Warning"}
intent=Intent::Warning
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Danger),
..props
})
text=html!{"Danger"}
intent=Intent::Danger
/>
</Menu>
<HtmlSelect<Option<Intent>>
options={vec![
(None, "None".to_string()),
(Some(Intent::Primary), "Primary".to_string()),
(Some(Intent::Success), "Success".to_string()),
(Some(Intent::Warning), "Warning".to_string()),
(Some(Intent::Danger), "Danger".to_string()),
]}
onchange=self.update_props(|props, intent| ExampleProps {
intent,
..props
})
/>
</div>
</div>
}

View file

@ -3,7 +3,7 @@ mod example;
use crate::ExampleContainer;
use example::*;
use yew::prelude::*;
use yewprint::{Intent, Menu, MenuItem, Switch, H1, H5};
use yewprint::{HtmlSelect, Intent, Switch, H1, H5};
pub struct ProgressBarDoc {
callback: Callback<ExampleProps>,
@ -84,47 +84,19 @@ crate::build_example_prop_component! {
label="Animate"
/>
<p>{"Select intent:"}</p>
<Menu>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: None,
..props
})
text=html!{"None"}
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Primary),
..props
})
text=html!{"Primary"}
intent=Intent::Primary
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Success),
..props
})
text=html!{"Success"}
intent=Intent::Success
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Warning),
..props
})
text=html!{"Warning"}
intent=Intent::Warning
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Danger),
..props
})
text=html!{"Danger"}
intent=Intent::Danger
/>
</Menu>
<HtmlSelect<Option<Intent>>
options={vec![
(None, "None".to_string()),
(Some(Intent::Primary), "Primary".to_string()),
(Some(Intent::Success), "Success".to_string()),
(Some(Intent::Warning), "Warning".to_string()),
(Some(Intent::Danger), "Danger".to_string()),
]}
onchange=self.update_props(|props, intent| ExampleProps {
intent,
..props
})
/>
</div>
</div>
}

View file

@ -3,7 +3,7 @@ mod example;
use crate::ExampleContainer;
use example::*;
use yew::prelude::*;
use yewprint::{Button, Intent, Menu, MenuItem, Switch, H1, H5};
use yewprint::{Button, HtmlSelect, IconName, Intent, Switch, H1, H5};
pub struct TagDoc {
callback: Callback<ExampleProps>,
@ -171,56 +171,31 @@ crate::build_example_prop_component! {
checked=self.props.right_icon
label="Right icon"
/>
<Button
onclick=self.update_props(|props, _| ExampleProps {
reset_tags: props.reset_tags + 1,
<p>{"Select intent:"}</p>
<HtmlSelect<Option<Intent>>
fill=true
options={vec![
(None, "None".to_string()),
(Some(Intent::Primary), "Primary".to_string()),
(Some(Intent::Success), "Success".to_string()),
(Some(Intent::Warning), "Warning".to_string()),
(Some(Intent::Danger), "Danger".to_string()),
]}
onchange=self.update_props(|props, intent| ExampleProps {
intent,
..props
})
>
{"Reset tags"}
</Button>
<p>{"Select intent:"}</p>
<Menu>
<MenuItem
/>
<Button
fill=true
icon=IconName::Refresh
onclick=self.update_props(|props, _| ExampleProps {
intent: None,
reset_tags: props.reset_tags + 1,
..props
})
text=html!{"None"}
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Primary),
..props
})
text=html!{"Primary"}
intent=Intent::Primary
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Success),
..props
})
text=html!{"Success"}
intent=Intent::Success
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Warning),
..props
})
text=html!{"Warning"}
intent=Intent::Warning
/>
<MenuItem
onclick=self.update_props(|props, _| ExampleProps {
intent: Some(Intent::Danger),
..props
})
text=html!{"Danger"}
intent=Intent::Danger
/>
</Menu>
>
{"Reset tags"}
</Button>
</div>
</div>
}

View file

@ -58,7 +58,7 @@ macro_rules! if_html {
// NOTE: this class needs to become deprecated when the feature bool_to_option lands in stable
//
// https://github.com/rust-lang/rust/issues/64260
#[derive(Debug, Copy, Clone, PartialEq, Default)]
#[derive(Debug, Copy, Clone, PartialEq, Hash, Default)]
pub struct ConditionalClass(bool);
impl Transformer<bool, ConditionalClass> for VComp {
@ -119,7 +119,7 @@ impl Not for ConditionalClass {
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Hash)]
pub enum Intent {
Primary,
Success,
@ -144,7 +144,7 @@ impl AsRef<str> for Intent {
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
pub enum Elevation {
Level0,
Level1,