-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(formatter): format
@starting-style
(#2213)
- Loading branch information
Showing
3 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
11 changes: 8 additions & 3 deletions
11
crates/biome_css_formatter/src/css/statements/starting_style_at_rule.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,10 +1,15 @@ | ||
use crate::prelude::*; | ||
use biome_css_syntax::CssStartingStyleAtRule; | ||
use biome_rowan::AstNode; | ||
use biome_css_syntax::{CssStartingStyleAtRule, CssStartingStyleAtRuleFields}; | ||
use biome_formatter::write; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssStartingStyleAtRule; | ||
impl FormatNodeRule<CssStartingStyleAtRule> for FormatCssStartingStyleAtRule { | ||
fn fmt_fields(&self, node: &CssStartingStyleAtRule, f: &mut CssFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let CssStartingStyleAtRuleFields { | ||
starting_style_token, | ||
block, | ||
} = node.as_fields(); | ||
write!(f, [starting_style_token.format(), space(), block.format()]) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
crates/biome_css_formatter/tests/specs/css/atrule/starting_style.css
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,18 @@ | ||
@starting-style { | ||
h1 { | ||
background-color: transparent; | ||
} | ||
|
||
|
||
@layer foo { | ||
@starting-style { | ||
background-color: transparent; | ||
} | ||
|
||
div { | ||
|
||
|
||
height: 100px; | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
crates/biome_css_formatter/tests/specs/css/atrule/starting_style.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,60 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: css/atrule/starting_style.css | ||
--- | ||
# Input | ||
|
||
```css | ||
@starting-style { | ||
h1 { | ||
background-color: transparent; | ||
} | ||
|
||
|
||
@layer foo { | ||
@starting-style { | ||
background-color: transparent; | ||
} | ||
|
||
div { | ||
|
||
|
||
height: 100px; | ||
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Quote style: Double Quotes | ||
----- | ||
|
||
```css | ||
@starting-style { | ||
h1 { | ||
background-color: transparent; | ||
} | ||
|
||
@layer foo { | ||
@starting-style { | ||
background-color: transparent; | ||
} | ||
|
||
div { | ||
height: 100px; | ||
} | ||
} | ||
} | ||
``` |