From b77b0495c80126b944aa838cd024b15c12dccde7 Mon Sep 17 00:00:00 2001 From: Helmut Haensel Date: Wed, 6 Jan 2021 08:06:30 +0100 Subject: [PATCH 1/3] add raw quasar and vue elements --- src/API.jl | 30 ++++++++++++++++++++++++++++-- src/StippleUI.jl | 3 +++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/API.jl b/src/API.jl index d721fc4b..68f36b39 100644 --- a/src/API.jl +++ b/src/API.jl @@ -1,8 +1,9 @@ module API -using Stipple +using Stipple, StippleUI +import Genie.Renderer.Html: HTMLString, normal_element -export attributes +export attributes, quasar, vue const ATTRIBUTES_MAPPINGS = Dict{String,String}( "autoclose" => "auto-close", @@ -100,6 +101,31 @@ function attributes(kwargs::Vector{X}, NamedTuple(attrs) end +Genie.Renderer.Html.register_normal_element("q__elem", context = @__MODULE__) + +function quasar(elem::Symbol, args...; + wrap::Function = StippleUI.NO_WRAPPER, + kwargs...) where {T<:Stipple.ReactiveModel} + wrap() do + q__elem(args...; + attributes( + [Symbol(replace("$k", "_"=>"-")) => v for (k,v) in kwargs], + ATTRIBUTES_MAPPINGS + )...) + end |> x->replace(x, "q-elem"=>"q-$elem") +end + +function vue(elem::Symbol, args...; + wrap::Function = StippleUI.NO_WRAPPER, + kwargs...) where {T<:Stipple.ReactiveModel} + wrap() do + q__elem(args...; + attributes( + [Symbol(replace("$k", "_"=>"-")) => v for (k,v) in kwargs], + ATTRIBUTES_MAPPINGS + )...) + end |> x->replace(x, "q-elem"=>"vue-$elem") +end function __init__() :: Nothing Stipple.rendering_mappings(ATTRIBUTES_MAPPINGS) diff --git a/src/StippleUI.jl b/src/StippleUI.jl index 2f68359a..075994e5 100644 --- a/src/StippleUI.jl +++ b/src/StippleUI.jl @@ -6,6 +6,7 @@ import Stipple using Stipple.Reexport const DEFAULT_WRAPPER = Genie.Renderer.Html.template +const NO_WRAPPER = f->f() #===# @@ -62,6 +63,8 @@ include("Drawer.jl") #===# +import .API.quasar, .API.vue +export quasar, vue @reexport using .Badge @reexport using .Banner @reexport using .BigNumber From f26d251f559160bb10809f2c8995960d1bec5a13 Mon Sep 17 00:00:00 2001 From: hhaensel Date: Thu, 28 Jan 2021 13:35:26 +0100 Subject: [PATCH 2/3] add uploader component, fix error in space component --- src/Space.jl | 4 ++-- src/StippleUI.jl | 2 ++ src/Uploader.jl | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/Uploader.jl diff --git a/src/Space.jl b/src/Space.jl index 2694c783..484f8c0d 100644 --- a/src/Space.jl +++ b/src/Space.jl @@ -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 diff --git a/src/StippleUI.jl b/src/StippleUI.jl index 075994e5..75e278c5 100644 --- a/src/StippleUI.jl +++ b/src/StippleUI.jl @@ -59,6 +59,7 @@ include("Toggle.jl") ############# new Elements ################## include("Layout.jl") include("Drawer.jl") +include("Uploader.jl") #===# @@ -86,6 +87,7 @@ export quasar, vue @reexport using .Space @reexport using .Table @reexport using .Toggle +@reexport using .Uploader #===# diff --git a/src/Uploader.jl b/src/Uploader.jl new file mode 100644 index 00000000..26a6ac81 --- /dev/null +++ b/src/Uploader.jl @@ -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 From 3f7a1a74497935aa4f04e7bdc9a874c546d3e0b7 Mon Sep 17 00:00:00 2001 From: hhaensel Date: Thu, 28 Jan 2021 13:37:37 +0100 Subject: [PATCH 3/3] add raw quasar and vue components --- src/API.jl | 37 +++++++++++++++++++++---------------- src/StippleUI.jl | 4 ++-- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/API.jl b/src/API.jl index 68f36b39..31d87fc4 100644 --- a/src/API.jl +++ b/src/API.jl @@ -3,7 +3,7 @@ module API using Stipple, StippleUI import Genie.Renderer.Html: HTMLString, normal_element -export attributes, quasar, vue +export attributes, quasar, vue, quasar_pure, vue_pure const ATTRIBUTES_MAPPINGS = Dict{String,String}( "autoclose" => "auto-close", @@ -101,32 +101,37 @@ function attributes(kwargs::Vector{X}, NamedTuple(attrs) end -Genie.Renderer.Html.register_normal_element("q__elem", context = @__MODULE__) +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.NO_WRAPPER, + wrap::Function = StippleUI.DEFAULT_WRAPPER, kwargs...) where {T<:Stipple.ReactiveModel} wrap() do - q__elem(args...; - attributes( - [Symbol(replace("$k", "_"=>"-")) => v for (k,v) in kwargs], - ATTRIBUTES_MAPPINGS - )...) - end |> x->replace(x, "q-elem"=>"q-$elem") + q__elem(Symbol("q-$elem"), args...; attributes([collect(kwargs)...], ATTRIBUTES_MAPPINGS)...) + end end function vue(elem::Symbol, args...; - wrap::Function = StippleUI.NO_WRAPPER, + wrap::Function = StippleUI.DEFAULT_WRAPPER, kwargs...) where {T<:Stipple.ReactiveModel} wrap() do - q__elem(args...; - attributes( - [Symbol(replace("$k", "_"=>"-")) => v for (k,v) in kwargs], - ATTRIBUTES_MAPPINGS - )...) - end |> x->replace(x, "q-elem"=>"vue-$elem") + 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) diff --git a/src/StippleUI.jl b/src/StippleUI.jl index 75e278c5..3e68620a 100644 --- a/src/StippleUI.jl +++ b/src/StippleUI.jl @@ -64,8 +64,8 @@ include("Uploader.jl") #===# -import .API.quasar, .API.vue -export quasar, vue +import .API: quasar, quasar_pure, vue, vue_pure +export quasar, quasar_pure, vue, vue_pure @reexport using .Badge @reexport using .Banner @reexport using .BigNumber