Skip to content

Commit

Permalink
fix #283 - nicer format of template areas
Browse files Browse the repository at this point in the history
  • Loading branch information
jogibear9988 committed Feb 12, 2025
1 parent 8f7f19c commit 03553a5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/stringify/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,17 @@ class Compiler {
this.emit(';')
);
}
if (node.property === 'grid-template-areas')
return (
this.emit(this.indent()) +
this.emit(
node.property +
': ' +
node.value.split('\n').join('\n'.padEnd(22) + this.indent()),
node.position,
) +
this.emit(';')
);
return (
this.emit(this.indent()) +
this.emit(node.property + ': ' + node.value, node.position) +
Expand Down
1 change: 1 addition & 0 deletions test/cases/gridTemplateArea/ast.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"stylesheet","stylesheet":{"source":"input.css","rules":[{"type":"rule","selectors":["foo"],"declarations":[{"type":"declaration","property":"grid-template-areas","value":"\"menu head head head\"\n\"menu main main main\"\n\"menu main main main\"\n\"menu footer footer footer\"","position":{"start":{"line":2,"column":3},"end":{"line":5,"column":28},"source":"input.css"}}],"position":{"start":{"line":1,"column":1},"end":{"line":6,"column":2},"source":"input.css"}}],"parsingErrors":[]}}
4 changes: 4 additions & 0 deletions test/cases/gridTemplateArea/compressed.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
foo{grid-template-areas:"menu head head head"
"menu main main main"
"menu main main main"
"menu footer footer footer";}
6 changes: 6 additions & 0 deletions test/cases/gridTemplateArea/input.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
foo {
grid-template-areas: "menu head head head"
"menu main main main"
"menu main main main"
"menu footer footer footer";
}
6 changes: 6 additions & 0 deletions test/cases/gridTemplateArea/output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
foo {
grid-template-areas: "menu head head head"
"menu main main main"
"menu main main main"
"menu footer footer footer";
}

0 comments on commit 03553a5

Please sign in to comment.