Replies: 4 comments
-
I don't think there's an issue, you don't need to nest things under 'text-nest': {
value: {
- base: { base: 'purple', _hover: 'pink' },
+ base: 'purple',
+ _hover: 'pink',
_onYellowBackground: { base: 'blue', _hover: 'lightblue' },
_onRedBackground: { base: 'green', _hover: 'lightgreen' },
},
}, |
Beta Was this translation helpful? Give feedback.
-
Hm, yeah I could make that work by manually flattening "base" types up to the top level. But it seems weird to me that base should be treated any differently from other conditions. base._hover could be interpreted just fine. And something deeply nested like In my case, I have some utility functions like: function withColorMode({dark: string, light: string}) {
return {
base: light,
_dark: dark,
_osDark: dark
}
} And withSurfaceColor({ default, brand }) {
return {
base: default,
_brand: brand
}
} These functions compose nicely regardless of the order: text: withSurfaceColor({
default: withColorMode({ dark: 'white', light: 'black' }),
brand: 'white',
}); // { base: { base: 'black', _dark: 'white', _osDark: 'white' }, _brand: 'white' } or text: withColorMode({
dark: 'white',
light: withSurfaceColor({ default: 'black', brand: 'white' }),
}); // { base: { base: 'black', _brand: 'white' }, _dark: 'white', _osDark: 'white' } So, in my case, I'd need to flatten the "base" case after all of the operations are finished which would result in a consistent output of: Would be nice if panda would just flatten this for me. There should be no ambiguity in the notation and it's nice that it just works the same as all other conditions. |
Beta Was this translation helpful? Give feedback.
-
totally understand the convenient argument, but as you already noticed with the something like
or you could also do it in hooks: import { defineConfig } from '@pandacss/dev'
export default defineConfig({
// ...
hooks: {
'config:resolved': ({ config, utils }) => {
config.tokens = flattenBase(config.tokens)
config.semanticTokens = flattenBase(config.semanticTokens)
},
},
}) that being said, since this nesting works in the style usage in app code, I think it makes sense to make that work in config as well css({
color: {
base: {
base: "green",
_hover: {
base: "red",
},
},
},
}); |
Beta Was this translation helpful? Give feedback.
-
Whenever you hover the document, every
Referring to the main example in the discussion |
Beta Was this translation helpful? Give feedback.
-
Description
I'm playing with nested conditions in my token configuration.
This works as expected:
Next, let's nest a hover condition for each case so that the text gets lighter when you hover it:
With this code, the yellow and red bg cases work great. But the base case breaks--the text is no longer purple.
This is illustrated in the stackblitz.
Upon investigation, you'll find the CSS:
Link to Reproduction
https://stackblitz.com/edit/vitejs-vite-xve3ql?file=panda.config.ts
Steps to reproduce
Visit the stackblitz https://stackblitz.com/edit/vitejs-vite-xve3ql?file=panda.config.ts
JS Framework
React TS
Panda CSS Version
0.30.2
Browser
No response
Operating System
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions