From d0f79d2779d00752eef78cd98b6904cd888d59e3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 23 Nov 2019 20:23:38 +0100 Subject: Make `tour` work with `iced_web` again :tada: - Implements `TextInput`, `Scrollable`, and `Container` - Adds basic style generation --- web/src/widget/column.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'web/src/widget/column.rs') diff --git a/web/src/widget/column.rs b/web/src/widget/column.rs index ee8c14fa..cc850f5f 100644 --- a/web/src/widget/column.rs +++ b/web/src/widget/column.rs @@ -1,4 +1,4 @@ -use crate::{Align, Bus, Element, Length, Widget}; +use crate::{style, Align, Bus, Element, Length, Style, Widget}; use dodrio::bumpalo; use std::u32; @@ -112,18 +112,42 @@ impl<'a, Message> Widget for Column<'a, Message> { &self, bump: &'b bumpalo::Bump, publish: &Bus, + style_sheet: &mut style::Sheet<'b>, ) -> dodrio::Node<'b> { use dodrio::builder::*; let children: Vec<_> = self .children .iter() - .map(|element| element.widget.node(bump, publish)) + .map(|element| element.widget.node(bump, publish, style_sheet)) .collect(); + let column_class = style_sheet.insert(bump, Style::Column); + + let spacing_class = + style_sheet.insert(bump, Style::Spacing(self.spacing)); + + let padding_class = + style_sheet.insert(bump, Style::Padding(self.padding)); + + let width = style::length(self.width); + let height = style::length(self.height); + // TODO: Complete styling div(bump) - .attr("style", "display: flex; flex-direction: column") + .attr( + "class", + bumpalo::format!(in bump, "{} {} {}", column_class, spacing_class, padding_class) + .into_bump_str(), + ) + .attr("style", bumpalo::format!( + in bump, + "width: {}; height: {}; max-width: {}px", + width, + height, + self.max_width + ).into_bump_str() + ) .children(children) .finish() } -- cgit