Skip to content

Commit

Permalink
Merge pull request #11 from GenieFramework/hh-rawelem
Browse files Browse the repository at this point in the history
Components: Uploader and raw quasar and vue elements
  • Loading branch information
hhaensel authored Jan 28, 2021
2 parents 9f95834 + 3f7a1a7 commit fbd2726
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
35 changes: 33 additions & 2 deletions src/API.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module API

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

export attributes
export attributes, quasar, vue, quasar_pure, vue_pure

const ATTRIBUTES_MAPPINGS = Dict{String,String}(
"autoclose" => "auto-close",
Expand Down Expand Up @@ -100,6 +101,36 @@ function attributes(kwargs::Vector{X},
NamedTuple(attrs)
end

function q__elem(f::Function, elem::Symbol, args...; attrs...) :: HTMLString
normal_element(f, string(elem), [args...], Pair{Symbol,Any}[attrs...])
end

function q__elem(elem::Symbol, children::Union{String,Vector{String}} = "", args...; attrs...) :: HTMLString
normal_element(children, string(elem), [args...], Pair{Symbol,Any}[attrs...])
end

function q__elem(elem::Symbol, children::Any, args...; attrs...) :: HTMLString
normal_element(string(children), string(elem), [args...], Pair{Symbol,Any}[attrs...])
end

function quasar(elem::Symbol, args...;
wrap::Function = StippleUI.DEFAULT_WRAPPER,
kwargs...) where {T<:Stipple.ReactiveModel}
wrap() do
q__elem(Symbol("q-$elem"), args...; attributes([collect(kwargs)...], ATTRIBUTES_MAPPINGS)...)
end
end

function vue(elem::Symbol, args...;
wrap::Function = StippleUI.DEFAULT_WRAPPER,
kwargs...) where {T<:Stipple.ReactiveModel}
wrap() do
q__elem(Symbol("vue-$elem"), args...; attributes([collect(kwargs)...], ATTRIBUTES_MAPPINGS)...)
end
end

quasar_pure(args...; kwargs...) = quasar(args...; wrap=StippleUI.NO_WRAPPER, kwargs...)
vue_pure(args...; kwargs...) = vue(args...; wrap=StippleUI.NO_WRAPPER, kwargs...)

function __init__() :: Nothing
Stipple.rendering_mappings(ATTRIBUTES_MAPPINGS)
Expand Down
4 changes: 2 additions & 2 deletions src/Space.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import Genie.Renderer.Html: HTMLString, normal_element, template

export space

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

function space(args...; wrap::Function = StippleUI.DEFAULT_WRAPPER, kwargs...)
wrap() do
q__separator(args...; kwargs...)
q__space(args...; kwargs...)
end
end

Expand Down
5 changes: 5 additions & 0 deletions src/StippleUI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Stipple
using Stipple.Reexport

const DEFAULT_WRAPPER = Genie.Renderer.Html.template
const NO_WRAPPER = f->f()

#===#

Expand Down Expand Up @@ -58,10 +59,13 @@ include("Toggle.jl")
############# new Elements ##################
include("Layout.jl")
include("Drawer.jl")
include("Uploader.jl")


#===#

import .API: quasar, quasar_pure, vue, vue_pure
export quasar, quasar_pure, vue, vue_pure
@reexport using .Badge
@reexport using .Banner
@reexport using .BigNumber
Expand All @@ -83,6 +87,7 @@ include("Drawer.jl")
@reexport using .Space
@reexport using .Table
@reexport using .Toggle
@reexport using .Uploader

#===#

Expand Down
18 changes: 18 additions & 0 deletions src/Uploader.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Uploader

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

export uploader

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

function uploader(args...;
wrap::Function = StippleUI.DEFAULT_WRAPPER,
kwargs...)
wrap() do
q__uploader(args...; kwargs...)
end
end

end

0 comments on commit fbd2726

Please sign in to comment.