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

Add table.cell(fit: Axes<bool>) parameter #4000

Open
PgBiel opened this issue Apr 24, 2024 · 4 comments
Open

Add table.cell(fit: Axes<bool>) parameter #4000

PgBiel opened this issue Apr 24, 2024 · 4 comments
Labels
feature request New feature or request layout Related to layout, positioning, etc.

Comments

@PgBiel
Copy link
Contributor

PgBiel commented Apr 24, 2024

Description

Related: #3001

A cell with fit: true would not cause auto tracks it is in to expand. For example, it could request more height for an auto row, but it wouldn't be given that height.

Importantly, this changes layout() inside that cell to return the final height of the auto row instead of +inf, for example (i.e. 100% would correspond to the final height of the auto row for height, and final width of the auto column for width).

Ideally we'd allow configuring this per axis. For example, fit: (true, false) would make sure an auto column would ignore the cell's width, but the auto row would consider its height.

Use Case

This would appeal to the common use case of having content with the same height or width as some other content. For example, you'd write

#grid(
  columns: 2,
  grid.cell(fit: true, rect(width: 2em, height: 100%, fill: red)[*Hello!*]),
  lorem(400)
)

and you'd get a red block with the same height as the lorem(400) next to it, regardless of how much height it has, thus not requiring a call to measure.

This is, however, mostly a (positive and useful) side effect of the more general purpose of this feature, which is to provide more fine-grained control over how cells affect track sizes in the table / grid.

@PgBiel PgBiel added the feature request New feature or request label Apr 24, 2024
@PgBiel PgBiel changed the title Add table.cell(fit: bool) parameter Add table.cell(fit: Axes<bool>) parameter Apr 24, 2024
@laurmaedje
Copy link
Member

I'm not sure fit is a very clear name for this. Maybe something like grow or expand would be clearer?

@laurmaedje laurmaedje added the layout Related to layout, positioning, etc. label Apr 29, 2024
@maxcrees
Copy link

Agree. Or maybe it can be inverted and called clip to match other functions? I suppose the semantics wouldn't be exactly the same but the spirit would be.

@PgBiel
Copy link
Contributor Author

PgBiel commented Apr 30, 2024

I'm not sure fit is a very clear name for this. Maybe something like grow or expand would be clearer?

The idea was that the cell would fit into the auto tracks, but I can see how it can be confusing.

expand sounds OK to me.

Or maybe it can be inverted and called clip to match other functions?

That wouldn't be consistent, as the cell's contents could still overflow. They just would have a fixed amount of space available.

@laurmaedje
Copy link
Member

My main concern with expand is that the terminology is confusing with the internal terminology. IIUC expand: true in Typst would lead to expand: false in the regions.

  • Internally, expand means: Fit exactly this space
  • Here, expand would mean: You can grow on your own, independent of peer cells

So maybe grow or growable or something else would be better. Not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request layout Related to layout, positioning, etc.
Projects
None yet
Development

No branches or pull requests

3 participants