Prod build process
This commit is contained in:
@@ -3,9 +3,9 @@ class TailwindFormBuilder < ActionView::Helpers::FormBuilder
|
||||
# leans on the FormBuilder class_attribute `field_helpers`
|
||||
# you'll want to add a method for each of the specific helpers listed here if you want to style them
|
||||
|
||||
TEXT_FIELD_STYLE = "bg-gray-200 rounded py-2 px-4 text-bluetang font-semibold leading-tight focus:outline-none focus:bg-white".freeze
|
||||
SELECT_FIELD_STYLE = "block bg-gray-200 text-gray-700 py-2 px-4 rounded leading-tight focus:outline-none focus:bg-white".freeze
|
||||
SUBMIT_BUTTON_STYLE = "cursor-pointer shadow bg-bronze focus:shadow-outline focus:outline-none text-white font-bold py-2 px-4 rounded hover:bg-copper".freeze
|
||||
TEXT_FIELD_STYLE = "flex bg-gray-200 rounded py-2 px-4 text-bluetang font-semibold leading-tight focus:outline-none focus:bg-white border border-platinum".freeze
|
||||
SELECT_FIELD_STYLE = "block bg-gray-200 text-bluetang py-2 px-4 font-semibold rounded leading-tight focus:outline-none focus:bg-white border border-platinum".freeze
|
||||
SUBMIT_BUTTON_STYLE = "cursor-pointer font-bold text-lg text-platinum hover:text-bronze bg-cobalt-vivid hover:bg-deepcove border-2 border-cobalt-vivid py-2 px-4 rounded".freeze
|
||||
|
||||
text_field_helpers.each do |field_method|
|
||||
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
||||
@@ -48,6 +48,7 @@ class TailwindFormBuilder < ActionView::Helpers::FormBuilder
|
||||
custom_opts, opts = partition_custom_opts(options)
|
||||
|
||||
classes = apply_style_classes(TEXT_FIELD_STYLE, custom_opts, object_method)
|
||||
puts "classes: #{classes}"
|
||||
|
||||
field = send(field_method, object_method, {
|
||||
class: classes,
|
||||
@@ -63,7 +64,7 @@ class TailwindFormBuilder < ActionView::Helpers::FormBuilder
|
||||
label = tailwind_label(object_method, label_options, field_options)
|
||||
error_label = error_label(object_method, field_options)
|
||||
|
||||
@template.content_tag("div", label + error_label, {class: "flex flex-col items-start"})
|
||||
@template.content_tag("div", label + error_label, {class: "flex justify-between"})
|
||||
end
|
||||
|
||||
def tailwind_label(object_method, label_options, field_options)
|
||||
@@ -73,8 +74,8 @@ class TailwindFormBuilder < ActionView::Helpers::FormBuilder
|
||||
[object_method.to_s.titleize, {}]
|
||||
end
|
||||
|
||||
label_classes = label_opts[:class] || "block text-platinum font-bold md:text-right mb-1 md:mb-0 pr-4"
|
||||
label_classes += " text-yellow-800 dark:text-yellow-400" if field_options[:disabled]
|
||||
label_classes = label_opts[:class] || "block shrink-0 text-platinum font-bold md:text-right mb-1 md:mb-0 pr-4"
|
||||
label_classes += " dark:text-brightlava" if field_options[:disabled]
|
||||
label(object_method, text, {
|
||||
class: label_classes
|
||||
}.merge(label_opts.except(:class)))
|
||||
@@ -83,15 +84,16 @@ class TailwindFormBuilder < ActionView::Helpers::FormBuilder
|
||||
def error_label(object_method, options)
|
||||
if errors_for(object_method).present?
|
||||
error_message = @object.errors[object_method].collect(&:titleize).join(", ")
|
||||
tailwind_label(object_method, {text: error_message, class: " font-bold text-red-500"}, options)
|
||||
tailwind_label(object_method, {text: error_message, class: " font-bold text-right text-bronze"}, options)
|
||||
end
|
||||
end
|
||||
|
||||
def border_color_classes(object_method)
|
||||
if errors_for(object_method).present?
|
||||
" border-2 border-red-400 focus:border-rose-200"
|
||||
" border-4 dark:border-bronze focus:border-atmosphere"
|
||||
else
|
||||
" border border-platinum focus:border-yellow-700"
|
||||
""
|
||||
# " border border-platinum focus:border-yellow-700"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user