diff --git a/yewprint-doc/src/slider/example.rs b/yewprint-doc/src/slider/example.rs index 5d32192..db2d2f9 100644 --- a/yewprint-doc/src/slider/example.rs +++ b/yewprint-doc/src/slider/example.rs @@ -6,7 +6,7 @@ pub struct Example { props: ExampleProps, float: f64, integer: i32, - log_level: LogLevel, + log_level: Option, link: ComponentLink, } @@ -32,7 +32,7 @@ impl Component for Example { props, float: 1.2, integer: 30, - log_level: LogLevel::Info, + log_level: None, link, } } @@ -46,7 +46,7 @@ impl Component for Example { self.integer = value; } Msg::LogLevelUpdate(value) => { - self.log_level = value; + self.log_level = Some(value); } Msg::Noop => {} } diff --git a/yewprint/src/slider.rs b/yewprint/src/slider.rs index 39df9cc..c9f4858 100644 --- a/yewprint/src/slider.rs +++ b/yewprint/src/slider.rs @@ -28,7 +28,7 @@ pub struct SliderProps { pub value_label: Option>, pub onchange: Callback, pub values: Vec<(T, Option>)>, - pub selected: T, + pub selected: Option, } pub enum Msg { @@ -104,7 +104,7 @@ impl Component for Slider { .get(position) .unwrap_or_else(|| self.props.values.last().expect("No value in the vec")); - if *value != self.props.selected { + if Some(value) != self.props.selected.as_ref() { self.props.onchange.emit(value.clone()); } @@ -137,7 +137,7 @@ impl Component for Slider { .props .values .iter() - .position(|(value, _)| *value == self.props.selected) + .position(|(value, _)| Some(value) == self.props.selected.as_ref()) .map(|i| i.saturating_sub(1)) .unwrap_or(0); let (value, _) = self.props.values[index].clone(); @@ -151,7 +151,7 @@ impl Component for Slider { .props .values .iter() - .position(|(value, _)| *value == self.props.selected) + .position(|(value, _)| Some(value) == self.props.selected.as_ref()) .map(|i| i.saturating_add(1)) .unwrap_or(0); let (value, _) = self @@ -188,7 +188,7 @@ impl Component for Slider { .props .values .iter() - .position(|(value, _)| *value == self.props.selected); + .position(|(value, _)| Some(value) == self.props.selected.as_ref()); let labels = if self.props.values.len() > 1 { self.props .values