Module: BootstrapConcerns::ComponentsHelper
- Defined in:
- lib/bootstrap_concerns/components_helper.rb
Constant Summary collapse
- SEARCH_COL_MARGIN =
"mb-3".freeze
Instance Method Summary collapse
- #assign_icon ⇒ Object
- #boolean_false_icon ⇒ Object
- #boolean_true_icon ⇒ Object
- #bs_button_to(name = nil, options = nil, html_options = nil) ⇒ Object
- #bs_link_or_button_to(method_name, name, options, html_options) ⇒ Object
- #bs_link_to(name = nil, options = nil, html_options = nil) ⇒ Object
- #bs_search_col ⇒ Object
- #bs_search_submit_col ⇒ Object
- #bs_table ⇒ Object
- #copy_icon ⇒ Object
- #delete_icon(text = "Delete") ⇒ Object
- #download_icon ⇒ Object
- #edit_icon ⇒ Object
- #export_icon(label = "Export") ⇒ Object
- #flash_alert_color(key) ⇒ Object
- #icon(name, text) ⇒ Object
- #import_icon ⇒ Object
- #new_icon(label = "New") ⇒ Object
- #rename_icon ⇒ Object
- #search_icon ⇒ Object
Instance Method Details
#assign_icon ⇒ Object
5 6 7 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 5 def assign_icon icon("box-arrow-in-left", "Assign") end |
#boolean_false_icon ⇒ Object
9 10 11 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 9 def boolean_false_icon content_tag(:i, "", class: "bi bi-x-circle-fill") end |
#boolean_true_icon ⇒ Object
13 14 15 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 13 def boolean_true_icon content_tag(:i, "", class: "bi bi-check-circle-fill") end |
#bs_button_to(name = nil, options = nil, html_options = nil) ⇒ Object
17 18 19 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 17 def (name = nil, = nil, = nil, &) (:button_to, name, , , &) end |
#bs_link_or_button_to(method_name, name, options, html_options) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 21 def (method_name, name, , , &) = if block_given? ||= {} else ||= {} end .merge!(Option.()) public_send( method_name, name, , , & ) end |
#bs_link_to(name = nil, options = nil, html_options = nil) ⇒ Object
40 41 42 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 40 def bs_link_to(name = nil, = nil, = nil, &) (:link_to, name, , , &) end |
#bs_search_col ⇒ Object
44 45 46 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 44 def bs_search_col(&) content_tag(:div, class: "col-12 col-sm #{SEARCH_COL_MARGIN}", &) end |
#bs_search_submit_col ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 48 def bs_search_submit_col content_tag(:div, class: "col-auto #{SEARCH_COL_MARGIN}") do content_tag(:button, BootstrapConcerns::Option.) do search_icon end end end |
#bs_table ⇒ Object
103 104 105 106 107 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 103 def bs_table(&) content_tag :div, class: "table-responsive" do content_tag(:table, class: "table table-striped table-sm", &) end end |
#copy_icon ⇒ Object
56 57 58 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 56 def copy_icon icon("files", "Copy") end |
#delete_icon(text = "Delete") ⇒ Object
60 61 62 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 60 def delete_icon(text = "Delete") icon("trash", text) end |
#download_icon ⇒ Object
64 65 66 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 64 def download_icon icon("download", "Download") end |
#edit_icon ⇒ Object
68 69 70 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 68 def edit_icon icon("pencil-square", "Edit") end |
#export_icon(label = "Export") ⇒ Object
72 73 74 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 72 def export_icon(label = "Export") icon("filetype-xlsx", label) end |
#flash_alert_color(key) ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 76 def flash_alert_color(key) case key.to_s when "notice" "success" when "alert" "danger" else key end end |
#icon(name, text) ⇒ Object
87 88 89 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 87 def icon(name, text) content_tag("i", "", class: "bi bi-#{name}") + content_tag(:span, text, class: "ms-1 d-none d-sm-inline") end |
#import_icon ⇒ Object
91 92 93 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 91 def import_icon icon("box-arrow-in-down", "Import") end |
#new_icon(label = "New") ⇒ Object
95 96 97 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 95 def new_icon(label = "New") icon("file-earmark-plus", label) end |
#rename_icon ⇒ Object
99 100 101 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 99 def rename_icon icon("input-cursor-text", "Rename") end |
#search_icon ⇒ Object
109 110 111 |
# File 'lib/bootstrap_concerns/components_helper.rb', line 109 def search_icon icon("search", "Search") end |