-
-
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_formatter): media and container queries (#1294)
- Loading branch information
1 parent
c54f043
commit 934fa66
Showing
32 changed files
with
823 additions
and
82 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
22 changes: 19 additions & 3 deletions
22
crates/biome_css_formatter/src/css/auxiliary/media_and_condition.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::CssMediaAndCondition; | ||
use biome_rowan::AstNode; | ||
use biome_css_syntax::{CssMediaAndCondition, CssMediaAndConditionFields}; | ||
use biome_formatter::write; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssMediaAndCondition; | ||
impl FormatNodeRule<CssMediaAndCondition> for FormatCssMediaAndCondition { | ||
fn fmt_fields(&self, node: &CssMediaAndCondition, f: &mut CssFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let CssMediaAndConditionFields { | ||
left, | ||
and_token, | ||
right, | ||
} = node.as_fields(); | ||
|
||
write!( | ||
f, | ||
[ | ||
left.format(), | ||
space(), | ||
and_token.format(), | ||
space(), | ||
right.format() | ||
] | ||
) | ||
} | ||
} |
22 changes: 19 additions & 3 deletions
22
crates/biome_css_formatter/src/css/auxiliary/media_and_type_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::CssMediaAndTypeQuery; | ||
use biome_rowan::AstNode; | ||
use biome_css_syntax::{CssMediaAndTypeQuery, CssMediaAndTypeQueryFields}; | ||
use biome_formatter::write; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssMediaAndTypeQuery; | ||
impl FormatNodeRule<CssMediaAndTypeQuery> for FormatCssMediaAndTypeQuery { | ||
fn fmt_fields(&self, node: &CssMediaAndTypeQuery, f: &mut CssFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let CssMediaAndTypeQueryFields { | ||
left, | ||
and_token, | ||
right, | ||
} = node.as_fields(); | ||
|
||
write!( | ||
f, | ||
[ | ||
left.format(), | ||
space(), | ||
and_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
9 changes: 6 additions & 3 deletions
9
crates/biome_css_formatter/src/css/auxiliary/media_condition_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::CssMediaConditionQuery; | ||
use biome_rowan::AstNode; | ||
use biome_css_syntax::{CssMediaConditionQuery, CssMediaConditionQueryFields}; | ||
use biome_formatter::write; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssMediaConditionQuery; | ||
impl FormatNodeRule<CssMediaConditionQuery> for FormatCssMediaConditionQuery { | ||
fn fmt_fields(&self, node: &CssMediaConditionQuery, f: &mut CssFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let CssMediaConditionQueryFields { condition } = node.as_fields(); | ||
|
||
write!(f, [condition.format()]) | ||
} | ||
} |
Oops, something went wrong.