summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-06 00:31:52 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-06 00:31:52 +0100
commitabdae3a7ec1413df86fca93699fb2448226e2da5 (patch)
tree8877773b7d6f60d0de4767aa1120b6054ad1bfdc /web
parentce45ecc23546efd85f04a76fcb1a3a691d259129 (diff)
downloadiced-abdae3a7ec1413df86fca93699fb2448226e2da5.tar.gz
iced-abdae3a7ec1413df86fca93699fb2448226e2da5.tar.bz2
iced-abdae3a7ec1413df86fca93699fb2448226e2da5.zip
Expose styling types for `checkbox` in `iced_web`
Diffstat (limited to 'web')
-rw-r--r--web/src/widget/checkbox.rs27
1 files changed, 20 insertions, 7 deletions
diff --git a/web/src/widget/checkbox.rs b/web/src/widget/checkbox.rs
index 7c7b805c..5160e221 100644
--- a/web/src/widget/checkbox.rs
+++ b/web/src/widget/checkbox.rs
@@ -1,5 +1,7 @@
//! Show toggle controls using checkboxes.
-use crate::{Bus, Color, Css, Element, Widget};
+use crate::{Bus, Css, Element, Length, Widget};
+
+pub use iced_style::checkbox::{Style, StyleSheet};
use dodrio::bumpalo;
use std::rc::Rc;
@@ -26,7 +28,8 @@ pub struct Checkbox<Message> {
is_checked: bool,
on_toggle: Rc<dyn Fn(bool) -> Message>,
label: String,
- label_color: Option<Color>,
+ width: Length,
+ style: Box<dyn StyleSheet>,
}
impl<Message> Checkbox<Message> {
@@ -48,15 +51,24 @@ impl<Message> Checkbox<Message> {
is_checked,
on_toggle: Rc::new(f),
label: String::from(label),
- label_color: None,
+ width: Length::Shrink,
+ style: Default::default(),
}
}
- /// Sets the color of the label of the [`Checkbox`].
+ /// Sets the width of the [`Checkbox`].
///
/// [`Checkbox`]: struct.Checkbox.html
- pub fn label_color<C: Into<Color>>(mut self, color: C) -> Self {
- self.label_color = Some(color.into());
+ pub fn width(mut self, width: Length) -> Self {
+ self.width = width;
+ self
+ }
+
+ /// Sets the style of the [`Checkbox`].
+ ///
+ /// [`Checkbox`]: struct.Checkbox.html
+ pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
+ self.style = style.into();
self
}
}
@@ -79,7 +91,8 @@ where
let on_toggle = self.on_toggle.clone();
let is_checked = self.is_checked;
- // TODO: Complete styling
+ // TODO: Styling
+
label(bump)
.children(vec![
input(bump)