diff options
Diffstat (limited to 'app/helpers/dropdowns_helper.rb')
-rw-r--r-- | app/helpers/dropdowns_helper.rb | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/app/helpers/dropdowns_helper.rb b/app/helpers/dropdowns_helper.rb index 8d8c62f1291..890d506d6c5 100644 --- a/app/helpers/dropdowns_helper.rb +++ b/app/helpers/dropdowns_helper.rb @@ -3,7 +3,7 @@ module DropdownsHelper def dropdown_tag(toggle_text, options: {}, &block) content_tag :div, class: "dropdown #{options[:wrapper_class] if options.key?(:wrapper_class)}" do - data_attr = { toggle: "dropdown" } + data_attr = {toggle: "dropdown"} if options.key?(:data) data_attr = options[:data].merge(data_attr) @@ -15,7 +15,7 @@ module DropdownsHelper dropdown_output = dropdown_toggle_link(toggle_text, data_attr, options) end - dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.key?(:dropdown_class)}") do + dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.key?(:dropdown_class)}") { output = [] if options.key?(:title) @@ -26,19 +26,19 @@ module DropdownsHelper output << dropdown_filter(options[:placeholder]) end - output << content_tag(:div, class: "dropdown-content #{options[:content_class] if options.key?(:content_class)}") do + output << content_tag(:div, class: "dropdown-content #{options[:content_class] if options.key?(:content_class)}") { capture(&block) if block && !options.key?(:footer_content) - end + } if block && options[:footer_content] - output << content_tag(:div, class: "dropdown-footer") do + output << content_tag(:div, class: "dropdown-footer") { capture(&block) - end + } end output << dropdown_loading output.join.html_safe - end + } dropdown_output.html_safe end @@ -47,8 +47,8 @@ module DropdownsHelper def dropdown_toggle(toggle_text, data_attr, options = {}) default_label = data_attr[:default_label] content_tag(:button, disabled: options[:disabled], class: "dropdown-menu-toggle #{options[:toggle_class] if options.key?(:toggle_class)}", id: (options[:id] if options.key?(:id)), type: "button", data: data_attr) do - output = content_tag(:span, toggle_text, class: "dropdown-toggle-text #{'is-default' if toggle_text == default_label}") - output << icon('chevron-down') + output = content_tag(:span, toggle_text, class: "dropdown-toggle-text #{"is-default" if toggle_text == default_label}") + output << icon("chevron-down") output.html_safe end end @@ -63,17 +63,17 @@ module DropdownsHelper title_output = [] if options.fetch(:back, false) - title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-back", aria: { label: "Go back" }, type: "button") do - icon('arrow-left') - end + title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-back", aria: {label: "Go back"}, type: "button") { + icon("arrow-left") + } end title_output << content_tag(:span, title) if options.fetch(:close, true) - title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-close", aria: { label: "Close" }, type: "button") do - icon('times', class: 'dropdown-menu-close-icon') - end + title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-close", aria: {label: "Close"}, type: "button") { + icon("times", class: "dropdown-menu-close-icon") + } end title_output.join.html_safe @@ -82,8 +82,8 @@ module DropdownsHelper def dropdown_input(placeholder, input_id: nil) content_tag :div, class: "dropdown-input" do - filter_output = text_field_tag input_id, nil, class: "dropdown-input-field dropdown-no-filter", placeholder: placeholder, autocomplete: 'off' - filter_output << icon('times', class: "dropdown-input-clear js-dropdown-input-clear", role: "button") + filter_output = text_field_tag input_id, nil, class: "dropdown-input-field dropdown-no-filter", placeholder: placeholder, autocomplete: "off" + filter_output << icon("times", class: "dropdown-input-clear js-dropdown-input-clear", role: "button") filter_output.html_safe end @@ -91,9 +91,9 @@ module DropdownsHelper def dropdown_filter(placeholder, search_id: nil) content_tag :div, class: "dropdown-input" do - filter_output = search_field_tag search_id, nil, class: "dropdown-input-field", placeholder: placeholder, autocomplete: 'off' - filter_output << icon('search', class: "dropdown-input-search") - filter_output << icon('times', class: "dropdown-input-clear js-dropdown-input-clear", role: "button") + filter_output = search_field_tag search_id, nil, class: "dropdown-input-field", placeholder: placeholder, autocomplete: "off" + filter_output << icon("search", class: "dropdown-input-search") + filter_output << icon("times", class: "dropdown-input-clear js-dropdown-input-clear", role: "button") filter_output.html_safe end @@ -119,7 +119,7 @@ module DropdownsHelper def dropdown_loading content_tag :div, class: "dropdown-loading" do - icon('spinner spin') + icon("spinner spin") end end end |