Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
greimel committed Sep 18, 2024
1 parent 1a00a9a commit c65f6e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ You can customize the widths of the columns.
"""

# ╔═╡ 0e1e62a6-3b78-4415-89fe-fa17279fddbf
Columns(md"Left col", md"Right col", widths = [1/3, 2/3])
Columns(md"Left col", md"Right col", widths=[1 / 3, 2 / 3])

# ╔═╡ f43beea9-7a7e-4ee6-8ae6-350640c426aa
TwoColumnWideRight(md"Left col", md"Right col")
Expand Down
25 changes: 12 additions & 13 deletions src/present.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,37 @@ function Base.show(io, mime::MIME"text/html", fld::Foldable)
return nothing
end

function Columns(cols...; widths=nothing, gap = 2)
function Columns(cols...; widths=nothing, gap=2)
ncols = length(cols)
ngaps = ncols - 1
if isnothing(widths)
widths = fill(100/ncols, ncols)
widths = fill(100 / ncols, ncols)
end
if gap > 0 # adjust widths if gaps are desired
widths = widths / sum(widths) * (100 - gap*ngaps)
widths = widths / sum(widths) * (100 - gap * ngaps)
end

columns = [
DivElement(children=[cols[i]], style="display: flex; flex: 0 1 $(widths[i])%") for i 1:ncols
DivElement(; children=[cols[i]], style="display: flex; flex: 0 1 $(widths[i])%") for
i in 1:ncols
]
the_gap = DivElement(children = [], style="display: flex; flex: 0 0 $gap%" )
the_gap = DivElement(; children=[], style="display: flex; flex: 0 0 $gap%")

# insert gaps between columns
# i.e. [a, b, c] ==> [a, gap, b, gap, c]
children = vec([reshape(columns, 1, :); fill(the_gap, 1, ncols)])[1:end-1]

DivElement(; children,
style="display: flex; flex-direction: row;"
)
children = vec([reshape(columns, 1, :); fill(the_gap, 1, ncols)])[1:(end - 1)]

return DivElement(; children, style="display: flex; flex-direction: row;")
end

# for backwards compatibility
TwoColumn(a, b; kwargs...) = Columns(a, b; kwargs...)

ThreeColumn(a, b, c; kwargs...) = Columns(a, b, c; kwargs...)

TwoColumnWideLeft(a, b; kwargs...) = Columns(a, b; widths = [66, 34], kwargs...)
TwoColumnWideLeft(a, b; kwargs...) = Columns(a, b; widths=[66, 34], kwargs...)

TwoColumnWideRight(a, b; kwargs...) = Columns(a, b; widths = [34, 66], kwargs...)
TwoColumnWideRight(a, b; kwargs...) = Columns(a, b; widths=[34, 66], kwargs...)

""" Provides checkbox to toggle full width and present mode. """
function ChooseDisplayMode(;
Expand Down

0 comments on commit c65f6e8

Please sign in to comment.