Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Mar 21, 2023
1 parent 6dbd887 commit 01632cf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
52 changes: 24 additions & 28 deletions src/css/deserialize.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
//! Parse/Deserialize raw CSS strings into Taffy style types

use crate::{
prelude::*,
style::{FlexDirection, Position},
};
use lightningcss::properties::border::LineStyle;
use lightningcss::properties::{align, display, flex, position, size};
use lightningcss::properties::{align, border, display, flex, position, size};
use lightningcss::{
properties::{align::GapValue, border::BorderSideWidth, Property, PropertyId},
properties::{Property, PropertyId},
stylesheet::ParserOptions,
traits::Parse,
values::{
Expand All @@ -12,10 +16,6 @@ use lightningcss::{
ratio::Ratio,
},
};
use crate::{
prelude::*,
style::{FlexDirection, Position},
};

/// applies the entire html namespace defined in dioxus-html with the specified configeration
pub fn apply_layout_attributes(name: &str, value: &str, style: &mut Style) {
Expand Down Expand Up @@ -309,26 +309,22 @@ fn convert_length_percentage(dimension_percentage: DimensionPercentage<LengthVal
fn convert_padding(dimension_percentage: LengthPercentageOrAuto) -> LengthPercentage {
match dimension_percentage {
LengthPercentageOrAuto::Auto => unimplemented!(),
LengthPercentageOrAuto::LengthPercentage(lp) => {
match lp {
LengthPercentageOrAuto::LengthPercentage(lp) => match lp {
DimensionPercentage::Dimension(value) => LengthPercentage::Points(extract_px_value(value)),
DimensionPercentage::Percentage(percentage) => LengthPercentage::Percent(percentage.0),
DimensionPercentage::Calc(_) => unimplemented!(),
}
}
},
}
}

fn convert_length_percentage_or_auto(dimension_percentage: LengthPercentageOrAuto) -> LengthPercentageAuto {
match dimension_percentage {
LengthPercentageOrAuto::Auto => LengthPercentageAuto::Auto,
LengthPercentageOrAuto::LengthPercentage(lp) => {
match lp {
LengthPercentageOrAuto::LengthPercentage(lp) => match lp {
DimensionPercentage::Dimension(value) => LengthPercentageAuto::Points(extract_px_value(value)),
DimensionPercentage::Percentage(percentage) => LengthPercentageAuto::Percent(percentage.0),
DimensionPercentage::Calc(_) => todo!(),
}
}
},
}
}

Expand All @@ -340,33 +336,33 @@ fn convert_dimension(dimension_percentage: DimensionPercentage<LengthValue>) ->
}
}

fn convert_border_side_width(border_side_width: BorderSideWidth) -> LengthPercentage {
fn convert_border_side_width(border_side_width: border::BorderSideWidth) -> LengthPercentage {
match border_side_width {
BorderSideWidth::Length(Length::Value(value)) => LengthPercentage::Points(extract_px_value(value)),
BorderSideWidth::Thick => LengthPercentage::Points(1.0),
BorderSideWidth::Medium => LengthPercentage::Points(3.0),
BorderSideWidth::Thin => LengthPercentage::Points(5.0),
BorderSideWidth::Length(_) => unimplemented!(),
border::BorderSideWidth::Length(Length::Value(value)) => LengthPercentage::Points(extract_px_value(value)),
border::BorderSideWidth::Thick => LengthPercentage::Points(1.0),
border::BorderSideWidth::Medium => LengthPercentage::Points(3.0),
border::BorderSideWidth::Thin => LengthPercentage::Points(5.0),
border::BorderSideWidth::Length(_) => unimplemented!(),
}
}

fn convert_gap_value(gap_value: GapValue) -> LengthPercentage {
fn convert_gap_value(gap_value: align::GapValue) -> LengthPercentage {
match gap_value {
GapValue::LengthPercentage(dim) => convert_length_percentage(dim),
GapValue::Normal => LengthPercentage::Points(0.0),
align::GapValue::LengthPercentage(dim) => convert_length_percentage(dim),
align::GapValue::Normal => LengthPercentage::Points(0.0),
}
}

fn convert_size(size: size::Size) -> Dimension {
match size {
size::Size::Auto => Dimension::Auto,
size::Size::LengthPercentage(length) => convert_dimension(length),
size::Size::MinContent(_) => Dimension::Auto, // Unimplemented, so default auto
size::Size::MaxContent(_) => Dimension::Auto, // Unimplemented, so default auto
size::Size::FitContent(_) => Dimension::Auto, // Unimplemented, so default auto
size::Size::MinContent(_) => Dimension::Auto, // Unimplemented, so default auto
size::Size::MaxContent(_) => Dimension::Auto, // Unimplemented, so default auto
size::Size::FitContent(_) => Dimension::Auto, // Unimplemented, so default auto
size::Size::FitContentFunction(_) => Dimension::Auto, // Unimplemented, so default auto
size::Size::Stretch(_) => Dimension::Auto, // Unimplemented, so default auto
size::Size::Contain => Dimension::Auto, // Unimplemented, so default auto
size::Size::Stretch(_) => Dimension::Auto, // Unimplemented, so default auto
size::Size::Contain => Dimension::Auto, // Unimplemented, so default auto
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/css/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//! Helpers for serializing/deserializing Taffy styles to/from CSS strings

pub mod deserialize;
pub mod deserialize;

0 comments on commit 01632cf

Please sign in to comment.