-
Notifications
You must be signed in to change notification settings - Fork 38
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
Missing support for core-supported dynamic breakpoints #16
Missing support for core-supported dynamic breakpoints #16
Comments
we can't also define custom screen sizes |
I would like to try my hand at extending the plugin code accordingly. And I would also like to create a pull request if it works. How the return value (i.e. the container query) could be adjusted to implement the different variants is obvious. Since within the function Could someone give me a hint how to get the text between the Update: I would like to be able to implement one of the following two alternatives.
I would also appreciate any recommendations on what would be a better fit for the Tailwind standard. |
Hi @christian-wantia, thanks! If you want to take a stab at it, and have any questions along the way, let me know. I would recommend using my related PR (tailwindlabs/tailwindcss#11225) as a guide, as it does the same operation we're striving for here but for media queries. Some notes / gotchas
Thanks again for contributing here! I really appreciate it. Let me know how I can help. |
Reading through the conversation, file changes, and your notes, I realized that I still need to figure out a few things before I dive into the code. I'll try my hand at it, and would appreciate feedback on whether my assumptions are correct. TopicMedia and Container Queries in generalFor Responsive Web Design, the concept of Media Queries has been around for a long time. These allow CSS rules to be applied depending on, for example, the width of the viewport. New is the concept of Container Queries. These are now (as of 2023-07-10) supported by most browsers, and allow CSS rules to be applied depending on, for example, the width of a parent HTML element. TailwindTailwind (up to and including v3.3) makes Responsive Design implementable with media queries - either via predefined Breakpoint prefixes or via Arbitrary values. Examples from the documentation:
Support for container queries can be added using the Tailwind plugin container-queries. The plugin so far only allows Examples from the documentation:
What GoalThe goal is to find a syntax and elegant implementation for the container queries that allows dynamic Next, I will first get an systematically overview of what is already available in terms of |
@christian-wantia Thank you for the detailed design review. Most of that is correct! Re the syntax discovery phase, let's stick with the two syntax options proposed earlier in my original post. Thanks! Notes: The existing syntax should likely be deprecated to support the new syntax exclusively to be inform with the core syntax. Much of the required logic is likely already set up. I'd suggest studying what this plugin is already doing and compare with the PR I linked previously from core. |
Cool. What do I need to correct in my mental model? (because you wrote „most“)
Okay. Do you have an idea, how we can integrate the design tokens (md, xl, …) in your syntax?
Hmm. I don't understand that. Maybe it's because English is not my native language. Even with Deepl I don't get behind the sense of this statement. Would you explain this to me?
I have already started with it in a free moment. I have understood some of it, but not everything yet. I'll have to set up some more time for that. It's super helpful that I can build on this. Thank you! |
@christian-wantia Sure! Please excuse my "most" — I only meant to clarify a few points, and I can respond to your questions below 🙂
|
Very nice. Thank you. Now I see much clearer. :-) So do I understand it correctly that the intended syntax for both - viewport (screen) and container queries - is now the following? Except that the container queries get an @ sign in front, and can get a name? (The round brackets are there to signal that the @ is optional.)
BTW: Was it a conscious decision that the variant with design tokens (
How do we integrate the width/height distinction? For the arbitrary values, the h: and w: would work inside the square brackets. But how do we implement that for the design tokens? After the colon there are already the utilities Oh yes, I am very interested. I just hope I can make it work. Because I'm not a full time developer. Normally I'm more of a product owner or scrum master type. But in this case, I'd like to try it myself. |
@christian-wantia For non-arbitrary men sizes, it would just be For the w/h distinction (only available for arbitrary values), that's where the For guidance on implementing that inner-bracket detail, see my related PR here: tailwindlabs/tailwindcss#11225 |
I hope I'm not straining your nerves too much. But before I can get to work on the implementation, I need clarity. Moreover, I am not completely free of my own and third party interests. Therefore, I would like to at least check if our ideas match those of the Tailwind project.
Okay. Exclusively I am in favor of allowing both. This makes the code more readable when
Is there anything against allowing the height for the design token variant as well? I think it's great that we can quickly try out arbitrary values when developing a design system. But ultimately, at least I always strive to systematize sizes.
I was very surprised when I noticed that the two variants behave differently. Therefore, I ask if there is a reason for this. |
@christian-wantia Not at all — I appreciate you seeking clarity on all this!
As they should match the syntax, supported by the court package, the intention, at least, for this issue is to support the former, but not the latter for named (non-arbitrary) usage. For example, in core TailwindCSS, While it could be more uniform to support min/max, in all cases, I doubt the core team would want to support two alternative syntax is for the same functionality, and the existing option is more concise.
Syntax like Besides, there's a drastically smaller use case for named height queries vs. width queries. In many cases, even when there is a simple solution available, the core team avoids implementing features that don't have reasonable IRL uses. For example, they recently implemented utilities like
I think I may know the difference you're speaking of, but to validate my assumption, could you please clarify the difference you noticed? |
Sorry, @brandonmcconnell, for getting back to you so late - and then without good news. After our last exchange, one by one my son, myself, my daughter and my wife got sick. This has put me behind in business. And in the meantime, our business has evolved, so I don't have time for side projects at the moment. With a little luck, next year I will not only have time for side projects again myself, but I may even be able to sponsor some work time. Thanks for your support in my attempt to understand the connections. |
@christian-wantia do you think the PR proposed by @brandonmcconnell could be reviewed and eventually merged? |
@leo-cheron That PR isn't directly related to this issue, but rather it includes an improvement to standard media query variants to support height, in addition to width. I would encourage you to follow up in that PR's thread directly. |
What version of @tailwindcss/container-queries are you using?
v0.1.1
What version of Node.js are you using?
v18.16.0
What browser are you using?
Chrome v112.0.5615.137
What operating system are you using?
macOS v13.1 (22C65)
Tailwind Play Reproduction
https://play.tailwindcss.com/iyNosSvgd1
Describe your issue
Purpose / Problem
There currently exists no way AFAIK to use the dynamic breakpoints functionality newly introduced in TailwindCSS v3.2, or anything comparable when it comes to container queries.
There is this arbitrary syntax supported:
@[17.5rem]:underline
however…max-
equivalent existsmin-*
Proposed Solution
It might be helpful to follow the core implementation's lead by adding support for
min-*
andmax-*
dynamic breakpoints for arbitrary values:This way, it works identically to the core implementation but is prepended with
@
, which is already being used by this plugin to denote container-related queries.Support for width/height distinction
Furthermore, per a related PR to the core implementation to add support for an explicit
w:
/h:
prefix to the arbitrary value to determine the dimension (e.g.min/max
-width/height
), implementing the same pattern could be helpful here if that PR passes, which could work like this:Syntax consideration
It may be worth considering which of these syntaxes makes more sense in line with the core implementation:
@
beforemin/max
(as shown above)
@min-[1px]:
@min-[w:1px]:
@min-[h:1px]:
@max-[100vw]:
@max-[w:100vw]:
@max-[h:100vw]:
@
before[…]
(as shown above)
min-@[1px]:
min-@[w:1px]:
min-@[h:1px]:
max-@[100vw]:
max-@[w:100vw]:
max-@[h:100vw]:
The text was updated successfully, but these errors were encountered: