Rename module style to css in iced_web
This commit is contained in:
parent
7b892eb3e1
commit
0030bcbd33
16 changed files with 89 additions and 89 deletions
|
|
@ -3,9 +3,9 @@ use crate::{bumpalo, Align, Color, Length};
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
/// The style of a VDOM node.
|
/// A CSS rule of a VDOM node.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Style {
|
pub enum Rule {
|
||||||
/// Container with vertical distribution
|
/// Container with vertical distribution
|
||||||
Column,
|
Column,
|
||||||
|
|
||||||
|
|
@ -19,16 +19,16 @@ pub enum Style {
|
||||||
Spacing(u16),
|
Spacing(u16),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Style {
|
impl Rule {
|
||||||
/// Returns the class name of the [`Style`].
|
/// Returns the class name of the [`Style`].
|
||||||
///
|
///
|
||||||
/// [`Style`]: enum.Style.html
|
/// [`Style`]: enum.Style.html
|
||||||
pub fn class<'a>(&self) -> String {
|
pub fn class<'a>(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Style::Column => String::from("c"),
|
Rule::Column => String::from("c"),
|
||||||
Style::Row => String::from("r"),
|
Rule::Row => String::from("r"),
|
||||||
Style::Padding(padding) => format!("p-{}", padding),
|
Rule::Padding(padding) => format!("p-{}", padding),
|
||||||
Style::Spacing(spacing) => format!("s-{}", spacing),
|
Rule::Spacing(spacing) => format!("s-{}", spacing),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,24 +39,24 @@ impl Style {
|
||||||
let class = self.class();
|
let class = self.class();
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Style::Column => {
|
Rule::Column => {
|
||||||
let body = "{ display: flex; flex-direction: column; }";
|
let body = "{ display: flex; flex-direction: column; }";
|
||||||
|
|
||||||
bumpalo::format!(in bump, ".{} {}", class, body).into_bump_str()
|
bumpalo::format!(in bump, ".{} {}", class, body).into_bump_str()
|
||||||
}
|
}
|
||||||
Style::Row => {
|
Rule::Row => {
|
||||||
let body = "{ display: flex; flex-direction: row; }";
|
let body = "{ display: flex; flex-direction: row; }";
|
||||||
|
|
||||||
bumpalo::format!(in bump, ".{} {}", class, body).into_bump_str()
|
bumpalo::format!(in bump, ".{} {}", class, body).into_bump_str()
|
||||||
}
|
}
|
||||||
Style::Padding(padding) => bumpalo::format!(
|
Rule::Padding(padding) => bumpalo::format!(
|
||||||
in bump,
|
in bump,
|
||||||
".{} {{ box-sizing: border-box; padding: {}px }}",
|
".{} {{ box-sizing: border-box; padding: {}px }}",
|
||||||
class,
|
class,
|
||||||
padding
|
padding
|
||||||
)
|
)
|
||||||
.into_bump_str(),
|
.into_bump_str(),
|
||||||
Style::Spacing(spacing) => bumpalo::format!(
|
Rule::Spacing(spacing) => bumpalo::format!(
|
||||||
in bump,
|
in bump,
|
||||||
".c.{} > * {{ margin-bottom: {}px }} \
|
".c.{} > * {{ margin-bottom: {}px }} \
|
||||||
.r.{} > * {{ margin-right: {}px }} \
|
.r.{} > * {{ margin-right: {}px }} \
|
||||||
|
|
@ -74,34 +74,34 @@ impl Style {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A sheet of styles.
|
/// A cascading style sheet.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Sheet<'a> {
|
pub struct Css<'a> {
|
||||||
styles: BTreeMap<String, &'a str>,
|
rules: BTreeMap<String, &'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Sheet<'a> {
|
impl<'a> Css<'a> {
|
||||||
/// Creates an empty style [`Sheet`].
|
/// Creates an empty style [`Sheet`].
|
||||||
///
|
///
|
||||||
/// [`Sheet`]: struct.Sheet.html
|
/// [`Sheet`]: struct.Sheet.html
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Css {
|
||||||
styles: BTreeMap::new(),
|
rules: BTreeMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts the [`Style`] in the [`Sheet`], if it was not previously
|
/// Inserts the [`rule`] in the [`Sheet`], if it was not previously
|
||||||
/// inserted.
|
/// inserted.
|
||||||
///
|
///
|
||||||
/// It returns the class name of the provided [`Style`].
|
/// It returns the class name of the provided [`Rule`].
|
||||||
///
|
///
|
||||||
/// [`Sheet`]: struct.Sheet.html
|
/// [`Sheet`]: struct.Sheet.html
|
||||||
/// [`Style`]: enum.Style.html
|
/// [`Rule`]: enum.Rule.html
|
||||||
pub fn insert(&mut self, bump: &'a bumpalo::Bump, style: Style) -> String {
|
pub fn insert(&mut self, bump: &'a bumpalo::Bump, rule: Rule) -> String {
|
||||||
let class = style.class();
|
let class = rule.class();
|
||||||
|
|
||||||
if !self.styles.contains_key(&class) {
|
if !self.rules.contains_key(&class) {
|
||||||
let _ = self.styles.insert(class.clone(), style.declaration(bump));
|
let _ = self.rules.insert(class.clone(), rule.declaration(bump));
|
||||||
}
|
}
|
||||||
|
|
||||||
class
|
class
|
||||||
|
|
@ -124,7 +124,7 @@ impl<'a> Sheet<'a> {
|
||||||
"button { border: none; cursor: pointer; outline: none }",
|
"button { border: none; cursor: pointer; outline: none }",
|
||||||
));
|
));
|
||||||
|
|
||||||
for declaration in self.styles.values() {
|
for declaration in self.rules.values() {
|
||||||
declarations.push(text(*declaration));
|
declarations.push(text(*declaration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{style, Bus, Color, Widget};
|
use crate::{Bus, Color, Css, Widget};
|
||||||
|
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
@ -57,7 +57,7 @@ impl<'a, Message> Element<'a, Message> {
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
bus: &Bus<Message>,
|
bus: &Bus<Message>,
|
||||||
style_sheet: &mut style::Sheet<'b>,
|
style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
self.widget.node(bump, bus, style_sheet)
|
self.widget.node(bump, bus, style_sheet)
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +89,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
bus: &Bus<B>,
|
bus: &Bus<B>,
|
||||||
style_sheet: &mut style::Sheet<'b>,
|
style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
self.widget
|
self.widget
|
||||||
.node(bump, &bus.map(self.mapper.clone()), style_sheet)
|
.node(bump, &bus.map(self.mapper.clone()), style_sheet)
|
||||||
|
|
|
||||||
|
|
@ -63,11 +63,12 @@ mod bus;
|
||||||
mod element;
|
mod element;
|
||||||
mod hasher;
|
mod hasher;
|
||||||
|
|
||||||
pub mod style;
|
pub mod css;
|
||||||
pub mod subscription;
|
pub mod subscription;
|
||||||
pub mod widget;
|
pub mod widget;
|
||||||
|
|
||||||
pub use bus::Bus;
|
pub use bus::Bus;
|
||||||
|
pub use css::Css;
|
||||||
pub use dodrio;
|
pub use dodrio;
|
||||||
pub use element::Element;
|
pub use element::Element;
|
||||||
pub use hasher::Hasher;
|
pub use hasher::Hasher;
|
||||||
|
|
@ -76,7 +77,6 @@ pub use iced_core::{
|
||||||
VerticalAlignment,
|
VerticalAlignment,
|
||||||
};
|
};
|
||||||
pub use iced_futures::{executor, futures, Command};
|
pub use iced_futures::{executor, futures, Command};
|
||||||
pub use style::Style;
|
|
||||||
pub use subscription::Subscription;
|
pub use subscription::Subscription;
|
||||||
|
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
|
|
@ -241,13 +241,13 @@ where
|
||||||
|
|
||||||
let mut ui = self.application.borrow_mut();
|
let mut ui = self.application.borrow_mut();
|
||||||
let element = ui.view();
|
let element = ui.view();
|
||||||
let mut style_sheet = style::Sheet::new();
|
let mut css = Css::new();
|
||||||
|
|
||||||
let node = element.widget.node(bump, &self.bus, &mut style_sheet);
|
let node = element.widget.node(bump, &self.bus, &mut css);
|
||||||
|
|
||||||
div(bump)
|
div(bump)
|
||||||
.attr("style", "width: 100%; height: 100%")
|
.attr("style", "width: 100%; height: 100%")
|
||||||
.children(vec![style_sheet.node(bump), node])
|
.children(vec![css.node(bump), node])
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! [`Widget`]: trait.Widget.html
|
//! [`Widget`]: trait.Widget.html
|
||||||
use crate::{style, Bus};
|
use crate::{Bus, Css};
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
|
|
||||||
pub mod button;
|
pub mod button;
|
||||||
|
|
@ -64,6 +64,6 @@ pub trait Widget<Message> {
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
_bus: &Bus<Message>,
|
_bus: &Bus<Message>,
|
||||||
style_sheet: &mut style::Sheet<'b>,
|
style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b>;
|
) -> dodrio::Node<'b>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
//!
|
//!
|
||||||
//! [`Button`]: struct.Button.html
|
//! [`Button`]: struct.Button.html
|
||||||
//! [`State`]: struct.State.html
|
//! [`State`]: struct.State.html
|
||||||
use crate::{style, Background, Bus, Element, Length, Style, Widget};
|
use crate::{css, Background, Bus, Css, Element, Length, Widget};
|
||||||
|
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
|
|
||||||
|
|
@ -126,18 +126,18 @@ where
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
bus: &Bus<Message>,
|
bus: &Bus<Message>,
|
||||||
style_sheet: &mut style::Sheet<'b>,
|
style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
|
|
||||||
let width = style::length(self.width);
|
let width = css::length(self.width);
|
||||||
let padding_class =
|
let padding_class =
|
||||||
style_sheet.insert(bump, Style::Padding(self.padding));
|
style_sheet.insert(bump, css::Rule::Padding(self.padding));
|
||||||
|
|
||||||
let background = match self.background {
|
let background = match self.background {
|
||||||
None => String::from("none"),
|
None => String::from("none"),
|
||||||
Some(background) => match background {
|
Some(background) => match background {
|
||||||
Background::Color(color) => style::color(color),
|
Background::Color(color) => css::color(color),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{style, Bus, Color, Element, Widget};
|
use crate::{Bus, Color, Css, Element, Widget};
|
||||||
|
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
@ -68,7 +68,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
bus: &Bus<Message>,
|
bus: &Bus<Message>,
|
||||||
_style_sheet: &mut style::Sheet<'b>,
|
_style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{style, Align, Bus, Element, Length, Style, Widget};
|
use crate::{css, Align, Bus, Css, Element, Length, Widget};
|
||||||
|
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
use std::u32;
|
use std::u32;
|
||||||
|
|
@ -112,7 +112,7 @@ impl<'a, Message> Widget<Message> for Column<'a, Message> {
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
publish: &Bus<Message>,
|
publish: &Bus<Message>,
|
||||||
style_sheet: &mut style::Sheet<'b>,
|
style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
|
|
||||||
|
|
@ -122,18 +122,18 @@ impl<'a, Message> Widget<Message> for Column<'a, Message> {
|
||||||
.map(|element| element.widget.node(bump, publish, style_sheet))
|
.map(|element| element.widget.node(bump, publish, style_sheet))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let column_class = style_sheet.insert(bump, Style::Column);
|
let column_class = style_sheet.insert(bump, css::Rule::Column);
|
||||||
|
|
||||||
let spacing_class =
|
let spacing_class =
|
||||||
style_sheet.insert(bump, Style::Spacing(self.spacing));
|
style_sheet.insert(bump, css::Rule::Spacing(self.spacing));
|
||||||
|
|
||||||
let padding_class =
|
let padding_class =
|
||||||
style_sheet.insert(bump, Style::Padding(self.padding));
|
style_sheet.insert(bump, css::Rule::Padding(self.padding));
|
||||||
|
|
||||||
let width = style::length(self.width);
|
let width = css::length(self.width);
|
||||||
let height = style::length(self.height);
|
let height = css::length(self.height);
|
||||||
|
|
||||||
let align_items = style::align(self.align_items);
|
let align_items = css::align(self.align_items);
|
||||||
|
|
||||||
// TODO: Complete styling
|
// TODO: Complete styling
|
||||||
div(bump)
|
div(bump)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{bumpalo, style, Align, Bus, Element, Length, Style, Widget};
|
use crate::{bumpalo, css, Align, Bus, Css, Element, Length, Widget};
|
||||||
|
|
||||||
/// An element decorating some content.
|
/// An element decorating some content.
|
||||||
///
|
///
|
||||||
|
|
@ -94,17 +94,17 @@ where
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
bus: &Bus<Message>,
|
bus: &Bus<Message>,
|
||||||
style_sheet: &mut style::Sheet<'b>,
|
style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
|
|
||||||
let column_class = style_sheet.insert(bump, Style::Column);
|
let column_class = style_sheet.insert(bump, css::Rule::Column);
|
||||||
|
|
||||||
let width = style::length(self.width);
|
let width = css::length(self.width);
|
||||||
let height = style::length(self.height);
|
let height = css::length(self.height);
|
||||||
|
|
||||||
let align_items = style::align(self.horizontal_alignment);
|
let align_items = css::align(self.horizontal_alignment);
|
||||||
let justify_content = style::align(self.vertical_alignment);
|
let justify_content = css::align(self.vertical_alignment);
|
||||||
|
|
||||||
let node = div(bump)
|
let node = div(bump)
|
||||||
.attr(
|
.attr(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{style, Bus, Element, Length, Widget};
|
use crate::{Bus, Css, Element, Length, Widget};
|
||||||
|
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ impl<Message> Widget<Message> for Image {
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
_bus: &Bus<Message>,
|
_bus: &Bus<Message>,
|
||||||
_style_sheet: &mut style::Sheet<'b>,
|
_style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{style, Bus, Color, Element, Widget};
|
use crate::{Bus, Color, Css, Element, Widget};
|
||||||
|
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
bus: &Bus<Message>,
|
bus: &Bus<Message>,
|
||||||
_style_sheet: &mut style::Sheet<'b>,
|
_style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{style, Align, Bus, Element, Length, Style, Widget};
|
use crate::{css, Align, Bus, Css, Element, Length, Widget};
|
||||||
|
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
use std::u32;
|
use std::u32;
|
||||||
|
|
@ -113,7 +113,7 @@ impl<'a, Message> Widget<Message> for Row<'a, Message> {
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
publish: &Bus<Message>,
|
publish: &Bus<Message>,
|
||||||
style_sheet: &mut style::Sheet<'b>,
|
style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
|
|
||||||
|
|
@ -123,18 +123,18 @@ impl<'a, Message> Widget<Message> for Row<'a, Message> {
|
||||||
.map(|element| element.widget.node(bump, publish, style_sheet))
|
.map(|element| element.widget.node(bump, publish, style_sheet))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let row_class = style_sheet.insert(bump, Style::Row);
|
let row_class = style_sheet.insert(bump, css::Rule::Row);
|
||||||
|
|
||||||
let spacing_class =
|
let spacing_class =
|
||||||
style_sheet.insert(bump, Style::Spacing(self.spacing));
|
style_sheet.insert(bump, css::Rule::Spacing(self.spacing));
|
||||||
|
|
||||||
let padding_class =
|
let padding_class =
|
||||||
style_sheet.insert(bump, Style::Padding(self.padding));
|
style_sheet.insert(bump, css::Rule::Padding(self.padding));
|
||||||
|
|
||||||
let width = style::length(self.width);
|
let width = css::length(self.width);
|
||||||
let height = style::length(self.height);
|
let height = css::length(self.height);
|
||||||
|
|
||||||
let justify_content = style::align(self.align_items);
|
let justify_content = css::align(self.align_items);
|
||||||
|
|
||||||
// TODO: Complete styling
|
// TODO: Complete styling
|
||||||
div(bump)
|
div(bump)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
//! Navigate an endless amount of content with a scrollbar.
|
//! Navigate an endless amount of content with a scrollbar.
|
||||||
use crate::{bumpalo, style, Align, Bus, Column, Element, Length, Widget};
|
use crate::{bumpalo, css, Align, Bus, Column, Css, Element, Length, Widget};
|
||||||
|
|
||||||
/// A widget that can vertically display an infinite amount of content with a
|
/// A widget that can vertically display an infinite amount of content with a
|
||||||
/// scrollbar.
|
/// scrollbar.
|
||||||
|
|
@ -105,12 +105,12 @@ where
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
bus: &Bus<Message>,
|
bus: &Bus<Message>,
|
||||||
style_sheet: &mut style::Sheet<'b>,
|
style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
|
|
||||||
let width = style::length(self.width);
|
let width = css::length(self.width);
|
||||||
let height = style::length(self.height);
|
let height = css::length(self.height);
|
||||||
|
|
||||||
let node = div(bump)
|
let node = div(bump)
|
||||||
.attr(
|
.attr(
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
//!
|
//!
|
||||||
//! [`Slider`]: struct.Slider.html
|
//! [`Slider`]: struct.Slider.html
|
||||||
//! [`State`]: struct.State.html
|
//! [`State`]: struct.State.html
|
||||||
use crate::{style, Bus, Element, Length, Widget};
|
use crate::{Bus, Css, Element, Length, Widget};
|
||||||
|
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
use std::{ops::RangeInclusive, rc::Rc};
|
use std::{ops::RangeInclusive, rc::Rc};
|
||||||
|
|
@ -88,7 +88,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
bus: &Bus<Message>,
|
bus: &Bus<Message>,
|
||||||
_style_sheet: &mut style::Sheet<'b>,
|
_style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{style, Bus, Element, Length, Widget};
|
use crate::{css, Bus, Css, Element, Length, Widget};
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
|
|
||||||
/// An amount of empty space.
|
/// An amount of empty space.
|
||||||
|
|
@ -44,12 +44,12 @@ impl<'a, Message> Widget<Message> for Space {
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
_publish: &Bus<Message>,
|
_publish: &Bus<Message>,
|
||||||
_style_sheet: &mut style::Sheet<'b>,
|
_css: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
|
|
||||||
let width = style::length(self.width);
|
let width = css::length(self.width);
|
||||||
let height = style::length(self.height);
|
let height = css::length(self.height);
|
||||||
|
|
||||||
let style = bumpalo::format!(
|
let style = bumpalo::format!(
|
||||||
in bump,
|
in bump,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
style, Bus, Color, Element, Font, HorizontalAlignment, Length,
|
css, Bus, Color, Css, Element, Font, HorizontalAlignment, Length,
|
||||||
VerticalAlignment, Widget,
|
VerticalAlignment, Widget,
|
||||||
};
|
};
|
||||||
use dodrio::bumpalo;
|
use dodrio::bumpalo;
|
||||||
|
|
@ -112,15 +112,15 @@ impl<'a, Message> Widget<Message> for Text {
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
_publish: &Bus<Message>,
|
_publish: &Bus<Message>,
|
||||||
_style_sheet: &mut style::Sheet<'b>,
|
_style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
|
|
||||||
let content = bumpalo::format!(in bump, "{}", self.content);
|
let content = bumpalo::format!(in bump, "{}", self.content);
|
||||||
let color = style::color(self.color.unwrap_or(Color::BLACK));
|
let color = css::color(self.color.unwrap_or(Color::BLACK));
|
||||||
|
|
||||||
let width = style::length(self.width);
|
let width = css::length(self.width);
|
||||||
let height = style::length(self.height);
|
let height = css::length(self.height);
|
||||||
|
|
||||||
let text_align = match self.horizontal_alignment {
|
let text_align = match self.horizontal_alignment {
|
||||||
HorizontalAlignment::Left => "left",
|
HorizontalAlignment::Left => "left",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
//!
|
//!
|
||||||
//! [`TextInput`]: struct.TextInput.html
|
//! [`TextInput`]: struct.TextInput.html
|
||||||
//! [`State`]: struct.State.html
|
//! [`State`]: struct.State.html
|
||||||
use crate::{bumpalo, style, Bus, Element, Length, Style, Widget};
|
use crate::{bumpalo, css, Bus, Css, Element, Length, Widget};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
/// A field that can be filled with text.
|
/// A field that can be filled with text.
|
||||||
|
|
@ -133,15 +133,15 @@ where
|
||||||
&self,
|
&self,
|
||||||
bump: &'b bumpalo::Bump,
|
bump: &'b bumpalo::Bump,
|
||||||
bus: &Bus<Message>,
|
bus: &Bus<Message>,
|
||||||
style_sheet: &mut style::Sheet<'b>,
|
style_sheet: &mut Css<'b>,
|
||||||
) -> dodrio::Node<'b> {
|
) -> dodrio::Node<'b> {
|
||||||
use dodrio::builder::*;
|
use dodrio::builder::*;
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
|
||||||
let width = style::length(self.width);
|
let width = css::length(self.width);
|
||||||
let max_width = style::length(self.max_width);
|
let max_width = css::length(self.max_width);
|
||||||
let padding_class =
|
let padding_class =
|
||||||
style_sheet.insert(bump, Style::Padding(self.padding));
|
style_sheet.insert(bump, css::Rule::Padding(self.padding));
|
||||||
|
|
||||||
let on_change = self.on_change.clone();
|
let on_change = self.on_change.clone();
|
||||||
let event_bus = bus.clone();
|
let event_bus = bus.clone();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue