summaryrefslogtreecommitdiffstats
path: root/web/src/widget/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-02-06 10:21:52 -0600
committerLibravatar GitHub <noreply@github.com>2020-02-06 10:21:52 -0600
commit97c308076ff93d09eb874f8e954aae4c7c5deaf7 (patch)
treec3a4ec76931c8153c932c364fa393e25d39d74f0 /web/src/widget/text.rs
parent7b892eb3e11596925a2993bcc4175ac09ff3768a (diff)
parent36e617ae70cc7a86ce998cbd61f6aa702bb42933 (diff)
downloadiced-97c308076ff93d09eb874f8e954aae4c7c5deaf7.tar.gz
iced-97c308076ff93d09eb874f8e954aae4c7c5deaf7.tar.bz2
iced-97c308076ff93d09eb874f8e954aae4c7c5deaf7.zip
Merge pull request #180 from hecrj/feature/web-styling
Custom styling for `iced_web`
Diffstat (limited to 'web/src/widget/text.rs')
-rw-r--r--web/src/widget/text.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/web/src/widget/text.rs b/web/src/widget/text.rs
index 5b0bee55..3ec565a8 100644
--- a/web/src/widget/text.rs
+++ b/web/src/widget/text.rs
@@ -1,5 +1,5 @@
use crate::{
- style, Bus, Color, Element, Font, HorizontalAlignment, Length,
+ css, Bus, Color, Css, Element, Font, HorizontalAlignment, Length,
VerticalAlignment, Widget,
};
use dodrio::bumpalo;
@@ -112,15 +112,18 @@ impl<'a, Message> Widget<Message> for Text {
&self,
bump: &'b bumpalo::Bump,
_publish: &Bus<Message>,
- _style_sheet: &mut style::Sheet<'b>,
+ _style_sheet: &mut Css<'b>,
) -> dodrio::Node<'b> {
use dodrio::builder::*;
let content = bumpalo::format!(in bump, "{}", self.content);
- let color = style::color(self.color.unwrap_or(Color::BLACK));
+ let color = self
+ .color
+ .map(css::color)
+ .unwrap_or(String::from("inherit"));
- 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 text_align = match self.horizontal_alignment {
HorizontalAlignment::Left => "left",
@@ -130,12 +133,16 @@ impl<'a, Message> Widget<Message> for Text {
let style = bumpalo::format!(
in bump,
- "width: {}; height: {}; font-size: {}px; color: {}; text-align: {}",
+ "width: {}; height: {}; font-size: {}px; color: {}; text-align: {}; font-family: {}",
width,
height,
self.size.unwrap_or(20),
color,
- text_align
+ text_align,
+ match self.font {
+ Font::Default => "inherit",
+ Font::External { name, .. } => name,
+ }
);
// TODO: Complete styling