49 lines
1.4 KiB
Ruby
49 lines
1.4 KiB
Ruby
module Merged
|
|
module ViewHelper
|
|
include MergedHelper
|
|
include PagesHelper
|
|
|
|
def render_section(section)
|
|
template = "merged/view/" + section.template
|
|
render( template , section: section)
|
|
end
|
|
|
|
# background image as inline style
|
|
def bg(section , clazz = "")
|
|
return {class: clazz} if section.image.blank?
|
|
img = asset_url( section.image.asset_name )
|
|
style = "background-image: url('#{img}');"
|
|
if(section.option("fixed") == "on")
|
|
clazz += " bg-fixed"
|
|
end
|
|
if(align = section.option("image_align"))
|
|
# for tailwind: bg-left-top bg-left bg-left-bottom
|
|
# bg-top bg-center bg-bottom bg-right-top bg-right bg-right-bottom
|
|
clazz += " bg-#{align}"
|
|
end
|
|
{class: clazz , style: style}
|
|
end
|
|
|
|
# works for with sections and cards that respond to .image
|
|
def image_for(element , classes = "")
|
|
return "" if element.image.blank?
|
|
image = element.image
|
|
image_tag(image.asset_name , alt: image.name , class: classes )
|
|
end
|
|
|
|
def view_button(element , extra_classes = "")
|
|
return "" unless element.has_option?("button_link")
|
|
["<button class='button ",
|
|
extra_classes,
|
|
"'>" ,
|
|
"<a href='" ,
|
|
element.option("button_link") ,
|
|
"'>" ,
|
|
element.option("button_text") ,
|
|
"</a>",
|
|
" </button>"].join.html_safe
|
|
end
|
|
# just for tailwind bg-cyan-200
|
|
end
|
|
end
|