From 0030bcbd33f5c4db60aac826552042e46b51c691 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 5 Feb 2020 00:23:22 +0100 Subject: Rename module `style` to `css` in `iced_web` --- web/src/widget/checkbox.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'web/src/widget/checkbox.rs') diff --git a/web/src/widget/checkbox.rs b/web/src/widget/checkbox.rs index 1e864875..d1d30048 100644 --- a/web/src/widget/checkbox.rs +++ b/web/src/widget/checkbox.rs @@ -1,4 +1,4 @@ -use crate::{style, Bus, Color, Element, Widget}; +use crate::{Bus, Color, Css, Element, Widget}; use dodrio::bumpalo; use std::rc::Rc; @@ -68,7 +68,7 @@ where &self, bump: &'b bumpalo::Bump, bus: &Bus, - _style_sheet: &mut style::Sheet<'b>, + _style_sheet: &mut Css<'b>, ) -> dodrio::Node<'b> { use dodrio::builder::*; -- cgit From ce45ecc23546efd85f04a76fcb1a3a691d259129 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 6 Feb 2020 00:28:25 +0100 Subject: Expose missing widget modules in `iced_web` --- web/src/widget/checkbox.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'web/src/widget/checkbox.rs') diff --git a/web/src/widget/checkbox.rs b/web/src/widget/checkbox.rs index d1d30048..7c7b805c 100644 --- a/web/src/widget/checkbox.rs +++ b/web/src/widget/checkbox.rs @@ -1,3 +1,4 @@ +//! Show toggle controls using checkboxes. use crate::{Bus, Color, Css, Element, Widget}; use dodrio::bumpalo; -- cgit From abdae3a7ec1413df86fca93699fb2448226e2da5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 6 Feb 2020 00:31:52 +0100 Subject: Expose styling types for `checkbox` in `iced_web` --- web/src/widget/checkbox.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'web/src/widget/checkbox.rs') 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 { is_checked: bool, on_toggle: Rc Message>, label: String, - label_color: Option, + width: Length, + style: Box, } impl Checkbox { @@ -48,15 +51,24 @@ impl Checkbox { 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>(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>) -> 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) -- cgit From 6c8fdfefbe6ea8cd1cc11a4a822285c28c278880 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 6 Feb 2020 01:25:22 +0100 Subject: Fix `Checkbox` styling in `iced_web` --- web/src/widget/checkbox.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'web/src/widget/checkbox.rs') diff --git a/web/src/widget/checkbox.rs b/web/src/widget/checkbox.rs index 5160e221..0657ccfb 100644 --- a/web/src/widget/checkbox.rs +++ b/web/src/widget/checkbox.rs @@ -1,5 +1,5 @@ //! Show toggle controls using checkboxes. -use crate::{Bus, Css, Element, Length, Widget}; +use crate::{css, Bus, Css, Element, Length, Widget}; pub use iced_style::checkbox::{Style, StyleSheet}; @@ -81,7 +81,7 @@ where &self, bump: &'b bumpalo::Bump, bus: &Bus, - _style_sheet: &mut Css<'b>, + style_sheet: &mut Css<'b>, ) -> dodrio::Node<'b> { use dodrio::builder::*; @@ -91,10 +91,23 @@ where let on_toggle = self.on_toggle.clone(); let is_checked = self.is_checked; - // TODO: Styling + let row_class = style_sheet.insert(bump, css::Rule::Row); + + let spacing_class = style_sheet.insert(bump, css::Rule::Spacing(5)); label(bump) + .attr( + "class", + bumpalo::format!(in bump, "{} {}", row_class, spacing_class) + .into_bump_str(), + ) + .attr( + "style", + bumpalo::format!(in bump, "width: {}; align-items: center", css::length(self.width)) + .into_bump_str(), + ) .children(vec![ + // TODO: Checkbox styling input(bump) .attr("type", "checkbox") .bool_attr("checked", self.is_checked) @@ -105,7 +118,8 @@ where vdom.schedule_render(); }) .finish(), - text(checkbox_label.into_bump_str()), + span(bump).children(vec![ + text(checkbox_label.into_bump_str())]).finish(), ]) .finish() } -- cgit