column number option for 2_col, also bg

This commit is contained in:
Torsten 2022-12-05 12:52:22 +02:00
parent 7728767b3d
commit 6911540d30
3 changed files with 30 additions and 4 deletions

View File

@ -23,8 +23,9 @@ module Merged
def order_option(section) def order_option(section)
return {} unless section.has_option?("order") return {} unless section.has_option?("order")
puts "Order #{section.option('order')}" option = section.option('order')
return {} if section.option("order") == "right" puts "Order #{option}"
return {} if option == "right"
{class: "order-last"} {class: "order-last"}
end end
@ -42,6 +43,21 @@ module Merged
{class: background} {class: background}
end end
def column_option(section)
option = section.option('columns')
option = 2 if option.blank?
puts "Columns #{option}"
case option
when "3"
columns = "grid-cols-1 md:grid-cols-3"
when "4"
columns = "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
else # two
columns = "grid-cols-1 md:grid-cols-2"
end
{class: columns}
end
def button(text , url , color) def button(text , url , color)
link_to(url) do link_to(url) do
content_tag(:button , class: color + " " + button_classes ) do content_tag(:button , class: color + " " + button_classes ) do

View File

@ -1,4 +1,4 @@
.flex.flex-col.bg-cyan-100.mx-5 .flex.flex-col.mx-5{ background_option(section)}
.flex.items-center.justify-center.flex-1 .flex.items-center.justify-center.flex-1
.max-w-prose.px-4.py-8.mx-auto.text-center .max-w-prose.px-4.py-8.mx-auto.text-center
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl %h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
@ -6,6 +6,6 @@
%p.mt-4.text-gray-500 %p.mt-4.text-gray-500
= section.text = section.text
- template = "merged/view/cards/" + section.card_template - template = "merged/view/cards/" + section.card_template
.grid.grid-cols-1.md:grid-cols-2 .grid{ column_option(section)}
- section.cards.each do |element| - section.cards.each do |element|
= render( template , element: element) = render( template , element: element)

View File

@ -8,6 +8,11 @@ sections:
fields: fields:
- header - header
- text - text
options:
- background
- columns
- button_link
- button_text
- template: section_full_up - template: section_full_up
header: Centered Header with text header: Centered Header with text
text: Full width header with centered headline and optional text text: Full width header with centered headline and optional text
@ -53,6 +58,11 @@ options:
during scrolling during scrolling
values: on off values: on off
default: off default: off
- name: columns
desciption:
Number of columns in a layout that supports cards
values: 2 3 4
default: 3
- name: background - name: background
desciption: desciption:
Slight background color Slight background color