diff options
author | 2021-06-01 19:59:02 +0700 | |
---|---|---|
committer | 2021-06-01 19:59:02 +0700 | |
commit | aab2176802b6d745a7eab76ec13762b5b4ddf782 (patch) | |
tree | 3d1655b36aa8d7151c878e1879c03c8271a466a5 /web/src/css.rs | |
parent | a9eb591628017caaf7aa9af505d1206f7a143a9a (diff) | |
parent | 8a3b71df8b619571ce0a972826cb5a3987b66b3d (diff) | |
download | iced-aab2176802b6d745a7eab76ec13762b5b4ddf782.tar.gz iced-aab2176802b6d745a7eab76ec13762b5b4ddf782.tar.bz2 iced-aab2176802b6d745a7eab76ec13762b5b4ddf782.zip |
Merge pull request #630 from blefevre/asymmetric-padding
Add support for asymmetrical padding
Diffstat (limited to 'web/src/css.rs')
-rw-r--r-- | web/src/css.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/web/src/css.rs b/web/src/css.rs index bdde23f3..66c363f2 100644 --- a/web/src/css.rs +++ b/web/src/css.rs @@ -1,5 +1,5 @@ //! Style your widgets. -use crate::{bumpalo, Align, Background, Color, Length}; +use crate::{bumpalo, Align, Background, Color, Length, Padding}; use std::collections::BTreeMap; @@ -12,9 +12,6 @@ pub enum Rule { /// Container with horizonal distribution Row, - /// Padding of the container - Padding(u16), - /// Spacing between elements Spacing(u16), } @@ -25,7 +22,6 @@ impl Rule { match self { Rule::Column => String::from("c"), Rule::Row => String::from("r"), - Rule::Padding(padding) => format!("p-{}", padding), Rule::Spacing(spacing) => format!("s-{}", spacing), } } @@ -45,13 +41,6 @@ impl Rule { bumpalo::format!(in bump, ".{} {}", class, body).into_bump_str() } - Rule::Padding(padding) => bumpalo::format!( - in bump, - ".{} {{ box-sizing: border-box; padding: {}px }}", - class, - padding - ) - .into_bump_str(), Rule::Spacing(spacing) => bumpalo::format!( in bump, ".c.{} > * {{ margin-bottom: {}px }} \ @@ -170,3 +159,13 @@ pub fn align(align: Align) -> &'static str { Align::End => "flex-end", } } + +/// Returns the style value for the given [`Padding`]. +/// +/// [`Padding`]: struct.Padding.html +pub fn padding(padding: Padding) -> String { + format!( + "{}px {}px {}px {}px", + padding.top, padding.right, padding.bottom, padding.left + ) +} |