-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(css_parser): better handling for Dimensions (#1375)
- Loading branch information
1 parent
73c5244
commit 8061a77
Showing
47 changed files
with
4,863 additions
and
4,486 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file. | ||
pub(crate) mod number; | ||
pub(crate) mod percent_dimension; | ||
pub(crate) mod percentage; | ||
pub(crate) mod ratio; | ||
pub(crate) mod regular_dimension; | ||
pub(crate) mod string; | ||
pub(crate) mod unknown_dimension; |
13 changes: 0 additions & 13 deletions
13
crates/biome_css_formatter/src/css/value/percent_dimension.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 12 additions & 9 deletions
21
crates/biome_css_formatter/src/css/value/regular_dimension.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
use crate::prelude::*; | ||
use crate::{prelude::*, utils::string_utils::FormatTokenAsLowercase}; | ||
use biome_css_syntax::{CssRegularDimension, CssRegularDimensionFields}; | ||
use biome_formatter::write; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssRegularDimension; | ||
impl FormatNodeRule<CssRegularDimension> for FormatCssRegularDimension { | ||
fn fmt_fields(&self, node: &CssRegularDimension, f: &mut CssFormatter) -> FormatResult<()> { | ||
let CssRegularDimensionFields { value, unit } = node.as_fields(); | ||
let CssRegularDimensionFields { | ||
value_token, | ||
unit_token, | ||
} = node.as_fields(); | ||
|
||
write!(f, [value.format()])?; | ||
|
||
if let Ok(unit) = unit { | ||
write!(f, [unit.format()])?; | ||
} | ||
|
||
Ok(()) | ||
write!( | ||
f, | ||
[ | ||
FormatTokenAsLowercase::from(value_token?), | ||
FormatTokenAsLowercase::from(unit_token?), | ||
] | ||
) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
crates/biome_css_formatter/src/css/value/unknown_dimension.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use crate::{prelude::*, utils::string_utils::FormatTokenAsLowercase}; | ||
use biome_css_syntax::{CssUnknownDimension, CssUnknownDimensionFields}; | ||
use biome_formatter::write; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssUnknownDimension; | ||
impl FormatNodeRule<CssUnknownDimension> for FormatCssUnknownDimension { | ||
fn fmt_fields(&self, node: &CssUnknownDimension, f: &mut CssFormatter) -> FormatResult<()> { | ||
let CssUnknownDimensionFields { | ||
value_token, | ||
unit_token, | ||
} = node.as_fields(); | ||
|
||
let var_name = write!( | ||
f, | ||
[ | ||
FormatTokenAsLowercase::from(value_token?), | ||
FormatTokenAsLowercase::from(unit_token?), | ||
] | ||
); | ||
var_name | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.