mirror of
https://github.com/yewprint/yewprint
synced 2025-02-16 12:08:25 +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 crate::ExampleContainer;
|
||||||
use example::*;
|
use example::*;
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yewprint::{Intent, Menu, MenuItem, Switch, H1, H5};
|
use yewprint::{HtmlSelect, Intent, Switch, H1, H5};
|
||||||
|
|
||||||
pub struct CalloutDoc {
|
pub struct CalloutDoc {
|
||||||
callback: Callback<ExampleProps>,
|
callback: Callback<ExampleProps>,
|
||||||
|
@ -84,47 +84,19 @@ crate::build_example_prop_component! {
|
||||||
label="Show/hide title"
|
label="Show/hide title"
|
||||||
/>
|
/>
|
||||||
<p>{"Select intent:"}</p>
|
<p>{"Select intent:"}</p>
|
||||||
<Menu>
|
<HtmlSelect<Option<Intent>>
|
||||||
<MenuItem
|
options={vec![
|
||||||
onclick=self.update_props(|props, _| ExampleProps {
|
(None, "None".to_string()),
|
||||||
intent: None,
|
(Some(Intent::Primary), "Primary".to_string()),
|
||||||
..props
|
(Some(Intent::Success), "Success".to_string()),
|
||||||
})
|
(Some(Intent::Warning), "Warning".to_string()),
|
||||||
text=html!{"None"}
|
(Some(Intent::Danger), "Danger".to_string()),
|
||||||
/>
|
]}
|
||||||
<MenuItem
|
onchange=self.update_props(|props, intent| ExampleProps {
|
||||||
onclick=self.update_props(|props, _| ExampleProps {
|
intent,
|
||||||
intent: Some(Intent::Primary),
|
..props
|
||||||
..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>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ mod example;
|
||||||
use crate::ExampleContainer;
|
use crate::ExampleContainer;
|
||||||
use example::*;
|
use example::*;
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yewprint::{Intent, Menu, MenuItem, Switch, H1, H5};
|
use yewprint::{HtmlSelect, Intent, Switch, H1, H5};
|
||||||
|
|
||||||
pub struct ProgressBarDoc {
|
pub struct ProgressBarDoc {
|
||||||
callback: Callback<ExampleProps>,
|
callback: Callback<ExampleProps>,
|
||||||
|
@ -84,47 +84,19 @@ crate::build_example_prop_component! {
|
||||||
label="Animate"
|
label="Animate"
|
||||||
/>
|
/>
|
||||||
<p>{"Select intent:"}</p>
|
<p>{"Select intent:"}</p>
|
||||||
<Menu>
|
<HtmlSelect<Option<Intent>>
|
||||||
<MenuItem
|
options={vec![
|
||||||
onclick=self.update_props(|props, _| ExampleProps {
|
(None, "None".to_string()),
|
||||||
intent: None,
|
(Some(Intent::Primary), "Primary".to_string()),
|
||||||
..props
|
(Some(Intent::Success), "Success".to_string()),
|
||||||
})
|
(Some(Intent::Warning), "Warning".to_string()),
|
||||||
text=html!{"None"}
|
(Some(Intent::Danger), "Danger".to_string()),
|
||||||
/>
|
]}
|
||||||
<MenuItem
|
onchange=self.update_props(|props, intent| ExampleProps {
|
||||||
onclick=self.update_props(|props, _| ExampleProps {
|
intent,
|
||||||
intent: Some(Intent::Primary),
|
..props
|
||||||
..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>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ mod example;
|
||||||
use crate::ExampleContainer;
|
use crate::ExampleContainer;
|
||||||
use example::*;
|
use example::*;
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
use yewprint::{Button, Intent, Menu, MenuItem, Switch, H1, H5};
|
use yewprint::{Button, HtmlSelect, IconName, Intent, Switch, H1, H5};
|
||||||
|
|
||||||
pub struct TagDoc {
|
pub struct TagDoc {
|
||||||
callback: Callback<ExampleProps>,
|
callback: Callback<ExampleProps>,
|
||||||
|
@ -171,56 +171,31 @@ crate::build_example_prop_component! {
|
||||||
checked=self.props.right_icon
|
checked=self.props.right_icon
|
||||||
label="Right icon"
|
label="Right icon"
|
||||||
/>
|
/>
|
||||||
<Button
|
<p>{"Select intent:"}</p>
|
||||||
onclick=self.update_props(|props, _| ExampleProps {
|
<HtmlSelect<Option<Intent>>
|
||||||
reset_tags: props.reset_tags + 1,
|
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
|
..props
|
||||||
})
|
})
|
||||||
>
|
/>
|
||||||
{"Reset tags"}
|
<Button
|
||||||
</Button>
|
fill=true
|
||||||
<p>{"Select intent:"}</p>
|
icon=IconName::Refresh
|
||||||
<Menu>
|
|
||||||
<MenuItem
|
|
||||||
onclick=self.update_props(|props, _| ExampleProps {
|
onclick=self.update_props(|props, _| ExampleProps {
|
||||||
intent: None,
|
reset_tags: props.reset_tags + 1,
|
||||||
..props
|
..props
|
||||||
})
|
})
|
||||||
text=html!{"None"}
|
>
|
||||||
/>
|
{"Reset tags"}
|
||||||
<MenuItem
|
</Button>
|
||||||
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>
|
|
||||||
</div>
|
</div>
|
||||||
</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
|
// NOTE: this class needs to become deprecated when the feature bool_to_option lands in stable
|
||||||
//
|
//
|
||||||
// https://github.com/rust-lang/rust/issues/64260
|
// 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);
|
pub struct ConditionalClass(bool);
|
||||||
|
|
||||||
impl Transformer<bool, ConditionalClass> for VComp {
|
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 {
|
pub enum Intent {
|
||||||
Primary,
|
Primary,
|
||||||
Success,
|
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 {
|
pub enum Elevation {
|
||||||
Level0,
|
Level0,
|
||||||
Level1,
|
Level1,
|
||||||
|
|
Loading…
Add table
Reference in a new issue