From 287d8dbe5bc0e31a3c2b2c1ad80323e724a7d80b Mon Sep 17 00:00:00 2001 From: hhaensel Date: Thu, 10 Oct 2024 19:18:16 +0200 Subject: [PATCH 1/2] never add core_theme to THEMES --- src/Layout.jl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Layout.jl b/src/Layout.jl index 7b377d46..003893bf 100644 --- a/src/Layout.jl +++ b/src/Layout.jl @@ -507,6 +507,11 @@ function htmldiv(args...; Genie.Renderer.Html.div(args...; kwargs...) end +function coretheme() + stylesheet("https://fonts.googleapis.com/css?family=Material+Icons"), + stylesheet(Genie.Assets.asset_path(Stipple.assets_config, :css, file="stipplecore")) +end + """ function theme() :: String @@ -528,20 +533,12 @@ julia> push!(Stipple.Layout.THEMES[], StippleUI.theme) function theme(; core_theme::Bool = true) :: Vector{String} output = String[] - if core_theme - push!(THEMES[], () -> begin - stylesheet("https://fonts.googleapis.com/css?family=Material+Icons"), - stylesheet(Genie.Assets.asset_path(Stipple.assets_config, :css, file="stipplecore")) - end - ) - end - - unique!(THEMES[]) - for f in THEMES[] push!(output, f()...) end + core_theme && coretheme ∉ THEMES[] && push!(output, coretheme()...) + output end From 32ce9071c3dd814d92cbc6bc7d20e59411fbe65d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helmut=20H=C3=A4nsel?= Date: Fri, 11 Oct 2024 08:45:47 +0200 Subject: [PATCH 2/2] move coretheme to the beginning of themes, add genie_footer, googlefonts_css, stipplecore_css --- src/Layout.jl | 40 +++++++++++++++++++++++++++++++++++++--- src/ReactiveTools.jl | 6 ++++-- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/Layout.jl b/src/Layout.jl index 003893bf..86be5b9a 100644 --- a/src/Layout.jl +++ b/src/Layout.jl @@ -10,7 +10,8 @@ using Genie, Stipple export layout, add_css, remove_css export page, app, row, column, cell, container, flexgrid_kwargs, htmldiv, @gutter -export theme +export theme, googlefonts_css, stipplecore_css, genie_footer + const THEMES = Ref(Function[]) const FLEXGRID_KWARGS = [:col, :xs, :sm, :md, :lg, :xl, :gutter, :xgutter, :ygutter] @@ -122,6 +123,31 @@ function iscontainer(class) false end +function genie_footer() + ParsedHTMLString(""" + +
+
+
+

Built with + +

+
+
+
+ """) +end + function flexgrid_class(tag::Symbol, value::Union{String,Int,Nothing,Symbol} = -1, container = false) gutter = container ? "q-col-gutter" : "q-gutter" (value == -1 || value === nothing) && return "" @@ -507,6 +533,14 @@ function htmldiv(args...; Genie.Renderer.Html.div(args...; kwargs...) end +function googlefonts_css() + (stylesheet("https://fonts.googleapis.com/css?family=Material+Icons"),) +end + +function stipplecore_css() + (stylesheet(Genie.Assets.asset_path(Stipple.assets_config, :css, file="stipplecore")),) +end + function coretheme() stylesheet("https://fonts.googleapis.com/css?family=Material+Icons"), stylesheet(Genie.Assets.asset_path(Stipple.assets_config, :css, file="stipplecore")) @@ -533,11 +567,11 @@ julia> push!(Stipple.Layout.THEMES[], StippleUI.theme) function theme(; core_theme::Bool = true) :: Vector{String} output = String[] + core_theme && coretheme ∉ THEMES[] && push!(output, coretheme()...) + for f in THEMES[] push!(output, f()...) end - - core_theme && coretheme ∉ THEMES[] && push!(output, coretheme()...) output end diff --git a/src/ReactiveTools.jl b/src/ReactiveTools.jl index 1456a57a..33503752 100644 --- a/src/ReactiveTools.jl +++ b/src/ReactiveTools.jl @@ -42,7 +42,9 @@ const TYPES = LittleDict{Module,Union{<:DataType,Nothing}}() const HANDLERS_FUNCTIONS = LittleDict{Type{<:ReactiveModel},Function}() function DEFAULT_LAYOUT(; title::String = "Genie App", - meta::D = Dict(), head_content::Union{AbstractString, Vector} = "") where {D <:AbstractDict} + meta::D = Dict(), + head_content::Union{AbstractString, Vector} = "", + core_theme::Bool = true) where {D <:AbstractDict} tags = Genie.Renderers.Html.for_each(x -> """\n""", meta) """ @@ -73,7 +75,7 @@ function DEFAULT_LAYOUT(; title::String = "Genie App",
- <% Stipple.page(model, partial = true, v__cloak = true, [Stipple.Genie.Renderer.Html.@yield], Stipple.@if(:isready)) %> + <% Stipple.page(model, partial = true, v__cloak = true, [Stipple.Genie.Renderer.Html.@yield], Stipple.@if(:isready); core_theme = $core_theme) %>