1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
mod child; mod group; mod item; pub use child::*; pub use group::*; pub use item::*; use yew::{html::ChildrenRenderer, prelude::*}; #[derive(Clone, Copy, Eq, PartialEq, Debug)] pub enum ToolbarElementModifier { Hidden, Visible, Left, Right, } impl ToString for ToolbarElementModifier { fn to_string(&self) -> String { match self { Self::Hidden => "pf-m-hidden".into(), Self::Visible => "pf-m-visible".into(), Self::Left => "pf-m-align-left".into(), Self::Right => "pf-m-align-right".into(), } } } #[derive(Clone, PartialEq, Properties)] pub struct ToolbarProps { #[prop_or_default] pub children: ChildrenRenderer<ToolbarChildVariant>, #[prop_or_default] pub id: String, } pub struct Toolbar { props: ToolbarProps, } impl Component for Toolbar { type Message = (); type Properties = ToolbarProps; fn create(props: Self::Properties, _: ComponentLink<Self>) -> Self { Self { props } } fn update(&mut self, _: Self::Message) -> ShouldRender { true } fn change(&mut self, props: Self::Properties) -> ShouldRender { if self.props != props { self.props = props; true } else { false } } fn view(&self) -> Html { return html! { <div id=self.props.id class="pf-c-toolbar"> <div class="pf-c-toolbar__content"> <div class="pf-c-toolbar__content-section"> { for self.props.children.iter() } </div> </div> </div> }; } }