diff options
author | 2019-11-24 19:15:28 +0100 | |
---|---|---|
committer | 2019-11-24 19:15:28 +0100 | |
commit | bbcd16c3358e641b8ab1877b802d1f7c5709943d (patch) | |
tree | 72c805ce46792f3c038d2d7ea127263ae965a779 /web/src/widget/text.rs | |
parent | 700390bdb297a5fc2eb356b10f9ed2656cc75daa (diff) | |
parent | 2b2a0f12c75032453fbefd2491d3ef51ff0ba88e (diff) | |
download | iced-bbcd16c3358e641b8ab1877b802d1f7c5709943d.tar.gz iced-bbcd16c3358e641b8ab1877b802d1f7c5709943d.tar.bz2 iced-bbcd16c3358e641b8ab1877b802d1f7c5709943d.zip |
Merge pull request #66 from hecrj/feature/new-web-tour
Make `tour` work with `iced_web` again
Diffstat (limited to 'web/src/widget/text.rs')
-rw-r--r-- | web/src/widget/text.rs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/web/src/widget/text.rs b/web/src/widget/text.rs index 1183a3cd..6194a12e 100644 --- a/web/src/widget/text.rs +++ b/web/src/widget/text.rs @@ -1,6 +1,6 @@ use crate::{ - Bus, Color, Element, Font, HorizontalAlignment, Length, VerticalAlignment, - Widget, + style, Bus, Color, Element, Font, HorizontalAlignment, Length, + VerticalAlignment, Widget, }; use dodrio::bumpalo; @@ -112,15 +112,30 @@ impl<'a, Message> Widget<Message> for Text { &self, bump: &'b bumpalo::Bump, _publish: &Bus<Message>, + _style_sheet: &mut style::Sheet<'b>, ) -> dodrio::Node<'b> { use dodrio::builder::*; let content = bumpalo::format!(in bump, "{}", self.content); - let size = bumpalo::format!(in bump, "font-size: {}px", self.size.unwrap_or(20)); + let color = style::color(self.color.unwrap_or(Color::BLACK)); + + let text_align = match self.horizontal_alignment { + HorizontalAlignment::Left => "left", + HorizontalAlignment::Center => "center", + HorizontalAlignment::Right => "right", + }; + + let style = bumpalo::format!( + in bump, + "font-size: {}px; color: {}; text-align: {}", + self.size.unwrap_or(20), + color, + text_align + ); // TODO: Complete styling p(bump) - .attr("style", size.into_bump_str()) + .attr("style", style.into_bump_str()) .children(vec![text(content.into_bump_str())]) .finish() } |