card styles and previews

This commit is contained in:
Torsten 2022-11-29 17:59:04 +02:00
parent 15ef3c34fd
commit 6f6836630f
4 changed files with 58 additions and 9 deletions

View File

@ -2,8 +2,8 @@ module Merged
class StylesController < MergedController class StylesController < MergedController
def index def index
@styles = Style.all @sections , @cards = Style.all
end end
end end
end end

View File

@ -2,6 +2,9 @@ module Merged
class Style class Style
include ActiveModel::API include ActiveModel::API
cattr_accessor :sections , :cards
@@sections = []
@@cards = []
attr_reader :content attr_reader :content
@ -21,14 +24,29 @@ module Merged
def cards def cards
@content["cards"] == true @content["cards"] == true
end end
def preview def section_preview
"merged/section_preview/" + template "merged/section_preview/" + template
end end
def card_preview
"merged/card_preview/" + template
end
def self.cards
self.all
@@cards
end
def self.sections
self.all
@@sections
end
def self.all def self.all
# should account for app styles. now just loading engines if @@sections.length == 0
@@styles = YAML.load_file(Engine.root.join("config/styles.yaml")) all = YAML.load_file(Engine.root.join("config/styles.yaml"))
@@styles.collect{ |content| Style.new(content) } all["sections"].each { |content| @@sections << Style.new(content) }
all["cards"].each { |content| @@cards << Style.new(content) }
end
[@@sections , @@cards]
end end
end end

View File

@ -1,7 +1,10 @@
.px-4.py-8.mx-auto.text-center
%h1.text-4xl.font-bold
Section styles
.grid.grid-cols-3.gap-4.m-8 .grid.grid-cols-3.gap-4.m-8
-@styles.each do |style| -@sections.each do |style|
%article.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm %article.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm
=image_tag(style.preview , class: "h-56 w-full object-contain lg:h-72") =image_tag(style.section_preview , class: "h-56 w-full object-contain lg:h-72")
%p.mt-2.text-sm.text-gray-500 %p.mt-2.text-sm.text-gray-500
=style.template =style.template
%article.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm %article.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm
@ -23,3 +26,25 @@
Section may include cards. See card styles below Section may include cards. See card styles below
-else -else
Section may not include cards Section may not include cards
.px-4.py-8.mx-auto.text-center
%h1.text-4xl.font-bold
Card styles
.grid.grid-cols-3.gap-4.m-8
-@cards.each do |style|
%article.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm
=image_tag(style.card_preview , class: "h-56 w-full object-contain lg:h-72")
%p.mt-2.text-sm.text-gray-500
=style.template
%article.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm
.p-6
%h3.text-lg.font-medium.text-gray-900
=style.header
%p.mt-2.text-sm.leading-relaxed.text-gray-500.line-clamp-3
= style.text
%article.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm
.p-6
%h3.text-lg.font-medium.text-gray-900
Option
%p.mt-2.text-sm.leading-relaxed.text-gray-500.line-clamp-3
Following options: none (wip)

View File

@ -1,3 +1,5 @@
---
sections:
- template: section_2_col - template: section_2_col
header: Two column layout with header header: Two column layout with header
text: A header with text and two column layout. Columns have a little gap, so text: A header with text and two column layout. Columns have a little gap, so
@ -18,4 +20,8 @@
text: Image left, header and text on the right. Optional button. text: Image left, header and text on the right. Optional button.
- template: section_spacer - template: section_spacer
header: Spacer header: Spacer
text: Just for extra padding text: Just for extra padding
cards:
- template: card_full_image
header: Full background
text: With text in bottom right corner, offset with solid color