hoist option values out of helper to merged module as config
This commit is contained in:
@ -38,7 +38,7 @@ module Merged
|
||||
|
||||
def order_option(section , clazz = "")
|
||||
if section.has_option?("order")
|
||||
clazz += " order-last" if section.option('order') == "right"
|
||||
clazz += " " + " order-last" if section.option('order') == "right"
|
||||
end
|
||||
{class: clazz}
|
||||
end
|
||||
@ -46,7 +46,7 @@ module Merged
|
||||
def text_align_option(section , clazz = "")
|
||||
if section.has_option?("text_align")
|
||||
# text-center , text-left , text-right , leave comment for tailwind
|
||||
clazz += " text-#{section.option('text_align')}"
|
||||
clazz += " " + " text-#{section.option('text_align')}"
|
||||
end
|
||||
{class: clazz}
|
||||
end
|
||||
@ -55,11 +55,11 @@ module Merged
|
||||
if section.has_option?("item_align")
|
||||
case section.option("item_align")
|
||||
when "left"
|
||||
clazz += " justify-start"
|
||||
clazz += " " + " justify-start"
|
||||
when "right"
|
||||
clazz += " justify-end"
|
||||
clazz += " " + " justify-end"
|
||||
else
|
||||
clazz += " justify-center"
|
||||
clazz += " " + " justify-center"
|
||||
end
|
||||
end
|
||||
{class: clazz }
|
||||
@ -68,112 +68,45 @@ module Merged
|
||||
def background_option(section , clazz = "")
|
||||
if section.has_option?("background")
|
||||
option = section.option('background')
|
||||
clazz += bg_for(section)
|
||||
clazz += " text-white" if option.include?("solid")
|
||||
clazz += " " + Merged.background[section.option('background')] || ""
|
||||
end
|
||||
{class: clazz}
|
||||
end
|
||||
|
||||
def margin_option(section , clazz = "")
|
||||
return {class: clazz} unless section.has_option?("margin")
|
||||
margin = { "none" => " m-0" ,
|
||||
"small" => " 2 md:4 lg:6 xl:m-8" ,
|
||||
"medium" => " 5 md:8 lg:10 xl:m-14" ,
|
||||
"large" => " 8 md:12 lg:16 xl:m-20" ,
|
||||
}[section.option("margin")] || ""
|
||||
margin = Merged.margin[section.option("margin")] || ""
|
||||
{class: clazz + margin}
|
||||
end
|
||||
|
||||
def text_color_option(section , clazz = "")
|
||||
if section.has_option?("text_color")
|
||||
clazz += color_for(section)
|
||||
clazz += " " + Merged.text_color[section.option("text_color")] || ""
|
||||
end
|
||||
{class: clazz }
|
||||
end
|
||||
|
||||
def shade_option(section , clazz = "")
|
||||
if section.has_option?("shade_color")
|
||||
clazz += shade_for(section)
|
||||
clazz += " " + Merged.shade_color[section.option("shade_color")] || ""
|
||||
end
|
||||
{class: clazz }
|
||||
end
|
||||
|
||||
def text_column_option( section)
|
||||
option = section.option('columns')
|
||||
option = 2 if option.blank?
|
||||
case option
|
||||
when "3"
|
||||
columns = "columns-1 md:columns-2 lg:columns-3"
|
||||
when "4"
|
||||
columns = "columns-1 md:columns-2 lg:columns-3 xl:columns-4"
|
||||
else # two
|
||||
columns = "columns-1 md:columns-2"
|
||||
def text_column_option( section )
|
||||
if section.has_option?("text_columns")
|
||||
clazz += " " + Merged.text_columns[section.option("text_columns")] || ""
|
||||
end
|
||||
{class: columns }
|
||||
{class: clazz }
|
||||
end
|
||||
|
||||
def column_option(section)
|
||||
option = section.option('columns')
|
||||
case option
|
||||
when "1"
|
||||
columns = "grid-cols-1"
|
||||
when "3"
|
||||
columns = "grid-cols-1 md:grid-cols-2 lg:grid-cols-3"
|
||||
when "4"
|
||||
columns = "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
|
||||
when "5"
|
||||
columns = "grid-cols-1 md:grid-cols-3 lg:grid-cols-5"
|
||||
when "6"
|
||||
columns = "grid-cols-2 md:grid-cols-4 lg:grid-cols-6"
|
||||
else # two
|
||||
columns = "grid-cols-1 md:grid-cols-2"
|
||||
if section.has_option?("columns")
|
||||
clazz += " " + Merged.text_columns[section.option("columns")] || ""
|
||||
end
|
||||
columns += " gap-8 md:gap-12 lg:gap-16"
|
||||
{class: columns }
|
||||
{class: clazz }
|
||||
end
|
||||
|
||||
private
|
||||
# need full color names for tailwind to pick it up
|
||||
def bg_for( section )
|
||||
{ "white" => " bg-white" ,
|
||||
"none" => "" ,
|
||||
"light_blue" => " bg-cyan-100" ,
|
||||
"light_gray" => " bg-gray-100" ,
|
||||
"light_orange" => " bg-orange-50" ,
|
||||
"solid_blue" => " bg-cyan-700" ,
|
||||
"solid_red" => " bg-amber-600" ,
|
||||
"solid_green" => " bg-green-700" ,
|
||||
"solid_petrol" => " bg-teal-700" ,
|
||||
"solid_indigo" => " bg-cyan-900" ,
|
||||
"solid_black" => " bg-slate-900" ,
|
||||
}[section.option('background')] || ""
|
||||
end
|
||||
|
||||
# need full color names for tailwind to pick it up
|
||||
def color_for( section )
|
||||
{ "white" => " text-white",
|
||||
"none" => "",
|
||||
"light_blue" => " text-cyan-100" ,
|
||||
"light_gray" => " text-gray-100" ,
|
||||
"solid_blue" => " text-cyan-700" ,
|
||||
"solid_red" => " text-orange-800" ,
|
||||
"solid_green" => " text-green-700" ,
|
||||
"solid_petrol" => " text-teal-700" ,
|
||||
"solid_indigo" => " text-indigo-800" ,
|
||||
"solid_black" => " text-slate-800" ,
|
||||
}[section.option("text_color")] || ""
|
||||
end
|
||||
# need full color names for tailwind to pick it up
|
||||
|
||||
def shade_for( section )
|
||||
{ "white_25" => " bg-white/25",
|
||||
"none" => "",
|
||||
"black_25" => " bg-black/25" ,
|
||||
"light_blue_25" => " bg-cyan-100/25" ,
|
||||
"light_red_25" => " bg-orange-300/25" ,
|
||||
"solid_blue_25" => " bg-cyan-700/25" ,
|
||||
"solid_red_25" => " bg-orange-800/25" ,
|
||||
}[section.option("shade_color")] || ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user