Skip to content

Commit

Permalink
New UI elements, API enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Aug 8, 2021
1 parent 6936602 commit bb956c3
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 7 deletions.
30 changes: 24 additions & 6 deletions src/Button.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,35 @@ export btn, btngroup
Genie.Renderer.Html.register_normal_element("q__btn", context = @__MODULE__)
Genie.Renderer.Html.register_normal_element("q__btn__group", context = @__MODULE__)

function btn(
label::String = "",
args...;
wrap::Function = StippleUI.DEFAULT_WRAPPER,
kwargs...)
function btn( label::String = "",
args...;
wrap::Function = StippleUI.DEFAULT_WRAPPER,
content::Union{String,Vector,Function} = "",
kwargs...)

wrap() do
q__btn("", args...; attributes([:label => label, kwargs...], StippleUI.API.ATTRIBUTES_MAPPINGS)...)
q__btn([isa(content, Function) ? content() : join(content)],
args...;
attributes([:label => label, kwargs...], StippleUI.API.ATTRIBUTES_MAPPINGS)...)
end
end

function btn( content::Function,
label::String = "",
args...;
wrap::Function = StippleUI.DEFAULT_WRAPPER,
kwargs...)
btn(label, args...; wrap = wrap, content = content, kwargs...)
end

function btn( args...;
label::String = "",
content::Union{String,Vector,Function} = "",
wrap::Function = StippleUI.DEFAULT_WRAPPER,
kwargs...)
btn(label, args...; wrap = wrap, content = content, kwargs...)
end

const button = btn


Expand Down
4 changes: 3 additions & 1 deletion src/List.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module List
using Genie, Stipple, StippleUI, StippleUI.API
import Genie.Renderer.Html: HTMLString, normal_element

export list, item, item_section, item_label
export list, item, item_section, itemsection, item_label, itemlabel

Genie.Renderer.Html.register_normal_element("q__list", context = @__MODULE__)
Genie.Renderer.Html.register_normal_element("q__item", context = @__MODULE__)
Expand All @@ -27,10 +27,12 @@ end
function item_section(args...; kwargs...)
q__item__section(args...; attributes([kwargs...], StippleUI.API.ATTRIBUTES_MAPPINGS)...)
end
const itemsection = item_section


function item_label(args...; kwargs...)
q__item__label(args...; kwargs...)
end
const itemlabel = item_label

end
32 changes: 32 additions & 0 deletions src/Menu.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Menu

using Genie, Stipple, StippleUI, StippleUI.API
import Genie.Renderer.Html: HTMLString, normal_element

export menu

Genie.Renderer.Html.register_normal_element("q__menu", context = @__MODULE__)

function menu(
fieldname::Union{Symbol,Nothing} = nothing,
args...;
content::Union{String,Vector} = "",
wrap::Function = StippleUI.DEFAULT_WRAPPER,
kwargs...)

wrap() do
q__menu(args...; attributes([:fieldname => fieldname, kwargs...], StippleUI.API.ATTRIBUTES_MAPPINGS)...) do
join(content)
end
end
end

function menu(content::Function,
fieldname::Union{Symbol,Nothing} = nothing,
args...;
wrap::Function = StippleUI.DEFAULT_WRAPPER,
kwargs...)
menu(label, fieldname, args...; wrap = wrap, content = content(), kwargs...)
end

end
27 changes: 27 additions & 0 deletions src/Spinner.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Spinner

using Genie, Stipple, StippleUI, StippleUI.API
import Genie.Renderer.Html: HTMLString, normal_element

export spinner

function __init__()
Genie.Renderer.Html.register_normal_element("q__spinner", context = @__MODULE__)

for spinner in ["audio", "ball", "bars", "box", "clock", "comment", "cube", "dots", "facebook", "gears", "grid",
"hearts", "hourglass", "infinity", "ios", "orbit", "oval", "pie", "puff", "radio", "rings", "tail"]
Genie.Renderer.Html.register_normal_element("q__spinner__$spinner", context = @__MODULE__)
end
end

function spinner(spinner_type::Union{String,Symbol} = "",
args...;
wrap::Function = StippleUI.DEFAULT_WRAPPER,
kwargs...)

wrap() do
getfield(@__MODULE__, Symbol("q__spinner$(isempty(string(spinner_type)) ? "" : "__")$spinner_type"))(args...; kwargs...)
end
end

end
4 changes: 4 additions & 0 deletions src/StippleUI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ include("Heading.jl")
include("Icon.jl")
include("Layout.jl")
include("List.jl")
include("Menu.jl")
include("Radio.jl")
include("Range.jl")
include("Select.jl")
include("Separator.jl")
include("Space.jl")
include("Spinner.jl")
include("Table.jl")
include("Toggle.jl")
include("Uploader.jl")
Expand All @@ -83,11 +85,13 @@ export quasar, quasar_pure, vue, vue_pure, xelem, xelem_pure, @click
@reexport using .Heading
@reexport using .Icon
@reexport using .List
@reexport using .Menu
@reexport using .Radio
@reexport using .Range
@reexport using .Select
@reexport using .Separator
@reexport using .Space
@reexport using .Spinner
@reexport using .Table
@reexport using .Toggle
@reexport using .Uploader
Expand Down

2 comments on commit bb956c3

@essenciary
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/42646

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.0 -m "<description of version>" bb956c376bdf5e0ec3a9d90993fc253f5a0d65f3
git push origin v0.7.0

Please sign in to comment.