diff --git a/src/Button.jl b/src/Button.jl index 80207b7c..c82587aa 100644 --- a/src/Button.jl +++ b/src/Button.jl @@ -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 diff --git a/src/List.jl b/src/List.jl index 1138f81f..45c4b2e5 100644 --- a/src/List.jl +++ b/src/List.jl @@ -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__) @@ -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 diff --git a/src/Menu.jl b/src/Menu.jl new file mode 100644 index 00000000..9f72e21c --- /dev/null +++ b/src/Menu.jl @@ -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 diff --git a/src/Spinner.jl b/src/Spinner.jl new file mode 100644 index 00000000..efb51197 --- /dev/null +++ b/src/Spinner.jl @@ -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 diff --git a/src/StippleUI.jl b/src/StippleUI.jl index d20a2ea6..b6c09333 100644 --- a/src/StippleUI.jl +++ b/src/StippleUI.jl @@ -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") @@ -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