Module: BMC::BootstrapHelper
- Included in:
- AllHelpers
- Defined in:
- app/helpers/bmc/bootstrap_helper.rb
Class Attribute Summary collapse
Instance Method Summary collapse
-
#bs_card(header: nil, body: true, footer: nil, card_tag: :div, header_tag: :div, body_tag: :div, footer_tag: :div, card_class: nil, header_class: nil, body_class: nil, footer_class: nil, &block) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- #bs_progress_bar(percentage) ⇒ Object
Class Attribute Details
.bootstrap_version ⇒ Object
16 17 18 |
# File 'app/helpers/bmc/bootstrap_helper.rb', line 16 def bootstrap_version @bootstrap_version ||= Bootstrap::VERSION[0] end |
.card_classes ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'app/helpers/bmc/bootstrap_helper.rb', line 5 def card_classes @card_classes ||= { :card => "card", :header => "card-header", :body => "card-body", :footer => "card-footer", } end |
Instance Method Details
#bs_card(header: nil, body: true, footer: nil, card_tag: :div, header_tag: :div, body_tag: :div, footer_tag: :div, card_class: nil, header_class: nil, body_class: nil, footer_class: nil, &block) ⇒ Object
rubocop:disable Metrics/ParameterLists
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/helpers/bmc/bootstrap_helper.rb', line 31 def bs_card( # rubocop:disable Metrics/ParameterLists header: nil, body: true, footer: nil, card_tag: :div, header_tag: :div, body_tag: :div, footer_tag: :div, card_class: nil, header_class: nil, body_class: nil, footer_class: nil, &block ) global_classes = BMC::BootstrapHelper.card_classes card_classes = ([global_classes[:card]] + card_class.to_s.split).compact.sort header_classes = ([global_classes[:header]] + header_class.to_s.split).compact.sort body_classes = ([global_classes[:body]] + body_class.to_s.split).compact.sort = ([global_classes[:footer]] + .to_s.split).compact.sort if header header_html = content_tag(header_tag, class: header_classes) { header } end if body body_html = content_tag(body_tag, class: body_classes) { capture(&block) } else body_html = capture(&block) end if = content_tag(, class: ) { } end content_tag(card_tag, class: card_classes) do [header_html, body_html, ].compact.sum("".html_safe) end end |
#bs_progress_bar(percentage) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/bmc/bootstrap_helper.rb', line 21 def (percentage) percentage = percentage.round if percentage.respond_to?(:round) tag.div(class: "progress") do tag.div(class: "progress-bar", style: "width:#{percentage}%") do "#{percentage}%" end end end |