Skip to content

Commit

Permalink
Merge pull request #291 from GenieFramework/hh-coretheme
Browse files Browse the repository at this point in the history
never add core_theme to THEMES
  • Loading branch information
hhaensel authored Oct 11, 2024
2 parents 3b0d87d + 32ce907 commit 64773a5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
53 changes: 42 additions & 11 deletions src/Layout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -122,6 +123,31 @@ function iscontainer(class)
false
end

function genie_footer()
ParsedHTMLString("""
<style>
._genie_logo {
background:url('https://genieframework.com/logos/genie/logo-simple-with-padding.svg') no-repeat;
background-size:40px;
padding-top:22px;
padding-right:10px;
color:transparent !important;
font-size:9pt;
}
._genie .row .col-12 { width:50%; margin:auto; }
</style>
<footer class='_genie container'>
<div class='row'>
<div class='col-12'>
<p class='text-muted credit' style='text-align:center;color:#8d99ae;'>Built with
<a href='https://genieframework.com' target='_blank' class='_genie_logo' ref='nofollow'>Genie</a>
</p>
</div>
</div>
</footer>
""")
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 ""
Expand Down Expand Up @@ -507,6 +533,19 @@ 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"))
end

"""
function theme() :: String
Expand All @@ -528,20 +567,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[])
core_theme && coretheme THEMES[] && push!(output, coretheme()...)

for f in THEMES[]
push!(output, f()...)
end

output
end

Expand Down
6 changes: 4 additions & 2 deletions src/ReactiveTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> """<meta name="$(string(x.first))" content="$(string(x.second))">\n""", meta)
"""
<!DOCTYPE html>
Expand Down Expand Up @@ -73,7 +75,7 @@ function DEFAULT_LAYOUT(; title::String = "Genie App",
<div class='container'>
<div class='row'>
<div class='col-12'>
<% 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) %>
</div>
</div>
</div>
Expand Down

0 comments on commit 64773a5

Please sign in to comment.