Skip to content

Commit

Permalink
feat(formatter): format @starting-style (#2213)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Mar 26, 2024
1 parent d86bb50 commit ad0a0b5
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
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()])
}
}
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;
}
}
}
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;
}
}
}
```

0 comments on commit ad0a0b5

Please sign in to comment.