submit button and unifed usage colors

This commit is contained in:
Torsten 2022-12-02 15:23:39 +02:00
parent 9d125ace16
commit 10cd945472
7 changed files with 23 additions and 17 deletions

View File

@ -1,5 +1,6 @@
module Merged module Merged
class ViewController < ::ApplicationController class ViewController < ::ApplicationController
include MergedHelper
def view def view
@page = Page.find(params[:id]) @page = Page.find(params[:id])

View File

@ -12,15 +12,22 @@ module Merged
def green_button( text, url) def green_button( text, url)
button( text , url , "bg-green-500" ) button( text , url , "bg-green-500" )
end end
def submit_button(text)
clazz = "bg-blue-500 " + button_classes
content_tag(:button , class: clazz , type: :submit) do
text
end
end
def button(text , url , color) def button(text , url , color)
claz = color + " ml-3 inline-block rounded-lg px-4 py-3 text-md font-medium text-white"
link_to(url) do link_to(url) do
content_tag(:button , class: claz ) do content_tag(:button , class: color + " " + button_classes ) do
text text
end end
end end
end end
def button_classes
"ml-3 inline-block rounded-lg px-4 py-3 text-md font-medium text-white"
end
end end
end end

View File

@ -1,5 +1,6 @@
module Merged module Merged
module ViewHelper module ViewHelper
include MergedHelper
# section should be hash with at least 'template' key # section should be hash with at least 'template' key
def find_template(section) def find_template(section)
"merged/view/" + section.template "merged/view/" + section.template

View File

@ -18,13 +18,13 @@
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
.p-4 .p-4
%h3.mt-4.text-lg.font-bold Card #{index + 1} %h3.mt-4.text-lg.font-bold Card #{index + 1}
= yellow_button( "Up" , card_move_url(card.id , dir: :up) ) = blue_button( "Up" , card_move_url(card.id , dir: :up) )
= yellow_button( "Down" , card_move_url(card.id , dir: :down) ) = blue_button( "Down" , card_move_url(card.id , dir: :down) )
= green_button( "New" , "/index" ) = green_button( "New" , "/index" )
= red_button("Delete" , "/index") = red_button("Delete" , "/index")
.p-4 .p-4
%h3.mt-4.text-lg.font-bold Image %h3.mt-4.text-lg.font-bold Image
= blue_button("Change Image" , card_select_image_url(card.id) ) = yellow_button("Change Image" , card_select_image_url(card.id) )
= red_button("Remove image", card_set_image_path( card.id , image: "") ) = red_button("Remove image", card_set_image_path( card.id , image: "") )
@ -42,8 +42,7 @@
%label.block %label.block
%h4.mt-4.text-lg.font-bold Text %h4.mt-4.text-lg.font-bold Text
= text_area_tag( :text , card.text, rows: 5 , class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm" ) = text_area_tag( :text , card.text, rows: 5 , class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm" )
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-sm.font-medium.text-white{:type => "submit"} =submit_button( "Update")
Update
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold Options %h3.mt-4.text-lg.font-bold Options

View File

@ -10,9 +10,9 @@
.grid.grid-cols-5.gap-2.m-8{class: (section.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' } .grid.grid-cols-5.gap-2.m-8{class: (section.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' }
.relative.block.border.border-gray-100.p-4 .relative.block.border.border-gray-100.p-4
%h3.mt-4.text-lg.font-bold Section #{section.index + 1} %h3.mt-4.text-lg.font-bold Section #{section.index + 1}
= yellow_button( "Up" , section_move_url(section.id , dir: :up) ) = blue_button( "Up" , section_move_url(section.id , dir: :up) )
= yellow_button( "Down" , section_move_url(section.id , dir: :down) ) = blue_button( "Down" , section_move_url(section.id , dir: :down) )
= blue_button("Edit" , section_path(section.id) ) = yellow_button("Edit" , section_path(section.id) )
= green_button( "New" , "/index" ) = green_button( "New" , "/index" )
= red_button( "Delete" , "/index" ) = red_button( "Delete" , "/index" )
.relative.block.border.border-gray-100.p-4 .relative.block.border.border-gray-100.p-4

View File

@ -16,7 +16,7 @@
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold Template #{@section.template} %h3.mt-4.text-lg.font-bold Template #{@section.template}
= section_preview(@section , class: "w-full object-contain p-3") = section_preview(@section , class: "w-full object-contain p-3")
= blue_button( "Change Template" , section_select_template_url(@section.id)) = yellow_button( "Change Template" , section_select_template_url(@section.id))
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
= section_form( class: "mx-auto mt-8 mb-0 max-w space-y-4") do = section_form( class: "mx-auto mt-8 mb-0 max-w space-y-4") do
@ -26,8 +26,7 @@
%label.block %label.block
%h4.mt-4.text-lg.font-bold Text %h4.mt-4.text-lg.font-bold Text
= text_area_tag( :text , @section.text, rows: 5 ,class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm") = text_area_tag( :text , @section.text, rows: 5 ,class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-sm.font-medium.text-white{:type => "submit"} = submit_button("Update")
Update
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold Image %h3.mt-4.text-lg.font-bold Image
@ -52,7 +51,7 @@
.mt-4.text-md.font-bold= card.header .mt-4.text-md.font-bold= card.header
.text-sm "#{card.text[0..70]} ....." .text-sm "#{card.text[0..70]} ....."
%p.p-3 %p.p-3
= blue_button( "View and Edit Cards" , section_cards_url(@section.id)) = yellow_button( "View and Edit Cards" , section_cards_url(@section.id))
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold Options %h3.mt-4.text-lg.font-bold Options
To be done To be done

View File

@ -1,2 +1 @@
%a.inline-block.rounded.bg-emerald-600.px-12.py-3.text-sm.font-medium.text-white.transition.hover:bg-emerald-700.focus:outline-none.focus:ring.focus:ring-yellow-400{:href => section.button_link} = blue_button( section.button_text , section.button_link)
=section.button_text