mirror of
https://github.com/yewprint/yewprint
synced 2024-11-22 03:23:03 +00:00
Change the intent menus in example's props into select (#52)
This commit is contained in:
parent
69e271f565
commit
b2ab172466
4 changed files with 52 additions and 133 deletions
|
@ -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>
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue