Make tour work with iced_web again 🎉
- Implements `TextInput`, `Scrollable`, and `Container` - Adds basic style generation
This commit is contained in:
parent
3a678561f2
commit
d0f79d2779
17 changed files with 882 additions and 69 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue