Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(generator): reset.css import order #902

Merged
merged 1 commit into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/smart-mirrors-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@pandacss/generator': patch
---

Fix reset.css (generated when config has `preflight: true`) import order, always place it first so that it can be easily
overriden
2 changes: 1 addition & 1 deletion packages/generator/src/artifacts/css/flat-css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export const generateFlattenedCss = (ctx: Context) => (options: { files: string[

const unresolved = [
'@layer reset, base, tokens, recipes, utilities;',
preflight && "@import './reset.css';",
"@import './global.css';",
staticCss && "@import './static.css';",
preflight && "@import './reset.css';",
!ctx.tokens.isEmpty && "@import './tokens/index.css';",
keyframes && "@import './tokens/keyframes.css';",
]
Expand Down
8 changes: 6 additions & 2 deletions packages/studio/styled-system/helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function isObject(value) {
var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g
var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g
var astish = (val, tree = [{}]) => {
const block = newRule.exec(val.replace(ruleClean, ''))
const block = newRule.exec((val ?? '').replace(ruleClean, ''))
if (!block) return tree[0]
if (block[4]) tree.shift()
else if (block[3]) tree.unshift((tree[0][block[3]] = tree[0][block[3]] || {}))
Expand Down Expand Up @@ -73,6 +73,7 @@ function mergeProps(...sources) {
}

// src/walk-object.ts
var isNotNullish = (element) => element != null
function walkObject(target, predicate, options = {}) {
const { stop, getKey } = options
function inner(value, path = []) {
Expand All @@ -84,7 +85,10 @@ function walkObject(target, predicate, options = {}) {
if (stop?.(value, childPath)) {
return predicate(value, path)
}
result[key] = inner(child, childPath)
const next = inner(child, childPath)
if (isNotNullish(next)) {
result[key] = next
}
}
return result
}
Expand Down