-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
css: CSS Media Query Support #132
Comments
Currently no there isn't a good way to accomplish this, definitely a good feature for us to have though! |
Hello! Might attempt to add this in a PR. |
Hi @headblockhead, I was thinking of picking this one up this week, are you still thinking of PRing for this one? Don't want to duplicate work if you're almost there with it! |
@joerdav Feel free to make a PR, I haven’t been able to start on adding media queries yet, maybe I was a bit too eager with my comment(!) |
Started work here: https://github.com/joerdav/templ/tree/media-queries |
Figured it would be worth discussing the design of it before I go ahead and implement the generator. |
So far the generator side of this has been more complex than expected, I'm thinking of parking for now since there is bigger fish to fry! And this can be worked around at the moment by just using a normal old style tag rather than templ css. |
Any update on this? |
@nftbolt not yet. For now I'd recommend using |
I have a proof-of-concept started that uses the tdewolff CSS parser as a base, and layers in some additional parsing for Go expressions. The idea would be to use standard Note that most are of type CSSToken, but then there's also a few of type GoToken, which is where the variables are inserted. At the moment, there's no concept of property name to property value, which is what the CSS sanitization uses to determine what (if any) sanitization to support. Before I jump to anything, the plan is to have an online meeting where everyone that's interested in templ CSS development can get together kick around ideas, and hopefully build consensus on a direction. |
Is there any convenient support for media queries which target classes from CSS expressions?
Given some component like
I'd like to write a media query which changes some properties on that
nav
class. There doesn't seem to be a way to reference theClassName()
of thetempl.ComponentCSSClass
from inside a<style>
tag so I'm currently resorting a plainfunc() string
to build a style tag withfmt.Sprintf
which isn't very ergonomic.Is there a better way to accomplish this at this time?
Ideally, something like Emotion's media query support would be available so we could write something like
which would generate CSS like
The text was updated successfully, but these errors were encountered: