-
-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c63922f
commit d70092e
Showing
13 changed files
with
396 additions
and
33 deletions.
There are no files selected for viewing
22 changes: 19 additions & 3 deletions
22
crates/biome_css_formatter/src/css/auxiliary/container_and_query.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,26 @@ | ||
use crate::prelude::*; | ||
use biome_css_syntax::CssContainerAndQuery; | ||
use biome_rowan::AstNode; | ||
use biome_css_syntax::{CssContainerAndQuery, CssContainerAndQueryFields}; | ||
use biome_formatter::write; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssContainerAndQuery; | ||
impl FormatNodeRule<CssContainerAndQuery> for FormatCssContainerAndQuery { | ||
fn fmt_fields(&self, node: &CssContainerAndQuery, f: &mut CssFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let CssContainerAndQueryFields { | ||
left, | ||
and_token, | ||
right, | ||
} = node.as_fields(); | ||
|
||
write!( | ||
f, | ||
[ | ||
left.format(), | ||
space(), | ||
and_token.format(), | ||
space(), | ||
right.format() | ||
] | ||
) | ||
} | ||
} |
9 changes: 6 additions & 3 deletions
9
crates/biome_css_formatter/src/css/auxiliary/container_not_query.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,13 @@ | ||
use crate::prelude::*; | ||
use biome_css_syntax::CssContainerNotQuery; | ||
use biome_rowan::AstNode; | ||
use biome_css_syntax::{CssContainerNotQuery, CssContainerNotQueryFields}; | ||
use biome_formatter::write; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssContainerNotQuery; | ||
impl FormatNodeRule<CssContainerNotQuery> for FormatCssContainerNotQuery { | ||
fn fmt_fields(&self, node: &CssContainerNotQuery, f: &mut CssFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let CssContainerNotQueryFields { not_token, query } = node.as_fields(); | ||
|
||
write!(f, [not_token.format(), space(), query.format()]) | ||
} | ||
} |
22 changes: 19 additions & 3 deletions
22
crates/biome_css_formatter/src/css/auxiliary/container_or_query.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,26 @@ | ||
use crate::prelude::*; | ||
use biome_css_syntax::CssContainerOrQuery; | ||
use biome_rowan::AstNode; | ||
use biome_css_syntax::{CssContainerOrQuery, CssContainerOrQueryFields}; | ||
use biome_formatter::write; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssContainerOrQuery; | ||
impl FormatNodeRule<CssContainerOrQuery> for FormatCssContainerOrQuery { | ||
fn fmt_fields(&self, node: &CssContainerOrQuery, f: &mut CssFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let CssContainerOrQueryFields { | ||
left, | ||
or_token, | ||
right, | ||
} = node.as_fields(); | ||
|
||
write!( | ||
f, | ||
[ | ||
left.format(), | ||
space(), | ||
or_token.format(), | ||
space(), | ||
right.format() | ||
] | ||
) | ||
} | ||
} |
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
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
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
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
20 changes: 17 additions & 3 deletions
20
crates/biome_css_formatter/src/css/statements/container_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,24 @@ | ||
use crate::prelude::*; | ||
use biome_css_syntax::CssContainerAtRule; | ||
use biome_rowan::AstNode; | ||
use biome_css_syntax::{CssContainerAtRule, CssContainerAtRuleFields}; | ||
use biome_formatter::write; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssContainerAtRule; | ||
impl FormatNodeRule<CssContainerAtRule> for FormatCssContainerAtRule { | ||
fn fmt_fields(&self, node: &CssContainerAtRule, f: &mut CssFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let CssContainerAtRuleFields { | ||
container_token, | ||
name, | ||
query, | ||
block, | ||
} = node.as_fields(); | ||
|
||
write!(f, [container_token.format(), space()])?; | ||
|
||
if name.is_some() { | ||
write!(f, [name.format(), space()])?; | ||
} | ||
|
||
write!(f, [query.format(), space(), block.format()]) | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
crates/biome_css_formatter/tests/specs/css/atrule/container.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,68 @@ | ||
@container name not (width <= 500px) { } | ||
|
||
@container my-layout ( inline-size > 45em) { } | ||
|
||
@container card (inline-size > 30em) or style(--responsive: true) { } | ||
@container card (inline-size > 30em) | ||
|
||
and | ||
style(--responsive: true) { } | ||
|
||
@container card | ||
( | ||
inline-size | ||
> | ||
30em | ||
) | ||
|
||
and | ||
|
||
style( | ||
--responsive: | ||
true) { } | ||
|
||
@container ( | ||
|
||
inline-size | ||
|
||
>= 0px | ||
) { } | ||
|
||
@container card | ||
|
||
( | ||
inline-size > | ||
30em ) and (inline-size < | ||
45em | ||
) { } | ||
|
||
@container ( | ||
100px > | ||
width > | ||
150px ) { } | ||
|
||
@container (not ( width <= 150px ) ) { } | ||
|
||
@container ( ( | ||
width | ||
<= 150px) ) { } | ||
|
||
@container ( | ||
min-width: 700px) { } | ||
|
||
@container sidebar (min-width: 400px) { } | ||
|
||
@container test style( | ||
--responsive: true | ||
) { } | ||
|
||
@container style(--responsive: true) { } | ||
|
||
@container card (inline-size > 30em) { } | ||
|
||
@container style(--responsive: true) { } | ||
|
||
@container(inline-size>=calc(200px)) { } | ||
|
||
@container ( WIDTH <= 150px ) { } | ||
@container ( 150px <= WIDTH ) { } |
Oops, something went wrong.