Make the design token object structure optional? #1353
s-h-a-d-o-w
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
I understand what you propose can be more convenient so here is a way to do it your way and keep the current panda behaviour as well: /**
* Recursively wraps each value in a { value: xxx } object
*/
export const wrapValue = (obj: Record<string, any>) => {
const newObj: Record<string, any> = {};
for (const key in obj) {
if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
newObj[key] = wrapValue(obj[key]); // Recursive call for nested objects
} else {
newObj[key] = { value: obj[key] };
}
}
return newObj;
}; import { defineConfig } from '@pandacss/dev'
export default defineConfig({
theme: {
// 👇🏻 Use wrap value here
tokens: wrapValue({
colors: {
primary: '#0FEE0F',
secondary: '#EE0F0F'
},
fonts: {
body: 'system-ui, sans-serif'
}
})
}
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What I mean by that is allowing users to write this:
Because unless missing something, if you don't also specify a description, it's just unnecessary boilerplate. And based on past observations, there are many people out there who dislike that even more than me. 😅
And it seems to me like supporting this should be straightforward. Again, unless I'm missing something, since only just recently stumbled across this project and skimmed the docs.
Beta Was this translation helpful? Give feedback.
All reactions