Skip to content
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] Dimensions unclear when clamping content-based minimum size #3573

Closed
Loirooriol opened this issue Jan 30, 2019 · 5 comments
Closed

Comments

@Loirooriol
Copy link
Contributor

From https://drafts.csswg.org/css-grid/#content-based-minimum-size,

if the grid item spans only grid tracks that have a fixed max track sizing function, its specified size suggestion and content size suggestion in that dimension (and the input to the transferred size suggestion in the other dimension) are further clamped to less than or equal to the stretch fit the grid area’s size

The other dimension is mixed in between, so it's not much clear

  • whether "the grid item spans only grid tracks that have a fixed max track sizing function" refers to both dimensions, the given dimension, or the given dimension when clamping the specified and content size suggestions but the other dimension for the transferred size suggestion.
  • to which dimension the "stretch fit the grid area’s size" refers.
  • whether the limit should be converted through the aspect ratio when it's in the other dimension.

I would just keep it simple and check track sizing functions only in the given dimension, clamp in the given dimension, to the size in the given dimension.

@fantasai
Copy link
Collaborator

I would just keep it simple and check track sizing functions only in the given dimension, clamp in the given dimension, to the size in the given dimension.

Yes, that's the intention.

@fantasai
Copy link
Collaborator

Oops. forgot the --amend, I guess the second commit should have been "update DoC".

Anyway. I added some words, lmk if it's acceptable. :)

@Loirooriol
Copy link
Contributor Author

I don't think it's clear either.

The content-based minimum size for a grid item in a given dimension is [...]. if in a given dimension

Are these dimensions the same, or independent?

and its input to the transferred size suggestion in the opposite dimension

So if I have an item with min-width: auto in a column sized with 100px, it has an aspect ratio of 3:1 and height: 50px, then this seems to mean it should clamp the input (i.e. the height 50px) by the max column size 100px, which is still 50px, then convert it through the aspect ratio, which is 150px, and this overflows the column.

So I don't get why bother with opposite dimensions, if this is trying to prevent overflow why not just calculate (without clamping the input) the transferred size suggestion, i.e. 150px, and then clamp by 100px? Like

However, to prevent the content-based minimum size from forcing overflow of its fixed-size grid area, if in the given dimension the grid item spans only grid tracks that have a fixed max track sizing function, then the content-based minimum size is clamped to less than or equal to the stretch fit into the grid area’s maximum size in that dimension

@fantasai
Copy link
Collaborator

fantasai commented Feb 1, 2019

Are these dimensions the same, or independent?

It doesn't matter? Afaict whichever way you want to interpret it, the paragraph means the same thing...

So if I have an item with min-width: auto in a column sized with 100px, it has an aspect ratio of 3:1 and height: 50px, then this seems to mean it should clamp the input (i.e. the height 50px) by the max column size 100px, which is still 50px, then convert it through the aspect ratio, which is 150px, and this overflows the column.

No, it would clamp the input from the current dimension into the transferred size of the opposite dimension. See #767

@Loirooriol
Copy link
Contributor Author

OK, I get it now, thanks. In

its input to the transferred size suggestion in the opposite dimension

my understanding was that the thing "in the opposite dimension" was the "input", not the "transferred size suggestion", which didn't make much sense.

It would be clearer if the spec used the wording from your comment, i.e.

its input from the current dimension to the transferred size suggestion of the opposite dimension

Or even better refactor the whole thing like

The foobar of a grid item in a given dimension is, if it spans only grid tracks that have a fixed max track sizing function, the stretch fit into the sum of those grid tracks’ max track sizing functions plus any intervening fixed gutters. Otherwise, it's infinite.

  • specified size suggestion
    If the item’s computed preferred size property in the relevant axis is definite, then the specified size suggestion is that size, clamped by the relevant max size property if it’s definite, and further clamped by the foobar of the grid item in that axis.
  • transferred size suggestion
    If the item has an intrinsic aspect ratio and its computed preferred size property in the opposite axis is definite, then the transferred size suggestion is that size, clamped by the opposite-axis min and max size properties if they are definite, further clamped by the foobar of the grid item in the opposite axis, converted through the aspect ratio and finally clamped by the same-axis max size property if it’s definite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants