diff options
| author | PgBiel <9021226+PgBiel@users.noreply.github.com> | 2024-03-09 12:48:48 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-09 15:48:48 +0000 |
| commit | 639a8d0dc01171130c84903b512c200c659bc537 (patch) | |
| tree | 6aa9271588cd12a284eed1bebe4072bce5f34cd8 /tests | |
| parent | d927974bb13bac9205fd4e90192f1bf7b4b972a3 (diff) | |
Repeatable Table Footers [More Flexible Tables Pt.6a] (#3577)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/layout/grid-footers-1.png | bin | 0 -> 50791 bytes | |||
| -rw-r--r-- | tests/ref/layout/grid-footers-2.png | bin | 0 -> 52405 bytes | |||
| -rw-r--r-- | tests/ref/layout/grid-footers-3.png | bin | 0 -> 52783 bytes | |||
| -rw-r--r-- | tests/ref/layout/grid-footers-4.png | bin | 0 -> 20513 bytes | |||
| -rw-r--r-- | tests/ref/layout/grid-footers-5.png | bin | 0 -> 5769 bytes | |||
| -rw-r--r-- | tests/typ/layout/grid-footers-1.typ | 192 | ||||
| -rw-r--r-- | tests/typ/layout/grid-footers-2.typ | 31 | ||||
| -rw-r--r-- | tests/typ/layout/grid-footers-3.typ | 44 | ||||
| -rw-r--r-- | tests/typ/layout/grid-footers-4.typ | 42 | ||||
| -rw-r--r-- | tests/typ/layout/grid-footers-5.typ | 28 | ||||
| -rw-r--r-- | tests/typ/layout/grid-headers-1.typ | 8 |
11 files changed, 341 insertions, 4 deletions
diff --git a/tests/ref/layout/grid-footers-1.png b/tests/ref/layout/grid-footers-1.png Binary files differnew file mode 100644 index 00000000..331cf7ad --- /dev/null +++ b/tests/ref/layout/grid-footers-1.png diff --git a/tests/ref/layout/grid-footers-2.png b/tests/ref/layout/grid-footers-2.png Binary files differnew file mode 100644 index 00000000..60e9689c --- /dev/null +++ b/tests/ref/layout/grid-footers-2.png diff --git a/tests/ref/layout/grid-footers-3.png b/tests/ref/layout/grid-footers-3.png Binary files differnew file mode 100644 index 00000000..cc4948b8 --- /dev/null +++ b/tests/ref/layout/grid-footers-3.png diff --git a/tests/ref/layout/grid-footers-4.png b/tests/ref/layout/grid-footers-4.png Binary files differnew file mode 100644 index 00000000..29a6430b --- /dev/null +++ b/tests/ref/layout/grid-footers-4.png diff --git a/tests/ref/layout/grid-footers-5.png b/tests/ref/layout/grid-footers-5.png Binary files differnew file mode 100644 index 00000000..b58ed266 --- /dev/null +++ b/tests/ref/layout/grid-footers-5.png diff --git a/tests/typ/layout/grid-footers-1.typ b/tests/typ/layout/grid-footers-1.typ new file mode 100644 index 00000000..c7a59e60 --- /dev/null +++ b/tests/typ/layout/grid-footers-1.typ @@ -0,0 +1,192 @@ +#set page(width: auto, height: 15em) +#set text(6pt) +#set table(inset: 2pt, stroke: 0.5pt) +#table( + columns: 5, + align: center + horizon, + table.header( + table.cell(colspan: 5)[*Cool Zone*], + table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], + table.hline(start: 2, end: 3, stroke: yellow) + ), + ..range(0, 5).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten(), + table.footer( + table.hline(start: 2, end: 3, stroke: yellow), + table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], + table.cell(colspan: 5)[*Cool Zone*] + ) +) + +--- +// Gutter & no repetition +#set page(width: auto, height: 16em) +#set text(6pt) +#set table(inset: 2pt, stroke: 0.5pt) +#table( + columns: 5, + gutter: 2pt, + align: center + horizon, + table.header( + table.cell(colspan: 5)[*Cool Zone*], + table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], + table.hline(start: 2, end: 3, stroke: yellow) + ), + ..range(0, 5).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten(), + table.footer( + repeat: false, + table.hline(start: 2, end: 3, stroke: yellow), + table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], + table.cell(colspan: 5)[*Cool Zone*] + ) +) + +--- +#table( + table.header(table.cell(stroke: red)[Hello]), + table.footer(table.cell(stroke: aqua)[Bye]), +) + +--- +#table( + gutter: 3pt, + table.header(table.cell(stroke: red)[Hello]), + table.footer(table.cell(stroke: aqua)[Bye]), +) + +--- +// Footer's top stroke should win when repeated, but lose at the last page. +#set page(height: 10em) +#table( + stroke: green, + table.header(table.cell(stroke: red)[Hello]), + table.cell(stroke: yellow)[Hi], + table.cell(stroke: yellow)[Bye], + table.cell(stroke: yellow)[Ok], + table.footer[Bye], +) + +--- +// Relative lengths +#set page(height: 10em) +#table( + rows: (30%, 30%, auto), + [C], + [C], + table.footer[*A*][*B*], +) + +--- +#grid( + grid.footer(grid.cell(y: 2)[b]), + grid.cell(y: 0)[a], + grid.cell(y: 1)[c], +) + +--- +// Ensure footer properly expands +#grid( + columns: 2, + [a], [], + [b], [], + grid.cell(x: 1, y: 3, rowspan: 4)[b], + grid.cell(y: 2, rowspan: 2)[a], + grid.footer(), + grid.cell(y: 4)[d], + grid.cell(y: 5)[e], + grid.cell(y: 6)[f], +) + +--- +// Error: 2:3-2:19 footer must end at the last row +#grid( + grid.footer([a]), + [b], +) + +--- +// Error: 3:3-3:19 footer must end at the last row +#grid( + columns: 2, + grid.footer([a]), + [b], +) + +--- +// Error: 4:3-4:19 footer would conflict with a cell placed before it at column 1 row 0 +// Hint: 4:3-4:19 try reducing that cell's rowspan or moving the footer +#grid( + columns: 2, + grid.header(), + grid.footer([a]), + grid.cell(x: 1, y: 0, rowspan: 2)[a], +) + +--- +// Error: 4:3-4:19 cannot have more than one footer +#grid( + [a], + grid.footer([a]), + grid.footer([b]), +) + +--- +// Error: 3:3-3:20 cannot use `table.footer` as a grid footer; use `grid.footer` instead +#grid( + [a], + table.footer([a]), +) + +--- +// Error: 3:3-3:19 cannot use `grid.footer` as a table footer; use `table.footer` instead +#table( + [a], + grid.footer([a]), +) + +--- +// Error: 14-28 cannot place a grid footer within another footer or header +#grid.header(grid.footer[a]) + +--- +// Error: 14-29 cannot place a table footer within another footer or header +#grid.header(table.footer[a]) + +--- +// Error: 15-29 cannot place a grid footer within another footer or header +#table.header(grid.footer[a]) + +--- +// Error: 15-30 cannot place a table footer within another footer or header +#table.header(table.footer[a]) + +--- +// Error: 14-28 cannot place a grid footer within another footer or header +#grid.footer(grid.footer[a]) + +--- +// Error: 14-29 cannot place a table footer within another footer or header +#grid.footer(table.footer[a]) + +--- +// Error: 15-29 cannot place a grid footer within another footer or header +#table.footer(grid.footer[a]) + +--- +// Error: 15-30 cannot place a table footer within another footer or header +#table.footer(table.footer[a]) + +--- +// Error: 14-28 cannot place a grid header within another header or footer +#grid.footer(grid.header[a]) + +--- +// Error: 14-29 cannot place a table header within another header or footer +#grid.footer(table.header[a]) + +--- +// Error: 15-29 cannot place a grid header within another header or footer +#table.footer(grid.header[a]) + +--- +// Error: 15-30 cannot place a table header within another header or footer +#table.footer(table.header[a]) diff --git a/tests/typ/layout/grid-footers-2.typ b/tests/typ/layout/grid-footers-2.typ new file mode 100644 index 00000000..df333434 --- /dev/null +++ b/tests/typ/layout/grid-footers-2.typ @@ -0,0 +1,31 @@ +#set page(height: 17em) +#table( + rows: (auto, 2.5em, auto), + table.header[*Hello*][*World*], + block(width: 2em, height: 10em, fill: red), + table.footer[*Bye*][*World*], +) + +--- +// Rowspan sizing algorithm doesn't do the best job at non-contiguous content +// ATM. +#set page(height: 20em) + +#table( + rows: (auto, 2.5em, 2em, auto, 5em, 2em, 2.5em), + table.header[*Hello*][*World*], + table.cell(rowspan: 3, lorem(20)), + table.footer[*Ok*][*Bye*], +) + +--- +// This should look right +#set page(height: 20em) + +#table( + rows: (auto, 2.5em, 2em, auto), + gutter: 3pt, + table.header[*Hello*][*World*], + table.cell(rowspan: 3, lorem(20)), + table.footer[*Ok*][*Bye*], +) diff --git a/tests/typ/layout/grid-footers-3.typ b/tests/typ/layout/grid-footers-3.typ new file mode 100644 index 00000000..070500f1 --- /dev/null +++ b/tests/typ/layout/grid-footers-3.typ @@ -0,0 +1,44 @@ +// Test lack of space for header + text. +#set page(height: 9em + 2.5em + 1.5em) + +#table( + rows: (auto, 2.5em, auto, auto, 10em, 2.5em, auto), + gutter: 3pt, + table.header[*Hello*][*World*], + table.cell(rowspan: 3, lorem(30)), + table.footer[*Ok*][*Bye*], +) + +--- +// Orphan header prevention test +#set page(height: 13em) +#v(8em) +#grid( + columns: 3, + gutter: 5pt, + grid.header( + [*Mui*], [*A*], grid.cell(rowspan: 2, fill: orange)[*B*], + [*Header*], [*Header* #v(0.1em)], + ), + ..([Test], [Test], [Test]) * 7, + grid.footer( + [*Mui*], [*A*], grid.cell(rowspan: 2, fill: orange)[*B*], + [*Footer*], [*Footer* #v(0.1em)], + ), +) + +--- +// Empty footer should just be a repeated blank row +#set page(height: 8em) +#table( + columns: 4, + align: center + horizon, + table.header(), + ..range(0, 2).map(i => ( + [John \##i], + table.cell(stroke: green)[123], + table.cell(stroke: blue)[456], + [789] + )).flatten(), + table.footer(), +) diff --git a/tests/typ/layout/grid-footers-4.typ b/tests/typ/layout/grid-footers-4.typ new file mode 100644 index 00000000..b6d978e9 --- /dev/null +++ b/tests/typ/layout/grid-footers-4.typ @@ -0,0 +1,42 @@ +// When a footer has a rowspan with an empty row, it should be displayed +// properly +#set page(height: 14em, width: auto) + +#let count = counter("g") +#table( + rows: (auto, 2em, auto, auto), + table.header( + [eeec], + table.cell(rowspan: 2, count.step() + count.display()), + ), + [d], + block(width: 5em, fill: yellow, lorem(7)), + [d], + table.footer( + [eeec], + table.cell(rowspan: 2, count.step() + count.display()), + ) +) +#count.display() + +--- +// Nested table with footer should repeat both footers +#set page(height: 10em, width: auto) +#table( + table( + [a\ b\ c\ d], + table.footer[b], + ), + table.footer[a], +) + +--- +#set page(height: 12em, width: auto) +#table( + [a\ b\ c\ d], + table.footer(table( + [c], + [d], + table.footer[b], + )) +) diff --git a/tests/typ/layout/grid-footers-5.typ b/tests/typ/layout/grid-footers-5.typ new file mode 100644 index 00000000..db2489fd --- /dev/null +++ b/tests/typ/layout/grid-footers-5.typ @@ -0,0 +1,28 @@ +// General footer-only tests +#set page(height: 9em) +#table( + columns: 2, + [a], [], + [b], [], + [c], [], + [d], [], + [e], [], + table.footer( + [*Ok*], table.cell(rowspan: 2)[test], + [*Thanks*] + ) +) + +--- +#set page(height: 5em) +#table( + table.footer[a][b][c] +) + +--- +#table(table.footer[a][b][c]) + +#table( + gutter: 3pt, + table.footer[a][b][c] +) diff --git a/tests/typ/layout/grid-headers-1.typ b/tests/typ/layout/grid-headers-1.typ index f1afe70e..ac998029 100644 --- a/tests/typ/layout/grid-headers-1.typ +++ b/tests/typ/layout/grid-headers-1.typ @@ -146,17 +146,17 @@ ) --- -// Error: 14-28 cannot place a grid header within another header +// Error: 14-28 cannot place a grid header within another header or footer #grid.header(grid.header[a]) --- -// Error: 14-29 cannot place a table header within another header +// Error: 14-29 cannot place a table header within another header or footer #grid.header(table.header[a]) --- -// Error: 15-29 cannot place a grid header within another header +// Error: 15-29 cannot place a grid header within another header or footer #table.header(grid.header[a]) --- -// Error: 15-30 cannot place a table header within another header +// Error: 15-30 cannot place a table header within another header or footer #table.header(table.header[a]) |
