Skip to content

Commit

Permalink
minor fixes, add tests for flexgrid kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Sep 14, 2023
1 parent b2b4f93 commit 139e513
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Layout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function row(args...;
# for backward compatibility with `size` kwarg
col == -1 && size != -1 && (col = size)

class = class isa Symbol ? Symbol("$class + ' row'") : join(pushfirst!(split(class), "row"), " ")
class = class isa Symbol ? Symbol("$class + ' row'") : join(push!(split(class), "row"), " ")
kwargs = flexgrid_kwargs(; class, col, xs, sm, md, lg, xl, symbol_class = false, kwargs...)

Genie.Renderer.Html.div(args...; kwargs...)
Expand Down Expand Up @@ -199,7 +199,7 @@ function column(args...;
# for backward compatibility with `size` kwarg
col == -1 && size != -1 && (col = size)

class = class isa Symbol ? Symbol("$class + ' column'") : join(pushfirst!(split(class), "st-col"), " ")
class = class isa Symbol ? Symbol("$class + ' column'") : join(push!(split(class), "column"), " ")
kwargs = flexgrid_kwargs(; class, col, xs, sm, md, lg, xl, symbol_class = false, kwargs...)

Genie.Renderer.Html.div(args...; kwargs...)
Expand Down Expand Up @@ -242,7 +242,7 @@ function cell(args...;
# for backward compatibility with `size` kwarg
col == 0 && size != 0 && (col = size)

class = class isa Symbol ? Symbol("$class + ' st-col'") : join(pushfirst!(split(class), "st-col"), " ")
class = class isa Symbol ? Symbol("$class + ' st-col'") : join(push!(split(class), "st-col"), " ")
kwargs = flexgrid_kwargs(; class, col, xs, sm, md, lg, xl, symbol_class = false, kwargs...)

Genie.Renderer.Html.div(args...; kwargs...)
Expand Down
43 changes: 43 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,47 @@ end

@clear_cache MyApp
down()
end

# attribute testing

@testset "Flexgrid attributes for row(), column(), and cell()" begin

el = column(col = 2, sm = 9, class = "myclass")
@test contains(el, "class=\"myclass column col-2 col-sm-9")

el = column(col = 2, sm = 9, class = :myclass)
@test contains(el, r":class=\"myclass \+ .*column.* col-2 col-sm-9'")

el = column(col = 2, sm = 9, class! = "myclass")
@test contains(el, r":class=\"myclass \+ .*column.* col-2 col-sm-9'")

el = column(col = 2, sm = 9, class! = :myclass)
@test contains(el, r":class=\"myclass \+ .*column.* col-2 col-sm-9'")

# ---------

el = row(col = 2, sm = 9, class = "myclass")
@test contains(el, "class=\"myclass row col-2 col-sm-9")

el = row(col = 2, sm = 9, class = :myclass)
@test contains(el, r":class=\"myclass \+ .*row.* col-2 col-sm-9'")

el = row(col = 2, sm = 9, class! = "myclass")
@test contains(el, r":class=\"myclass \+ .*row.* col-2 col-sm-9'")

# ---------

el = cell(col = 2, sm = 9, class = "myclass")
@test contains(el, "class=\"myclass st-col col-2 col-sm-9")

el = cell(col = 2, sm = 9, class = :myclass)
@test contains(el, r":class=\"myclass \+ .*st-col.* col-2 col-sm-9'")

el = column(col = 2, sm = 9, class! = "myclass")
@test contains(el, r":class=\"myclass \+ .*column.* col-2 col-sm-9'")

@test cell(sm = 9) == "<div class=\"st-col col col-sm-9\"></div>"

@test cell(col = -1, sm = 9) == "<div class=\"st-col col-sm-9\"></div>"
end

0 comments on commit 139e513

Please sign in to comment.