Skip to content

Commit

Permalink
take header and footer arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrswift committed Jul 18, 2024
1 parent 974ff5d commit 01186f1
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# [v0.1.1](https://github.com/JamesxX/dining-table/releases/tags/v0.1.1)
## Added
- `.make(..args)` now takes `header` (none, auto, array) and `footer` (none, array) as arguments

## Removed

Expand Down
27 changes: 21 additions & 6 deletions src/impl.typ
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@
#let make(
columns: (),
data: (),
header: auto,
footer: none,
hline: none,
toprule: toprule,
midrule: midrule,
Expand Down Expand Up @@ -171,11 +173,18 @@
columns: query-result.map(
it=>{if it.width.value != none {it.width.value} else {auto}}
),
table.header(
table.hline(stroke: toprule),
..build-header(columns, max-depth: max-depth),
table.hline(stroke: midrule, y: max-depth),
),
..(if header != none {
(table.hline(stroke: toprule, y:0),)
(table.header(
..if header == auto{
build-header(columns, max-depth: max-depth)
(table.hline(stroke: midrule, y: max-depth),)
} else {
header
(table.hline(stroke: midrule),)
}
),)
} else {(table.hline(stroke: toprule, y:0),)}),
..args,
..(
for entry in data{
Expand All @@ -187,7 +196,13 @@
if hline != none {(hline,)}
}
),
table.hline(stroke: bottomrule)
if footer == none {table.hline(stroke: bottomrule)} else {
table.footer(
table.hline(stroke: midrule),
..footer,
table.hline(stroke: bottomrule)
)
}
) + if (notes != none) {note.display-style(notes)} // ADDED

}
Expand Down
Binary file added tests/topdown/footer/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/topdown/footer/ref/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/topdown/footer/ref/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/topdown/footer/ref/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions tests/topdown/footer/test.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#import "../ledger.typ": *
#set text(size: 11pt)
#set page(height: 5cm, margin: 1em)
#dining-table.make(columns: example,
footer: none,
data: data,
notes: dining-table.note.display-list
)

#v(0.5cm)

#dining-table.make(columns: example,
footer: (
table.cell(
colspan: 3, fill: none,
align(right, strong(smallcaps[total])),
),
[#{7*100}],[00],
[#{7*99}],[00]
),
data: data,
notes: dining-table.note.display-list
)
Binary file added tests/topdown/header-none/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/topdown/header-none/ref/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/topdown/header-none/ref/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/topdown/header-none/ref/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/topdown/header-none/ref/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/topdown/header-none/ref/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions tests/topdown/header-none/test.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import "../ledger.typ": *
#set text(size: 11pt)
#set page(height: 3.5cm, margin: 1em)
#dining-table.make(columns: example,
header: none,
data: data,
notes: dining-table.note.display-list
)

#dining-table.make(columns: example,
data: data,
notes: dining-table.note.display-list
)

0 comments on commit 01186f1

Please sign in to comment.