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/container.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'web/src/widget/container.rs') diff --git a/web/src/widget/container.rs b/web/src/widget/container.rs index bdc88979..55995795 100644 --- a/web/src/widget/container.rs +++ b/web/src/widget/container.rs @@ -1,4 +1,4 @@ -use crate::{bumpalo, style, Align, Bus, Element, Length, Style, Widget}; +use crate::{bumpalo, css, Align, Bus, Css, Element, Length, Widget}; /// An element decorating some content. /// @@ -94,17 +94,17 @@ 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::*; - let column_class = style_sheet.insert(bump, Style::Column); + let column_class = style_sheet.insert(bump, css::Rule::Column); - let width = style::length(self.width); - let height = style::length(self.height); + let width = css::length(self.width); + let height = css::length(self.height); - let align_items = style::align(self.horizontal_alignment); - let justify_content = style::align(self.vertical_alignment); + let align_items = css::align(self.horizontal_alignment); + let justify_content = css::align(self.vertical_alignment); let node = div(bump) .attr( -- 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/container.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'web/src/widget/container.rs') diff --git a/web/src/widget/container.rs b/web/src/widget/container.rs index 55995795..43d9abf7 100644 --- a/web/src/widget/container.rs +++ b/web/src/widget/container.rs @@ -1,3 +1,4 @@ +//! Decorate content and apply alignment. use crate::{bumpalo, css, Align, Bus, Css, Element, Length, Widget}; /// An element decorating some content. -- cgit From 58a7be0a31793400e5686f8e2af558f2307bebcd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 6 Feb 2020 00:36:00 +0100 Subject: Expose styling types for `container` in `iced_web` --- web/src/widget/container.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'web/src/widget/container.rs') diff --git a/web/src/widget/container.rs b/web/src/widget/container.rs index 43d9abf7..767fed67 100644 --- a/web/src/widget/container.rs +++ b/web/src/widget/container.rs @@ -1,6 +1,8 @@ //! Decorate content and apply alignment. use crate::{bumpalo, css, Align, Bus, Css, Element, Length, Widget}; +pub use iced_style::container::{Style, StyleSheet}; + /// An element decorating some content. /// /// It is normally used for alignment purposes. @@ -12,6 +14,7 @@ pub struct Container<'a, Message> { max_height: u32, horizontal_alignment: Align, vertical_alignment: Align, + style: Box, content: Element<'a, Message>, } @@ -32,6 +35,7 @@ impl<'a, Message> Container<'a, Message> { max_height: u32::MAX, horizontal_alignment: Align::Start, vertical_alignment: Align::Start, + style: Default::default(), content: content.into(), } } @@ -85,6 +89,14 @@ impl<'a, Message> Container<'a, Message> { self } + + /// Sets the style of the [`Container`]. + /// + /// [`Container`]: struct.Container.html + pub fn style(mut self, style: impl Into>) -> Self { + self.style = style.into(); + self + } } impl<'a, Message> Widget for Container<'a, Message> -- cgit From cf3ca442104994411529dfe21f7dced08f4ee1fb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 6 Feb 2020 02:24:18 +0100 Subject: Implement `Container` styling in `iced_web` --- web/src/widget/container.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'web/src/widget/container.rs') diff --git a/web/src/widget/container.rs b/web/src/widget/container.rs index 767fed67..8e4318f9 100644 --- a/web/src/widget/container.rs +++ b/web/src/widget/container.rs @@ -14,7 +14,7 @@ pub struct Container<'a, Message> { max_height: u32, horizontal_alignment: Align, vertical_alignment: Align, - style: Box, + style_sheet: Box, content: Element<'a, Message>, } @@ -35,7 +35,7 @@ impl<'a, Message> Container<'a, Message> { max_height: u32::MAX, horizontal_alignment: Align::Start, vertical_alignment: Align::Start, - style: Default::default(), + style_sheet: Default::default(), content: content.into(), } } @@ -94,7 +94,7 @@ impl<'a, Message> Container<'a, Message> { /// /// [`Container`]: struct.Container.html pub fn style(mut self, style: impl Into>) -> Self { - self.style = style.into(); + self.style_sheet = style.into(); self } } @@ -113,11 +113,7 @@ where let column_class = style_sheet.insert(bump, css::Rule::Column); - let width = css::length(self.width); - let height = css::length(self.height); - - let align_items = css::align(self.horizontal_alignment); - let justify_content = css::align(self.vertical_alignment); + let style = self.style_sheet.style(); let node = div(bump) .attr( @@ -128,12 +124,17 @@ where "style", bumpalo::format!( in bump, - "width: {}; height: {}; max-width: {}px; align-items: {}; justify-content: {}", - width, - height, - self.max_width, - align_items, - justify_content + "width: {}; height: {}; max-width: {}; align-items: {}; justify-content: {}; background: {}; color: {}; border-width: {}px; border-color: {}; border-radius: {}px", + css::length(self.width), + css::length(self.height), + css::max_length(self.max_width), + css::align(self.horizontal_alignment), + css::align(self.vertical_alignment), + style.background.map(css::background).unwrap_or(String::from("initial")), + style.text_color.map(css::color).unwrap_or(String::from("inherit")), + style.border_width, + css::color(style.border_color), + style.border_radius ) .into_bump_str(), ) -- cgit