-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[0.2] Combine sides and sizes for rounded utilities, like we do with border widths #188
Conversation
I think I'd actually prefer this: <div class="rounded-tr-lg rounded-tl-lg"></div> Yes, it's longer than just using As for the |
I like the rounded-disabled better. The class rounded-off sounds like you are rounding something, which is the opposite of what the class is trying to invoke. Kinda like rounding-off numbers. Anyways, I love the fact that you guys are discussing ideas here between each other, feels more open to the community 😄 |
Part of me wants to rename this utility altogether to just But I do really like If we did switch that name, I'm not sure what I'd want the default scale to be either.
Or:
...or who knows what else. Tough. |
If I may provide an outside opinion for consideration, perhaps it helps when thinking about naming css classes (and perhaps not). :) When naming classes, I think it is important to keep the naming to convey meaning and describe what the element looks like after it is applied. Focussing on the specific CSS property the rule pertains to seems to steer the "discussion" back to the technical side of things. The class names become adjectives of the element they are applied to. This is in-line with most of the other naming conventions in Tailwind, like the colors, etc. Because of that, I think |
[0.2] Rework `rounded` utilities to `radius`, add ability to target corners
7c0bcf3
to
d4f7b3b
Compare
Use vh rather than vw units in custom config example
Closes #204
This PR reverts an API design decision that was made just prior to 0.1.0 back to how it used to be in the secret days.
It combines rounded sides and sizes into one utility, like this:
Right now, to make only one side of an element round, you need to combine a size utility and a side utility:
This had the benefit of not repeating the size utilities for every side, which seemed like a win.
There's a few downsides that ultimately I don't think ended up being worth it though:
You have to combine two utilities for something that's actually done with one CSS property; that seems a bit weird.
The implementation is too "clever". The way it works is when you add
rounded-t
, it sets the bottom border radiuses back to 0. I don't like that a class designed to say "make the top corners round" actually just makes the bottom corners square. It should be simpler and more obvious.You can't make 3 out of 4 corners rounded because of the implementation in point Update defaultConfig.js #2.
The implementation mentioned in point Update defaultConfig.js #2 leads to this annoying situation where if you want to change what side is rounded at a different breakpoint, you have to respecify the size.
For example, this won't work as you expect:
You'd think that would have top rounded corners by default, and left rounded corners on medium screens and up. But what actually happens, is that on medium screens and up, only the top left corner is rounded, because
rounded-t
sets bottom radiuses to 0 androunded-l
sets right radiuses to 0. Grim!So currently you need to do this:
With the changes in this PR, sides and sizes are combined into the same utility like they are with border widths. So the example above would be written like this:
...which is a lot more like how you'd write similar border width code.
You can also now have two sides with different border radiuses if you really desire:
This approach comes with the downside that the filesize is now a bit bigger because there are more utilities, but I think the added flexibility, increased consistency, and more obvious implementation is worth it.
Breaking Changes
This is a breaking change so it wouldn't land until 0.2.0.
Breaks include:
Border radius size utilities now no longer affect the radius of individually specified sides, ie:
...would have normal sized rounded top corners, not large.
Instead, you'd write that like this now:
The
borderRadius
section of the default config file has changed slighty, movingnone
to the top of the modifiers list so you can more easily use it to reset border radius at a breakpoint while still overriding one of those corners with another size. End users would need to update their config files to match this for their experience to match what's in the documentation.Questions
I have two things I'm still considering that I'd be interested in input on:
Right now we target sides like top, left, bottom, or right. That's not really how it works in CSS; instead in CSS you target top-left, top-right, bottom-right, or bottom-left.
Our current utilities try to serve as a useful abstraction on top of this but it can make it really tricky to get things right when you're trying to round 3 corners or 1 corner.
For example, this is the only way to round just the bottom right corner:
That seems pretty lame to me vs. something like this:
In general I think rounding a pair of corners is probably still the most common use case though, so I'm inclined to keep it the way it is. I don't think I'd like to add all 4 sides and all 4 corners, because the CSS bloat would be significant.
Would the developer experience be significantly worse if you had to write this to make the top of an element rounded?
I feel like it's probably worse, but it's definitely the most powerful approach :/ Open to discussion on that.
I think I hate our default
none
modifier, and I think I'd like to change it to0
by default, even though we use a named scale for the other sizes.Is this scale weird, or is it fine?
To Do Before Merging