Skip to content

Commit 0ab6fa5

Browse files
committed
better default height
1 parent 37075d3 commit 0ab6fa5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/TableView.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,21 @@ end
1818
to_css_size(s::AbstractString) = s
1919
to_css_size(s::Real) = "$(s)px"
2020

21-
function showtable(table; dark = false, height = 500, width = "100%")
21+
function showtable(table; dark = false, height = :auto, width = "100%")
2222
if !Tables.istable(typeof(table))
2323
throw(ArgumentError("Argument is not a table."))
2424
end
2525

2626
tablelength = Base.IteratorSize(table) == Base.HasLength() ? length(Tables.rows(table)) : nothing
2727

28+
if height === :auto
29+
height = 500
30+
if tablelength !== nothing
31+
# header + footer height ≈ 40px, 28px per row
32+
height = min(40 + tablelength*28, height)
33+
end
34+
end
35+
2836
rows = Tables.rows(table)
2937
schema = Tables.schema(table)
3038
if schema === nothing

0 commit comments

Comments
 (0)