Archived
generated from mitchell/rust_template
add signals where appropriate
This commit is contained in:
+18
-14
@@ -1,15 +1,15 @@
|
||||
use super::{BuilderCxFn, BuilderFn, ControlBuilder, ControlData, ControlRenderData};
|
||||
use crate::{form::FormToolData, form_builder::FormBuilder, styles::FormStyle};
|
||||
use leptos::{Signal, View};
|
||||
use std::{ops::RangeInclusive, rc::Rc};
|
||||
use leptos::{MaybeSignal, Signal, View};
|
||||
use std::rc::Rc;
|
||||
|
||||
/// Data used for the slider control.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SliderData {
|
||||
pub name: String,
|
||||
pub label: Option<String>,
|
||||
pub min: i32,
|
||||
pub max: i32,
|
||||
pub min: MaybeSignal<i32>,
|
||||
pub max: MaybeSignal<i32>,
|
||||
}
|
||||
|
||||
impl Default for SliderData {
|
||||
@@ -17,8 +17,8 @@ impl Default for SliderData {
|
||||
SliderData {
|
||||
name: String::new(),
|
||||
label: None,
|
||||
min: 0,
|
||||
max: 1,
|
||||
min: MaybeSignal::Static(0),
|
||||
max: MaybeSignal::Static(1),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,21 +75,25 @@ impl<FD: FormToolData, FDT> ControlBuilder<FD, SliderData, FDT> {
|
||||
|
||||
/// Sets the minimum value for the slider.
|
||||
pub fn min(mut self, min: i32) -> Self {
|
||||
self.data.min = min;
|
||||
self.data.min = MaybeSignal::Static(min);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the minimum value for the slider to a signal.
|
||||
pub fn min_signal(mut self, min: Signal<i32>) -> Self {
|
||||
self.data.min = MaybeSignal::Dynamic(min);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum value for the slider.
|
||||
pub fn max(mut self, max: i32) -> Self {
|
||||
self.data.max = max;
|
||||
self.data.max = MaybeSignal::Static(max);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the minimum and maximum values for the slider by providing a
|
||||
/// range.
|
||||
pub fn range(mut self, range: RangeInclusive<i32>) -> Self {
|
||||
self.data.min = *range.start();
|
||||
self.data.max = *range.end();
|
||||
/// Sets the maximum value for the slider to a signal.
|
||||
pub fn max_signal(mut self, max: Signal<i32>) -> Self {
|
||||
self.data.max = MaybeSignal::Dynamic(max);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user