media queries in themes #598
Replies: 5 comments 5 replies
-
@markdalgleish any chance you'd give a hint on how to solve this properly? |
Beta Was this translation helpful? Give feedback.
-
Why not just do the dynamic css variable defs in a normal CSS file based on preferred media scheme or what-have-you, and then set those css vars as the values of some vanilla-extract style? |
Beta Was this translation helpful? Give feedback.
-
I think this is the simplest solution I could come up with: |
Beta Was this translation helpful? Give feedback.
-
related: #977 |
Beta Was this translation helpful? Give feedback.
-
I'm trying to achieve having media queries applied in a theme (depending on a contract).
With a css such as:
and implemented as:
...the goal is that the demo component would automatically toggle light/dark color scheme with that amount of code. I understand this can be done more explicitly with sprinkles, but sprinkles seems not to allow "any css prop" and you'd need to list explicitly all, which is not convenient imho.
I have "hacked" something which works, but it feels like building against the library. https://codesandbox.io/s/rough-meadow-93conb?file=/src/themes/dynamic.css.ts
So yeah, it works but i think it's not the right construction since we use "style" to create a theme with only vars inside. Hopefully the types are flexible enough to make it work, but I wished it would be as easy as:
I created something which almost works, but not really :) the theme generation fails for an unknown reason, although the inputs i'm passing is 100% similar to what i'm passing manually, so i'm kinda clueless of why it breaks. https://codesandbox.io/s/rough-meadow-93conb?file=/src/themes/createMQTheme.ts
Beta Was this translation helpful? Give feedback.
All reactions