summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-06 02:24:18 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-06 02:24:18 +0100
commitcf3ca442104994411529dfe21f7dced08f4ee1fb (patch)
tree17f43b5b8b72823940aa1522a88d90de595975de /web
parente953733323c1c2a50cc511408167c7982f84bf06 (diff)
downloadiced-cf3ca442104994411529dfe21f7dced08f4ee1fb.tar.gz
iced-cf3ca442104994411529dfe21f7dced08f4ee1fb.tar.bz2
iced-cf3ca442104994411529dfe21f7dced08f4ee1fb.zip
Implement `Container` styling in `iced_web`
Diffstat (limited to 'web')
-rw-r--r--web/src/widget/container.rs29
1 files changed, 15 insertions, 14 deletions
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<dyn StyleSheet>,
+ style_sheet: Box<dyn StyleSheet>,
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<Box<dyn StyleSheet>>) -> 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(),
)