summaryrefslogtreecommitdiffstats
path: root/web/src/widget/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-23 20:23:38 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-23 20:23:38 +0100
commitd0f79d2779d00752eef78cd98b6904cd888d59e3 (patch)
tree436e757d7b24ae9791dc554d341b38d6646285d3 /web/src/widget/text.rs
parent3a678561f2da92e089390ee79bd4f9efc2c1a8c7 (diff)
downloadiced-d0f79d2779d00752eef78cd98b6904cd888d59e3.tar.gz
iced-d0f79d2779d00752eef78cd98b6904cd888d59e3.tar.bz2
iced-d0f79d2779d00752eef78cd98b6904cd888d59e3.zip
Make `tour` work with `iced_web` again :tada:
- Implements `TextInput`, `Scrollable`, and `Container` - Adds basic style generation
Diffstat (limited to 'web/src/widget/text.rs')
-rw-r--r--web/src/widget/text.rs23
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()
}