From 57fdada4fa95c1b314f1eb553b06f01761625420 Mon Sep 17 00:00:00 2001 From: Torsten Date: Tue, 27 Dec 2022 00:50:40 +0200 Subject: [PATCH] starting on page types, style and buttons --- app/controllers/merged/pages_controller.rb | 3 +- app/controllers/merged/styles_controller.rb | 1 + app/models/merged/page_style.rb | 6 ++- app/views/merged/pages/index.haml | 3 +- app/views/merged/styles/_options.haml | 9 ++++ app/views/merged/styles/index.haml | 59 ++++++++++++++------- config/merged/option_definitions.yml | 5 ++ config/merged/page_styles.yml | 5 ++ 8 files changed, 68 insertions(+), 23 deletions(-) create mode 100644 app/views/merged/styles/_options.haml diff --git a/app/controllers/merged/pages_controller.rb b/app/controllers/merged/pages_controller.rb index edf1081..a2df5f4 100644 --- a/app/controllers/merged/pages_controller.rb +++ b/app/controllers/merged/pages_controller.rb @@ -5,6 +5,7 @@ module Merged def index @pages = Page.all + @page_styles = PageStyle.all end def show @@ -28,7 +29,7 @@ module Merged flash.now.alert = "Must enter name" render :index else - @page = Page.new_page(name) + @page = Page.new_page(name , params[:type]) @page.add_save(current_member.email) redirect_to new_page_section_url(@page.id) , notice: "Page was successfully created." end diff --git a/app/controllers/merged/styles_controller.rb b/app/controllers/merged/styles_controller.rb index 5716d8a..972c3ad 100644 --- a/app/controllers/merged/styles_controller.rb +++ b/app/controllers/merged/styles_controller.rb @@ -2,6 +2,7 @@ module Merged class StylesController < MergedController def index + @page_styles = PageStyle.all @section_styles = SectionStyle.all @cards_styles = CardStyle.all end diff --git a/app/models/merged/page_style.rb b/app/models/merged/page_style.rb index 847d66b..4d9179e 100644 --- a/app/models/merged/page_style.rb +++ b/app/models/merged/page_style.rb @@ -1,6 +1,10 @@ module Merged class PageStyle < Style - fields :type , :description + fields :type , :description , :section_template + + def section_preview + "merged/section_preview/" + section_template + end end end diff --git a/app/views/merged/pages/index.haml b/app/views/merged/pages/index.haml index b63b9bd..806da3e 100644 --- a/app/views/merged/pages/index.haml +++ b/app/views/merged/pages/index.haml @@ -42,4 +42,5 @@ %label.block %h4.text-lg.font-bold Name = text_field_tag( :name , params[:name], class: "block w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm") - =submit_button( "New Page") + - @page_styles.each do |page| + %button.mt-3.bg-cyan-200{class: button_classes , name: :type , value: page.type}= "New #{page.type.capitalize}" diff --git a/app/views/merged/styles/_options.haml b/app/views/merged/styles/_options.haml new file mode 100644 index 0000000..9d0f655 --- /dev/null +++ b/app/views/merged/styles/_options.haml @@ -0,0 +1,9 @@ +.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm + .p-6 + %h3.text-lg.font-medium + Options + %p.mt-2.text-sm.leading-relaxed.line-clamp-3 + -style.options_definitions.each do | style | + %label.block + .text-lg.font-bold=style.name + =style.description diff --git a/app/views/merged/styles/index.haml b/app/views/merged/styles/index.haml index fe019c1..85ea699 100644 --- a/app/views/merged/styles/index.haml +++ b/app/views/merged/styles/index.haml @@ -1,9 +1,43 @@ - content_for( :merged_menu ) do .text-xl.font-bold - Section styles + Page styles + .text-xl.font-bold + =link_to "Section styles" , "#section_styles" + .text-xl.font-bold + =link_to "Card styles" , "#cards_styles" = render "layouts/merged_header" +.flex.bg-cyan-100 + .px-4.py-8.mx-auto.text-center + %h1.text-4xl.font-bold + Page styles + +.grid.grid-cols-3.gap-4.m-8 + -@page_styles.each do |style| + %article.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm + .p-6 + %h3.text-lg.font-medium + =style.type + %p.mt-2.text-sm + Shorthand: + =style.section_template + .overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm + .p-6 + -if style.section_template + = style.section_template + .w-full.object-contain + =image_tag(style.section_preview ) + -else style.section_template + .w-full + Any Section allowed + =render "options" , style: style + +#section_styles.flex.bg-cyan-100 + .px-4.py-8.mx-auto.text-center + %h1.text-4xl.font-bold + Section styles + .grid.grid-cols-3.gap-4.m-8 -@section_styles.each do | style| .overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm @@ -27,17 +61,9 @@ .w-full.object-contain.h-72 =image_tag(style.section_preview ) - .overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm - .p-6 - %h3.text-lg.font-medium - Options - %p.mt-2.text-sm.leading-relaxed.line-clamp-3 - -style.options_definitions.each do | style | - %label.block - .text-lg.font-bold=style.name - =style.description + =render "options" , style: style -.flex.bg-cyan-100 +#cards_styles.flex.bg-cyan-100 .px-4.py-8.mx-auto.text-center %h1.text-4xl.font-bold Card styles @@ -56,12 +82,5 @@ .p-6 .w-full.object-contain.h-72 =image_tag(style.card_preview ) - .overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm - .p-6 - %h3.text-lg.font-medium - Options - %p.mt-2.text-sm.leading-relaxed.line-clamp-3 - -style.options_definitions.each do | style | - %label.block - .text-lg.font-bold=style.name - =style.description + + =render "options" , style: style diff --git a/config/merged/option_definitions.yml b/config/merged/option_definitions.yml index 6476e7b..4e2833e 100644 --- a/config/merged/option_definitions.yml +++ b/config/merged/option_definitions.yml @@ -98,3 +98,8 @@ :values: :default: :id: 18 +- :name: published + :description: Date when the blog is published + :values: + :default: + :id: 19 diff --git a/config/merged/page_styles.yml b/config/merged/page_styles.yml index 01ade60..05eb37c 100644 --- a/config/merged/page_styles.yml +++ b/config/merged/page_styles.yml @@ -4,3 +4,8 @@ No restrictions of any kind. No options either. options: - meta +- type: blog + description: An news or similar article. + section_template: section_half_image + options: + - published