-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add support for dimension prefix when using dynamic min-*
and max-*
(resolved sorting)
#11225
Conversation
This reverts commit ba54545.
This reverts commit ba54545.
* make `sequential` and `parallel` version of a new (tmp) `parse_candidate_strings` * use bitmasks for the strategy Only sending a number over the wire instead of a serialized objects. * use cleaner match syntax
…lwindlabs#11205) * make `@import "tailwindcss"` work out of the box * update changelog
UPDATE: This has all been taken care of now. The full update is in a newer comment, below.
|
This is all patched up and ready for re-review. The sorting now works as expected, and I've included a new test for that. The new and expected order is (in bulleted order):
Here's one example (collapse/expand)HTML w/ TailwindCSS utilities (the input)This rather convoluted class string: <_ class="min-[3px]:font-bold min-[1px]:font-bold min-[2px]:font-bold min-[h:3px]:font-bold min-[h:1px]:font-bold min-[h:2px]:font-bold min-[w:3px]:font-bold min-[w:1px]:font-bold min-[w:2px]:font-bold max-[3px]:font-bold max-[1px]:font-bold max-[2px]:font-bold max-[h:3px]:font-bold max-[h:1px]:font-bold max-[h:2px]:font-bold max-[w:3px]:font-bold max-[w:1px]:font-bold max-[w:2px]:font-bold" /> Generated CSS (the output)…outputs this correctly sorted and grouped CSS block: @media (max-height: 3px) {
.max-\[h\:3px\]\:font-bold {
font-weight: 700;
}
}
@media (max-height: 2px) {
.max-\[h\:2px\]\:font-bold {
font-weight: 700;
}
}
@media (max-height: 1px) {
.max-\[h\:1px\]\:font-bold {
font-weight: 700;
}
}
@media (max-width: 3px) {
.max-\[3px\]\:font-bold,
.max-\[w\:3px\]\:font-bold {
font-weight: 700;
}
}
@media (max-width: 2px) {
.max-\[2px\]\:font-bold,
.max-\[w\:2px\]\:font-bold {
font-weight: 700;
}
}
@media (max-width: 1px) {
.max-\[1px\]\:font-bold,
.max-\[w\:1px\]\:font-bold {
font-weight: 700;
}
}
@media (min-height: 1px) {
.min-\[h\:1px\]\:font-bold {
font-weight: 700;
}
}
@media (min-height: 2px) {
.min-\[h\:2px\]\:font-bold {
font-weight: 700;
}
}
@media (min-height: 3px) {
.min-\[h\:3px\]\:font-bold {
font-weight: 700;
}
}
@media (min-width: 1px) {
.min-\[1px\]\:font-bold,
.min-\[w\:1px\]\:font-bold {
font-weight: 700;
}
}
@media (min-width: 2px) {
.min-\[2px\]\:font-bold,
.min-\[w\:2px\]\:font-bold {
font-weight: 700;
}
}
@media (min-width: 3px) {
.min-\[3px\]\:font-bold,
.min-\[w\:3px\]\:font-bold {
font-weight: 700;
}
} |
@adamwathan @RobinMalfait I wanted to check in on this PR to prevent it from going stale. This is still a feature that would help me in a number of places in my code across several projects. In the meantime, I'm accounting for the lack of height media queries with inline variants (e.g. This PR also accounts for properly sorting media queries, as discussed in PR #11217. All of that is done, tested, and included in this PR. I also have a related issue open on the container queries plugin repo (tailwindlabs/tailwindcss-container-queries#16) here, which addresses the current syntax differences between that plugin and the latest syntax employed by core Tailwind CSS. |
Hey finally getting back to this! I think still going to say no to this one for now mostly because of the API — I still like You mentioned before this conflicts with the <div class="min-h-[200px]:min-h-[100px]"> I think would likely accept this though with that syntax, but against v4 (the |
UPDATE: I am opening this PR as a re-open of #11217, as I have accounted for the changes recommended by @adamwathan. I have fixed the sorting bug from before and provided feedback on his other questions at the bottom of this PR description under "Feedback resolution".
This PR adds support for using a new dimension prefix with dynamic
min-*
andmax-*
variants.Syntax:
type-[length]
ortype-[dimension:length]
, where…type
:'min' | 'max'
dimension
:'w' | 'h'
(optional, can be excluded to omit and default towidth
)length
: any valid CSS lengthSyntax examples:
Real use case examples:
only applied on screens taller than
100px
only applied on screens taller and narrower than
100px
only applied on screens shorter and narrower than
100px
(no conflict betweenmax-[w?:]
andmax-[h:]
)only applied on screens taller and wider than
100px
(no conflict betweenmin-[w?:]
andmin-[h:]
)Gotcha / usage note
Using
w:
is 100% optional and only exists so either dimension can be defined explicitly if the user so desires. If any prefix is used other thanh:
it defaults to usingwidth:
, though one consideration could be to throw alog.risk
orlog.warn
if any non-''
/'w:'
/'h:'
dimension prefix is used.Feedback resolution
On the previous PR for this change (#11217), @adamwathan left some feedback re what this PR might need before re-opening. Here is his feedback as well as my resolution notes:
(expand/collapse @adamwathan's feedback)
(expand/collapse my resolution notes)
width
using width naturally).min-h-[100px]
andmax-h-[100px]
, but…min-width
,max-width
,min-height
, andmax-height
utilitiesmax-*
andmax-*
) could potentially be a breaking change for some users