-
Notifications
You must be signed in to change notification settings - Fork 715
[css-grid] Allow naming grid rows and columns and allow a grid item to span named grid areas/rows/columns... #4892
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
Comments
This syntax already exists, and means something else. It expands to grid-row: B2 / B2;
grid-column: C4 / C4; that is, it refers to the B4 area. Changing the meaning could break sites, and wouldn't add much benefit since you can already achieve your desired behavior with grid-area: B2 / B2 / C4 / C4; which means grid-row: B2 / C4;
grid-column: B2 / C4; |
Well, that's already kind of possible, you just need to specify grid-template-columns: [
\31\.1-start] 1fr [\31\.1-end
\31\.2-start] 1fr [\31\.2-end
\31\.3-start] 1fr [\31\.3-end
\31\.4-start] 1fr [\31\.4-end
\31\.1-start] 1fr [\31\.1-end
\32\.2-start] 1fr [\32\.2-end
\32\.3-start] 1fr [\32\.3-end
\32\.4-start] 1fr [\32\.4-end];
grid-template-rows: [
D\#\/Eb1-start] 1fr [D\#\/Eb1-end
D1-start] 1fr [D1-end
C\#\/Db1-start] 1fr [C\#\/Db1-end
C1-start] 1fr [C1-end]; And then grid-row: C1;
grid-column: \31\.1 / \31\.3; |
Rather than escaping numbers, the obvious thing would just swap those an ident ^_^ But yeah, between using |
I don't understand how your example works, but it seems to work for me...hard to understand for me, personally, however. I associate the maybe something like this for spanning multiple grid-areas? grid-area: B2 - C4; ...as writing everything twice feels rather odd and unintuitive, at least to me. But also it makes sense that I am specifying using the As for your second example showing how to name grid rows and columns, I must admit that I don't follow it at all. Are there any resources that explain this in more detail? |
If grid-area: B2 / C4;
/* equivalent to */
grid-row-start: B2;
grid-row-end: B2;
grid-column-start: C4;
grid-column-end: C4; grid-area: B2 / B2 / C4 / C4;
/* equivalent to */
grid-row-start: B2;
grid-row-end: C4;
grid-column-start: B2;
grid-column-end: C4;
You need to write it twice because there are 2 axes.
These are the relevant sections in the spec: |
trying to read through the doc, but I'm having a hard time understanding this: \31\.1-start] 1fr [\31\.1-end what is the Could I write it like this? grid-template-columns:
[1_1-start] 1fr [1_1-end]
[1_2-start] 1fr [1_2-end]
; ...for each line? Is there anything about that that wouldn't work? |
It escapes the value so that it becomes a valid
Because the character
The brackets are there. I just inserted a newline inside
No, a But you could do this: grid-template-columns: [_1_1-start] 1fr [_1_1-end _1_2-start] 1fr [_1_2-end]; |
hmmm...but what is sooo...maybe I'm starting to get the idea of how this naming system works, albeit very bizarre and convoluted, at least to me...so maybe like this?: grid-template-columns:
[
_1_1-start] 1fr [_1_1-end
_1_2-start] 1fr [_1_2-end
_1_3-start] 1fr [_1_3-end
.........moar uv dem.........
_2_4-start] 1fr [_2_4-end
];
grid-template-rows: [
D\#\/Eb1-start] 1fr [D\#\/Eb1-end
D1-start] 1fr [D1-end
C\#\/Db1-start] 1fr [C\#\/Db1-end
C1-start] 1fr [C1-end]; ...but ideally, I would want the API of a note definition to look like this for the end user of the component: <Note name='C#1' start='1.2' length='1/4' velocity='95' offset='+24' /> ...so how could I go about transforming this monstrosity: |
That's the code that represents the digit zero in Unicode, https://unicode.org/cldr/utility/character.jsp?a=0030
You don't. You transform your API-exposed Though it would be easier to use Also, it seems that with grid-template-rows: [C♯1-start D♭1-start] 1fr [C♯1-end D♭1-end] |
Oriol was using the exact names you used, and had to use escapes to write them; in reality you'd just change the way you write them so that they're a valid ident to start with, as I did in my previous comment ( The line names have to be CSS idents, which have some basic rules about how they can be written; the big one is that they must start with a letter, underscore, or dash (or a non-ASCII character); in particularly, if a value starts with an ASCII digit, it's instead parsed as a CSS number or dimension. If you do, for whatever reason, need to start an ident with a digit or other disallowed character, you can do so by escaping it, as Oriol did, by giving its unicode codepoint in hexadecimal. As he said, the digit "0" has codepoint U+0030, so you can write it in CSS as |
I would love to be able to place a grid item across multiple named grid areas, and to also name grid-rows and columns and place items across multiple ones of those as well.
It would be really nice to be able to name grid-areas, like so:
...then I could place an item like so:
...and this would place the item in B2, B3, B4 and also C2, C3 and C4.
This would be amazing for building something like a musical note sequencer where one could define a
midi note name
andmusical timing
grid like so:...and then place a note across multiple named grid areas. like so:
Or better yet, simple name rows and columns, like so:
...then one could place an item using both and spanning multiple of each one, like so:
...or something along those lines. This could be really nice for these kinds of use-cases where one wants to place an item on an intricate grid in a very precise way without having to count every line and make sure the lines are right. I could imagine a scenario where the grid has hundreds of columns and over a hundred rows...I really don't want to have to figure out where:
...is on that grid! ahhhh!
Anyway, just dropping these questions/ideas off for now...will come back and work on them more later if the general concept is well received :-)
Thank you! XD
The text was updated successfully, but these errors were encountered: