Skip to content

Resolve further fields in grid and table show rules #3697

@PgBiel

Description

@PgBiel

Description

It could be interesting to be able to access more info when applying show rules on tables. In particular, rows and children, in show rules, have (almost) the same values received by the #table call, when in reality those fields are changed during grid / table layout (more rows are needed depending on the cells). Similarly, at least row-gutter isn't the final array of gutter spacing.

In other words,

#show table: it => {
  
  show table.cell: it => it.fields()
  [Rows: #it.rows, #it]
}

#table(
  columns: 2,
  [a], [b],
  [c], [d],
  table.cell(stroke: red, y: 3)[e]
)

Displays rows: () when it would be more useful to display something like (auto, auto, auto), so we can know the actual amount of rows in the table. (Resolving auto to final lengths could be a bit out of scope at first, especially because auto rows behave very distinctly from fixed-size rows, so we should refrain from doing that initially.)

I think resolving it.children is debatable at first, because, while it would be nice to have access to each cell's resolved fields, a cell's stroke being specified or not does change its priority, for example. But if we assume that resolving that field doesn't affect the table's layout, then maybe it isn't that much of a problem. The larger problem could be possible performance concerns in converting every single Vec<Entry> to Array<TableCell> for example.

But, in principle, having at least it.rows have the same amount of rows that is actually displayed in the table would be helpful.

Use Case

Allows you to use the table's final layout to your advantage in show rules:

#show table: it => {
   show table.cell.where(y: it.rows.len() - 1): strong
   it
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requeststylingAbout set and show rules or style properties

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions