-
Notifications
You must be signed in to change notification settings - Fork 703
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-grid] Shortcut syntax for repeat(M, 1fr) #2270
Comments
I'm not sure why we should prefer 1fr over the other options here. |
Also I think this is very confusing because 0 is a valid length |
...which are?
Not sure what you mean? |
I just don't think that In other words, creating a shortcut to easily repeat a fixed number of More fundamentally, I don't think we want to get an
|
You don't think that "N equal sized rows/columns" is more common than other things?
I've been at this long enough to know not to suggest things that just fit my one particular case. I suggested this after stumbling on use cases that involved that several times, over the several months since I started using grid. In fact, every grid I've ever defined involved this in at least one direction.
That’s actually a good argument. I wonder if we can define it as |
I don't think so. I'm also concerned it would further lead people to believe that N fr == N equal sized, which isn't the case, it's really |
Also the default size for a track is |
@LeaVerou based on the comments here, would you like to retract (close) the issue or raise it to the WG? |
It can repeat whatever you think would be most useful, |
That does not actually answer the question that I asked, but I'll interpret it as “please Agenda+”... |
I'm in favour of @LeaVerou I'm particularly interested in a shorter method of writing the There was another issue where people wanted I don't like the idea of it being a unitless value though. I'm thinking a This is what I'm thinking: |
You seem to be a bit out of touch with how content authors use css grid. The most common use case for us content authors above all else is X number of equally sized columns. That makes |
THIS. Any design system I've seen starts from many equally sized columns and then elements can span 2 or more, but the grid itself is equal sized columns. Not to mention things like game boards etc. |
There's a fairly fundamental grammar conflict here, tho. Having |
That's partly why I'm suggesting there be a |
Oh, so, what you want is not I still don't think using integers directly is nice idea inside Still, this syntax prohibits you from using most of the useful grids features like named lines. Maybe that part is just me but I always build my fixed grids in such a way that they have grid { grid-template-rows: [start] repeat(2, repeat(2, repeat(3, minmax(0,1fr) [small]) [medium]) [large] [half]) [end]; }
.small { grid-column-end: span small; }
.medium { grid-column-end: span medium }
.large { grid-column-end: span large }
.half { grid-column-end: span half }
.full { grid-column-start: start; grid-column-end: end; } Then I can use a different layout on tablets where I only have 6 columns: grid { grid-template-rows: [start] repeat(2, repeat(3, minmax(0,1fr) [small]) [medium] [half]) [large] [end]; } But I can conceive there are probably use cases where you just know what you want and you don't need to be responsive like this. Just wanted to say so that people don't read too much into my first comments, I don't feel as strongly now that I have seen more use cases. |
I really like the idea of having a quick "create this many equal columns" unit. You can do stuff like this then: grid-template-columns: 20px 12rep 20px; Which would be the equivalent of writing this: grid-template-columns: 20px repeat(12, minmax(0, 1fr)) 20px; or maybe do something like this: grid-template-columns: 20px 3rep 100px 3rep 20px; Equivalent to this: grid-template-columns: 20px repeat(3, minmax(0, 1fr)) 100px repeat(3, minmax(0, 1fr)) 20px; You can still name the lines before and after the repeated columns: grid-template-columns: 20px [left-start] 3rep [left-end] 100px [right-start] 3rep [right-end] 20px; Translation: grid-template-columns: 20px [left-start] repeat(3, minmax(0, 1fr)) [left-end] 100px [right-start] repeat(3, minmax(0, 1fr)) [right-end] 20px; Or maybe grid-template-columns: 20px 12cols 20px;
grid-template-rows: 12rows; Translation: grid-template-columns: 20px repeat(12, minmax(0,1fr)) 20px;
grid-template-rows: repeat(12, minmax(0,1fr)); (I'm not actually a fan of the bootstrap approach to grid systems but it's a good use case for this) |
If this was implemented though I'm positive that there would be many people who would start abusing They might start using it like this grid-template-columns: 100px 1rep 1rep 20px; Which is like saying grid-template-columns: 100px repeat(1, minmax(0,1fr)) repeat(1, minmax(0,1fr)) 20px; And then get confused why this ends up creating an extra column grid-template-columns: 100px 1rep 2rep 20px; Or get confused why 1.5 wouldn't work /* invalid, you can't repeat something 1.5 times */
grid-template-columns: 100px 1rep 1.5rep 20px; I'm thinking that a new unit should also be created for
grid-template-columns: repeat(3, 1efr); Translated: grid-template-columns: repeat(3, minmax(0,1fr)); |
Maybe a short-named functional notation (e.g. |
I like the idea of a function actually instead of a unit. Units look too much like a single column/row. Since we want a column generated this way to equal I think I would prefer this:
|
If
then we can also have the
|
If there was an obvious “best choice” for how to size those tracks @tabatkins and I think it would be fine to make the second argument of repeat() optional (so you could just say Note, part of the problem with verbosity here is stemming from problems with |
@fantasai what is the issue you see with introducing a new unit like The reason we tend to want easy access to Maybe we want content to scroll. Maybe we want content to break long words and wrap them. What we generally don't want is for the grid to get forced out of it's original container or cause a major change to the signed off design. The If someone posts a long link in a basic 3 column layout, we don't want the column with the long link to squish the other 2 columns. We want the link text to wrap onto the next line. |
@fantasai I like the idea of fixing If fixing |
Sorry, wrong issue reference - I meant #1865 which covers |
The Working Group just discussed
The full IRC log of that discussion<dael> Topic: Shortcut syntax for repeat(M, 1fr)<dael> github: https://github.com//issues/2270 <dael> leaverou: I found that I was using grid template columns and rows numbered by accident and realized that not how you make equal columns and I was wondering if we can add shortcut syntax so the error becomes correct b/c I suspect other people would write this. <dael> leaverou: TabAtkins raised point that because we allow unitless lengths grid-template:0 has a meaning. It doesn't mean it's not possible, but it's confusing in that case. <dael> leaverou: People have discussed a new unit, I don't remember names, but people discussed units or functions like efr. I'm not a huge fan because I wanted to prevent this error and other syntax would g et people to make errors. but I guess a shortcut for this is still a net gain <dael> fantasai: My main concerns where that there's lots of sizing functions you can have and I'm not sure fr is what you always want <dael> leaverou: My point was a shortcut to spec equal width columns. It can be a shortcut to whatever you think ti should be. You know grid better then me <dael> TabAtkins: The point isn't one better, but it's that there isn't a single obvious choice. It's hard to justify one with a belssing of a shorthand <dael> jensimmons: I'd hesitate to put a thumb on the scale for which syntax should be used by giving one approach a special short hand. I feel industry needs a couple years to come up with a bazillion ways to do things. <dael> astearns: I wonder if we should let it sit, see if preprocessors come up with a shorthand of their own we can adopt <dael> rachelandrew: Agree. I d on't see huge confusion. I see people that love shorthands, but I don't see this as a mistake. I see a lot of not working grid and thishasn't come up. <dael> jensimmons: I see people trying to systematize and it's early for that. Theyd ont' understand power of grid and what a fr is. I think there's a long way to go before we create a system of shortcut. <dael> astearns: Is there anything we can do about the mistake case? <dael> fantasai: I think we leave ass invalid. We could revisit a shorthand in the future but I think for now it's not the right time. <fantasai> https://github.com//issues/1865 <dael> fantasai: Related: one frustration raised in thread is w ay fr units are calc and people are frustrated you can't use direct because auto min is often wrong. We need to fix those cases. They have to set a 0 min. That's #1865. We need to do something about it. <chris> s/ass/as <dael> astearns: leaverou are you okay closing this for now and taking someof this over to 1865? <dael> leaverou: Yep, fine. I was fine since TabAtkins pointed out grammar inconsistancy. <dael> astearns: We'll leave it there and not do anything for hte moment. We'll see what people do with fr and make shorthands <dael> RESOLVED: Close this issue, won't fix. |
Try this in chrome :D |
...sigh. Mind filing a bug? |
I guess this is just an overzealous implementation of https://simon.html5.org/specs/quirks-mode#the-unitless-length-quirk |
I’ve noticed myself often defining grids where all I want is a bunch of equally sized rows, columns, or both. I.e. things like:
or in one direction:
Look at the first syntax. Isn't that a bit clunky, just to say that I want a M×N grid?
Wouldn’t it be much more elegant to be able to say:
And AFAIK
<integer>
has no meaning ingrid-template
right now, so the syntax is up for grabs and can be combined with other units as necessary, e.g.Though admittedly, when combined with other units, its meaning is not as obvious as when used by itself.
The text was updated successfully, but these errors were encountered: