first hero section on index

This commit is contained in:
Torsten 2022-11-22 19:44:34 +02:00
parent d087af0879
commit ee479cdffc
6 changed files with 39 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

View File

@ -1,4 +1,10 @@
class CmsController < ApplicationController
def view
page = params[:id]
# assert file exists
@data = YAML.load_file(Rails.root.join('cms' , "#{page}.yaml"))
#assert data is an array (of hashes?)
end
end

View File

@ -1,2 +1,12 @@
module CmsHelper
# sectio should be hash with at least 'template' key
def find_template(section)
"sections/" + section["template"]
end
def bg(section)
#{'background-image' => url('#{image_url('cms/' + section['image'])}')}
img = image_url "cms/house.jpg"
"background-image: url('#{img}');"
end
end

View File

@ -1 +1,3 @@
%h1 CMS
- @data.each do |section|
- template = find_template(section)
= render( template , section: section)

View File

@ -0,0 +1,13 @@
%section.overflow-hidden.bg-cover.bg-center.bg-no-repeat{style: bg(section)}
.p-8.md:p-12.lg:px-16.lg:py-24{:class => "bg-black/25"}
.max-w-lg.text-center.sm:text-left
%h2.text-2xl.font-bold.text-white.sm:text-3xl.md:text-5xl
= section["header"]
%p.hidden.max-w-md.md:mt-6.md:block.md:text-lg.md:leading-relaxed{:class => "text-white/90"}
= section["text"]
-if section["button_text"]
.mt-4.sm:mt-8
%a.inline-flex.items-center.rounded-full.bg-indigo-700.px-8.py-3.text-white.shadow-lg.transition.hover:bg-indigo-600.focus:outline-none.focus:ring{:href => section["button_link"]}
%span.text-sm.font-medium section["button_text"]
%svg.ml-3.h-5.w-5{:fill => "none", :stroke => "currentColor", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"}
%path{:d => "M17 8l4 4m0 0l-4 4m4-4H3", "stroke-linecap" => "round", "stroke-linejoin" => "round", "stroke-width" => "2"}

7
cms/index.yaml Normal file
View File

@ -0,0 +1,7 @@
- template: hero_section
header: HUB FEENIX
text:
Only an hour west of Helsinki, the Feenix rises from an old sanatorium.
The Hub is a place to create, learn and regenerate.
image: house.jpg
im: section.overflow-hidden.bg-cover.bg-center.bg-no-repeat{:class => "bg-[url('#{image_url('cms/' + section['image'])}')]"}