-
-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(css_formatter): use format_number_token utils for css number
- Loading branch information
1 parent
b29ac6f
commit 296e463
Showing
7 changed files
with
169 additions
and
224 deletions.
There are no files selected for viewing
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,13 +1,11 @@ | ||
use crate::prelude::*; | ||
use biome_css_syntax::{CssNumber, CssNumberFields}; | ||
use biome_formatter::write; | ||
use biome_css_syntax::CssNumber; | ||
use biome_formatter::token::number::format_number_token; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssNumber; | ||
impl FormatNodeRule<CssNumber> for FormatCssNumber { | ||
fn fmt_fields(&self, node: &CssNumber, f: &mut CssFormatter) -> FormatResult<()> { | ||
let CssNumberFields { value_token } = node.as_fields(); | ||
|
||
write!(f, [value_token.format()]) | ||
format_number_token(&node.value_token()?).fmt(f) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
hr { | ||
opacity: .25; | ||
} | ||
|
||
h3 { | ||
font-size: calc(1.3rem + .6vw); | ||
} | ||
h4 { | ||
font-size: calc(1.275rem + .3vw); | ||
} | ||
sup { | ||
top: -.5em; | ||
} | ||
.row { | ||
--bs-gutter-x: 1.5rem; | ||
--bs-gutter-y: 0; | ||
margin-top: calc(var(--bs-gutter-y) * -1); | ||
margin-right: calc(var(--bs-gutter-x) * -.5); | ||
margin-left: calc(var(--bs-gutter-x) * -.5); | ||
} |
67 changes: 67 additions & 0 deletions
67
crates/biome_css_formatter/tests/specs/css/number.css.snap
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,67 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: css/number.css | ||
--- | ||
# Input | ||
|
||
```css | ||
hr { | ||
opacity: .25; | ||
} | ||
|
||
h3 { | ||
font-size: calc(1.3rem + .6vw); | ||
} | ||
h4 { | ||
font-size: calc(1.275rem + .3vw); | ||
} | ||
sup { | ||
top: -.5em; | ||
} | ||
.row { | ||
--bs-gutter-x: 1.5rem; | ||
--bs-gutter-y: 0; | ||
margin-top: calc(var(--bs-gutter-y) * -1); | ||
margin-right: calc(var(--bs-gutter-x) * -.5); | ||
margin-left: calc(var(--bs-gutter-x) * -.5); | ||
} | ||
|
||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Quote style: Double Quotes | ||
----- | ||
|
||
```css | ||
hr { | ||
opacity: 0.25; | ||
} | ||
|
||
h3 { | ||
font-size: calc(1.3rem + .6vw); | ||
} | ||
h4 { | ||
font-size: calc(1.275rem + .3vw); | ||
} | ||
sup { | ||
top: -.5em; | ||
} | ||
.row { | ||
--bs-gutter-x: 1.5rem; | ||
--bs-gutter-y: 0; | ||
margin-top: calc(var(--bs-gutter-y) * -1); | ||
margin-right: calc(var(--bs-gutter-x) * -0.5); | ||
margin-left: calc(var(--bs-gutter-x) * -0.5); | ||
} | ||
``` |
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
74 changes: 0 additions & 74 deletions
74
crates/biome_css_formatter/tests/specs/prettier/css/color/whitespace-syntax.css.snap
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.