unified option handling more
This commit is contained in:
parent
b606caf2b8
commit
f32e6c105c
@ -20,6 +20,8 @@ module Merged
|
|||||||
text
|
text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def button_classes
|
||||||
|
"mr-3 inline-block rounded-lg px-4 py-3 text-md font-medium text-white"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,49 +13,47 @@ module Merged
|
|||||||
|
|
||||||
def order_option(section , clazz = "")
|
def order_option(section , clazz = "")
|
||||||
if section.has_option?("order")
|
if section.has_option?("order")
|
||||||
option = section.option('order')
|
clazz += " order-last" if section.option('order') == "right"
|
||||||
puts "Order #{option}"
|
|
||||||
clazz += " order-last" if option == "right"
|
|
||||||
end
|
end
|
||||||
{class: clazz}
|
{class: clazz}
|
||||||
end
|
end
|
||||||
|
|
||||||
def align_option(section)
|
def align_option(section , clazz = "")
|
||||||
return {} unless section.has_option?("align")
|
if section.has_option?("align")
|
||||||
option = section.option('align')
|
# text-center , text-left , text-right , leave comment for tailwind
|
||||||
puts "align #{option}"
|
clazz += " text-#{section.option('align')}"
|
||||||
# text-center , text-left , text-right , leave comment for tailwind
|
end
|
||||||
{class: "text-#{option}"}
|
{class: clazz}
|
||||||
end
|
end
|
||||||
|
|
||||||
def background_option(section)
|
def background_option(section , clazz = "")
|
||||||
return {} unless section.has_option?("background")
|
if section.has_option?("background")
|
||||||
option = section.option('background')
|
option = section.option('background')
|
||||||
puts "Background #{option}"
|
clazz += bg_for(option)
|
||||||
background = bg_for(option)
|
clazz += " text-white" if option.include?("solid")
|
||||||
background += " text-white" if option.include?("solid")
|
end
|
||||||
{class: background}
|
{class: clazz}
|
||||||
end
|
end
|
||||||
|
|
||||||
def margin_option(section)
|
def margin_option(section , clazz = "")
|
||||||
return {} unless section.has_option?("margin")
|
if section.has_option?("margin")
|
||||||
option = section.option('margin')
|
clazz += margin_for(section.option("margin"))
|
||||||
puts "Margin #{option}"
|
end
|
||||||
{class: margin_for(option)}
|
{class: clazz}
|
||||||
end
|
end
|
||||||
|
|
||||||
def color_option(section)
|
def color_option(section , clazz = "")
|
||||||
return {} unless section.has_option?("color")
|
if section.has_option?("color")
|
||||||
option = section.option('color')
|
clazz += color_for(section.option("color"))
|
||||||
puts "Text color #{option} , #{color_for(option)}"
|
end
|
||||||
{class: color_for(option) }
|
{class: clazz }
|
||||||
end
|
end
|
||||||
|
|
||||||
def shade_option(section)
|
def shade_option(section)
|
||||||
return {} unless section.has_option?("shade_color")
|
if section.has_option?("shade_color")
|
||||||
option = section.option('shade_color')
|
clazz += shade_for(section.option("shade_color"))
|
||||||
puts "Shade color #{option} , #{shade_for(option)}"
|
end
|
||||||
{class: shade_for(option) }
|
{class: clazz }
|
||||||
end
|
end
|
||||||
|
|
||||||
def column_option(section)
|
def column_option(section)
|
||||||
@ -76,49 +74,49 @@ module Merged
|
|||||||
private
|
private
|
||||||
# need full color names for tailwind to pick it up
|
# need full color names for tailwind to pick it up
|
||||||
def bg_for( option )
|
def bg_for( option )
|
||||||
{ "white" => "bg-white" ,
|
{ "white" => " bg-white" ,
|
||||||
"none" => "" ,
|
"none" => "" ,
|
||||||
"light_blue" => "bg-cyan-100" ,
|
"light_blue" => " bg-cyan-100" ,
|
||||||
"light_gray" => "bg-gray-100" ,
|
"light_gray" => " bg-gray-100" ,
|
||||||
"light_orange" => "bg-orange-50" ,
|
"light_orange" => " bg-orange-50" ,
|
||||||
"solid_blue" => "bg-cyan-700" ,
|
"solid_blue" => " bg-cyan-700" ,
|
||||||
"solid_red" => "bg-orange-800" ,
|
"solid_red" => " bg-orange-800" ,
|
||||||
"solid_green" => "bg-green-700" ,
|
"solid_green" => " bg-green-700" ,
|
||||||
"solid_petrol" => "bg-teal-700" ,
|
"solid_petrol" => " bg-teal-700" ,
|
||||||
"solid_indigo" => "bg-indigo-800" ,
|
"solid_indigo" => " bg-indigo-800" ,
|
||||||
"solid_black" => "bg-slate-900" ,
|
"solid_black" => " bg-slate-900" ,
|
||||||
}[option] || ""
|
}[option] || ""
|
||||||
end
|
end
|
||||||
# need full margin names for tailwind to pick it up
|
# need full margin names for tailwind to pick it up
|
||||||
def margin_for( option )
|
def margin_for( option )
|
||||||
{ "0" => "m-0" ,
|
{ "0" => " m-0" ,
|
||||||
"none" => "" ,
|
"none" => "" ,
|
||||||
"20" => "m-20" ,
|
"20" => " m-20" ,
|
||||||
}[option] || ""
|
}[option] || ""
|
||||||
end
|
end
|
||||||
# need full color names for tailwind to pick it up
|
# need full color names for tailwind to pick it up
|
||||||
def color_for( option )
|
def color_for( option )
|
||||||
{ "white" => "text-white",
|
{ "white" => " text-white",
|
||||||
"none" => "",
|
"none" => "",
|
||||||
"light_blue" => "text-cyan-100" ,
|
"light_blue" => " text-cyan-100" ,
|
||||||
"solid_blue" => "text-cyan-700" ,
|
"solid_blue" => " text-cyan-700" ,
|
||||||
"solid_red" => "text-orange-800" ,
|
"solid_red" => " text-orange-800" ,
|
||||||
"solid_green" => "text-green-700" ,
|
"solid_green" => " text-green-700" ,
|
||||||
"solid_petrol" => "text-teal-700" ,
|
"solid_petrol" => " text-teal-700" ,
|
||||||
"solid_indigo" => "text-indigo-800" ,
|
"solid_indigo" => " text-indigo-800" ,
|
||||||
"solid_black" => "text-slate-900" ,
|
"solid_black" => " text-slate-900" ,
|
||||||
}[option] || ""
|
}[option] || ""
|
||||||
end
|
end
|
||||||
# need full color names for tailwind to pick it up
|
# need full color names for tailwind to pick it up
|
||||||
|
|
||||||
def shade_for( option )
|
def shade_for( option )
|
||||||
{ "white_25" => "bg-white/25",
|
{ "white_25" => " bg-white/25",
|
||||||
"none" => "",
|
"none" => "",
|
||||||
"black_25" => "bg-black/25" ,
|
"black_25" => " bg-black/25" ,
|
||||||
"light_blue_25" => "bg-cyan-100/25" ,
|
"light_blue_25" => " bg-cyan-100/25" ,
|
||||||
"light_red_25" => "bg-orange-300/25" ,
|
"light_red_25" => " bg-orange-300/25" ,
|
||||||
"solid_blue_25" => "bg-cyan-700/25" ,
|
"solid_blue_25" => " bg-cyan-700/25" ,
|
||||||
"solid_red_25" => "bg-orange-800/25" ,
|
"solid_red_25" => " bg-orange-800/25" ,
|
||||||
}[option] || ""
|
}[option] || ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
module Merged
|
module Merged
|
||||||
module ViewHelper
|
module ViewHelper
|
||||||
include OptionsHelper
|
include OptionsHelper
|
||||||
|
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
|
||||||
@ -33,9 +34,6 @@ module Merged
|
|||||||
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
|
||||||
|
@ -78,6 +78,10 @@ cards:
|
|||||||
fields:
|
fields:
|
||||||
- header
|
- header
|
||||||
- text
|
- text
|
||||||
|
options:
|
||||||
|
- background
|
||||||
|
- color
|
||||||
|
- align
|
||||||
- template: card_normal_square
|
- template: card_normal_square
|
||||||
header: Standard card with square image
|
header: Standard card with square image
|
||||||
text: Image, header, text, normal stuff
|
text: Image, header, text, normal stuff
|
||||||
@ -117,7 +121,7 @@ options:
|
|||||||
desciption:
|
desciption:
|
||||||
Text colors. Don't use with solid background colors.
|
Text colors. Don't use with solid background colors.
|
||||||
Same colors as background available. Default none, meas as parent.
|
Same colors as background available. Default none, meas as parent.
|
||||||
values: none white light_blue light_gray solid_black solid_blue solid_red solid_indigo
|
values: none white black light_blue light_gray solid_black solid_blue solid_red solid_indigo
|
||||||
default: none
|
default: none
|
||||||
- name: shade_color
|
- name: shade_color
|
||||||
desciption:
|
desciption:
|
||||||
|
Loading…
Reference in New Issue
Block a user