bh 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/CHANGELOG.md +19 -0
  4. data/README.md +51 -18
  5. data/bh.gemspec +13 -9
  6. data/examples/middleman/.gitignore +18 -0
  7. data/examples/middleman/Gemfile +6 -0
  8. data/examples/middleman/config.rb +1 -0
  9. data/examples/middleman/source/index.html.erb +158 -0
  10. data/examples/padrino/Gemfile +9 -0
  11. data/examples/padrino/app/app.rb +16 -0
  12. data/examples/padrino/app/views/index.html.erb +155 -0
  13. data/examples/padrino/config.ru +5 -0
  14. data/examples/padrino/config/apps.rb +5 -0
  15. data/examples/padrino/config/boot.rb +8 -0
  16. data/examples/rails/.gitignore +12 -0
  17. data/examples/rails/Gemfile +5 -0
  18. data/examples/rails/app/controllers/application_controller.rb +6 -0
  19. data/examples/rails/app/controllers/users_controller.rb +2 -0
  20. data/examples/rails/app/models/user.rb +15 -0
  21. data/examples/rails/app/views/application/index.html.erb +160 -0
  22. data/examples/rails/bin/rails +4 -0
  23. data/examples/rails/config.ru +4 -0
  24. data/examples/rails/config/application.rb +12 -0
  25. data/examples/rails/config/boot.rb +3 -0
  26. data/examples/rails/config/environment.rb +5 -0
  27. data/examples/rails/config/environments/development.rb +7 -0
  28. data/examples/rails/config/routes.rb +4 -0
  29. data/examples/rails/config/secrets.yml +22 -0
  30. data/examples/rails/log/.keep +0 -0
  31. data/gemfiles/Gemfile.rails-3.x +2 -0
  32. data/gemfiles/Gemfile.rails-4.x +2 -0
  33. data/lib/bh.rb +15 -4
  34. data/lib/bh/classes/alert_box.rb +35 -0
  35. data/lib/bh/classes/base.rb +125 -0
  36. data/lib/bh/classes/button.rb +58 -0
  37. data/lib/bh/classes/button_to.rb +33 -0
  38. data/lib/bh/classes/cdn.rb +35 -0
  39. data/lib/bh/classes/dropdown.rb +56 -0
  40. data/lib/bh/classes/icon.rb +34 -0
  41. data/lib/bh/classes/link_to.rb +22 -0
  42. data/lib/bh/classes/modal.rb +68 -0
  43. data/lib/bh/classes/nav.rb +37 -0
  44. data/lib/bh/classes/navbar.rb +78 -0
  45. data/lib/bh/classes/panel.rb +72 -0
  46. data/lib/bh/classes/panel_row.rb +13 -0
  47. data/lib/bh/classes/progress_bar.rb +89 -0
  48. data/lib/bh/classes/stack.rb +19 -0
  49. data/lib/bh/classes/vertical.rb +27 -0
  50. data/lib/bh/core_ext/middleman.rb +24 -0
  51. data/lib/bh/core_ext/padrino.rb +25 -0
  52. data/lib/bh/core_ext/rails/base_helper.rb +21 -0
  53. data/lib/bh/{helpers → core_ext/rails}/form/base_helper.rb +3 -1
  54. data/lib/bh/{helpers → core_ext/rails}/form/check_box_helper.rb +1 -1
  55. data/lib/bh/{helpers → core_ext/rails}/form/field_helper.rb +1 -1
  56. data/lib/bh/{helpers → core_ext/rails}/form/fields_for_helper.rb +1 -1
  57. data/lib/bh/{helpers → core_ext/rails}/form/fieldset_helper.rb +1 -1
  58. data/lib/bh/{helpers → core_ext/rails}/form/file_field_helper.rb +1 -1
  59. data/lib/bh/{helpers → core_ext/rails}/form/legend_helper.rb +1 -1
  60. data/lib/bh/{helpers → core_ext/rails}/form/radio_button_helper.rb +1 -1
  61. data/lib/bh/{helpers → core_ext/rails}/form/select_helper.rb +1 -1
  62. data/lib/bh/{helpers → core_ext/rails}/form/static_control_helper.rb +1 -1
  63. data/lib/bh/{helpers → core_ext/rails}/form/submit_helper.rb +1 -1
  64. data/lib/bh/{form_builders → core_ext/rails}/form_builder.rb +11 -10
  65. data/lib/bh/core_ext/rails/form_for_helper.rb +32 -0
  66. data/lib/bh/core_ext/railtie.rb +27 -0
  67. data/lib/bh/helpers/alert_box_helper.rb +40 -0
  68. data/lib/bh/helpers/button_helper.rb +35 -58
  69. data/lib/bh/helpers/button_to_helper.rb +48 -10
  70. data/lib/bh/helpers/cdn_helper.rb +11 -35
  71. data/lib/bh/helpers/dropdown_helper.rb +29 -62
  72. data/lib/bh/helpers/glyphicon_helper.rb +7 -13
  73. data/lib/bh/helpers/horizontal_helper.rb +35 -0
  74. data/lib/bh/helpers/icon_helper.rb +15 -29
  75. data/lib/bh/helpers/link_to_helper.rb +52 -41
  76. data/lib/bh/helpers/modal_helper.rb +49 -79
  77. data/lib/bh/helpers/nav_helper.rb +25 -40
  78. data/lib/bh/helpers/navbar_helper.rb +36 -170
  79. data/lib/bh/helpers/panel_helper.rb +45 -72
  80. data/lib/bh/helpers/panel_row_helper.rb +20 -38
  81. data/lib/bh/helpers/progress_bar_helper.rb +48 -59
  82. data/lib/bh/helpers/vertical_helper.rb +33 -0
  83. data/lib/bh/version.rb +1 -1
  84. data/lib/bh/views/bh/_alert_dismiss_button.html +4 -0
  85. data/lib/bh/views/bh/_dropdown.html.erb +5 -5
  86. data/lib/bh/views/bh/_dropdown_split.html.erb +5 -5
  87. data/lib/bh/views/bh/_modal.html.erb +5 -8
  88. data/lib/bh/views/bh/_navbar.html.erb +5 -0
  89. data/spec/padrino/button_to_helper.rb +35 -0
  90. data/spec/padrino_spec.rb +28 -0
  91. data/spec/rails/button_to_helper.rb +31 -0
  92. data/spec/{helpers → rails}/form/check_box_helper_spec.rb +3 -3
  93. data/spec/{helpers → rails}/form/field_helper_spec.rb +3 -3
  94. data/spec/{helpers → rails}/form/fields_for_helper_spec.rb +3 -3
  95. data/spec/{helpers → rails}/form/fieldset_helper_spec.rb +3 -3
  96. data/spec/{helpers → rails}/form/file_field_helper_spec.rb +3 -3
  97. data/spec/{helpers → rails}/form/legend_helper_spec.rb +3 -3
  98. data/spec/{helpers → rails}/form/radio_button_helper_spec.rb +3 -3
  99. data/spec/{helpers → rails}/form/select_helper_spec.rb +3 -3
  100. data/spec/{helpers → rails}/form/static_control_helper_spec.rb +3 -3
  101. data/spec/{helpers → rails}/form/submit_helper_spec.rb +3 -3
  102. data/spec/{helpers → rails}/form_for_helper_spec.rb +3 -3
  103. data/spec/rails_helper.rb +25 -0
  104. data/spec/rails_spec.rb +28 -0
  105. data/spec/shared/alert_box_helper.rb +62 -0
  106. data/spec/shared/button_helper.rb +52 -0
  107. data/spec/shared/button_to_helper.rb +42 -0
  108. data/spec/shared/cdn_helper.rb +36 -0
  109. data/spec/shared/dropdown_helper.rb +112 -0
  110. data/spec/shared/glyphicon_helper.rb +21 -0
  111. data/spec/shared/horizontal_helper.rb +37 -0
  112. data/spec/shared/icon_helper.rb +31 -0
  113. data/spec/shared/link_to_helper.rb +62 -0
  114. data/spec/shared/modal_helper.rb +104 -0
  115. data/spec/shared/nav_helper.rb +49 -0
  116. data/spec/shared/navbar_helper.rb +63 -0
  117. data/spec/shared/panel_helper.rb +76 -0
  118. data/spec/shared/panel_row_helper.rb +21 -0
  119. data/spec/shared/progress_bar_helper.rb +103 -0
  120. data/spec/shared/vertical_helper.rb +43 -0
  121. data/spec/spec_helper.rb +6 -29
  122. data/spec/support/matchers.rb +38 -0
  123. data/spec/support/padrino.rb +33 -0
  124. data/spec/support/rails.rb +27 -0
  125. metadata +183 -94
  126. data/config.rb +0 -6
  127. data/lib/bh/helpers/alert_helper.rb +0 -77
  128. data/lib/bh/helpers/base_helper.rb +0 -39
  129. data/lib/bh/helpers/form_for_helper.rb +0 -30
  130. data/lib/bh/middleman.rb +0 -39
  131. data/lib/bh/railtie.rb +0 -42
  132. data/spec/dummy/index.html.erb +0 -60
  133. data/spec/dummy/layouts/default.erb +0 -17
  134. data/spec/helpers/alert_helper_spec.rb +0 -84
  135. data/spec/helpers/button_helper_spec.rb +0 -100
  136. data/spec/helpers/button_to_helper_spec.rb +0 -25
  137. data/spec/helpers/cdn_helper_spec.rb +0 -100
  138. data/spec/helpers/dropdown_helper_spec.rb +0 -146
  139. data/spec/helpers/glyphicon_helper_spec.rb +0 -21
  140. data/spec/helpers/icon_helper_spec.rb +0 -45
  141. data/spec/helpers/link_to_helper_spec.rb +0 -124
  142. data/spec/helpers/modal_helper_spec.rb +0 -133
  143. data/spec/helpers/nav_helper_spec.rb +0 -53
  144. data/spec/helpers/navbar_helper_spec.rb +0 -194
  145. data/spec/helpers/panel_helper_spec.rb +0 -95
  146. data/spec/helpers/panel_row_helper_spec.rb +0 -27
  147. data/spec/helpers/progress_bar_helper_spec.rb +0 -114
@@ -0,0 +1,13 @@
1
+ require 'bh/classes/base'
2
+
3
+ module Bh
4
+ module Classes
5
+ class PanelRow < Base
6
+ # @return [#to_s] the grid-related class to assign to each panel
7
+ # nested in this panel row.
8
+ def column_class
9
+ @options[:column_class]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,89 @@
1
+ require 'bh/classes/base'
2
+
3
+ module Bh
4
+ module Classes
5
+ class ProgressBar < Base
6
+ # @return [#to_s] the context-related class to assign to the progress bar.
7
+ def context_class
8
+ ProgressBar.contexts[@options[:context]]
9
+ end
10
+
11
+ # @return [#to_s] the class to assign to make the progress bar striped.
12
+ def striped_class
13
+ ProgressBar.stripes[@options[:striped]]
14
+ end
15
+
16
+ # @return [#to_s] the class to assign to make the progress bar aniamted.
17
+ def animated_class
18
+ ProgressBar.animations[@options[:animated]]
19
+ end
20
+
21
+ # @return [#to_s] the text to display as the label of the progress bar.
22
+ def label
23
+ labels[@options.fetch :label, false] || @options[:label]
24
+ end
25
+
26
+ def aria_values
27
+ {}.tap do |values|
28
+ values[:'aria-valuemax'] = 100
29
+ values[:'aria-valuemin'] = 0
30
+ values[:'aria-valuenow'] = percentage
31
+ end
32
+ end
33
+
34
+ def values
35
+ {}.tap do |values|
36
+ values[:role] = :progressbar
37
+ values[:style] = "width: #{percentage}%"
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ # @return [Hash<Symbol, String>] the classes that Bootstrap requires to
44
+ # append to the progress bar for each possible context.
45
+ def self.contexts
46
+ HashWithIndifferentAccess.new.tap do |klass|
47
+ klass[:danger] = :'progress-bar-danger'
48
+ klass[:info] = :'progress-bar-info'
49
+ klass[:success] = :'progress-bar-success'
50
+ klass[:warning] = :'progress-bar-warning'
51
+ end
52
+ end
53
+
54
+ # @return [Hash<Symbol, String>] the classes that Bootstrap requires to
55
+ # append to the progress bar to make it look striped.
56
+ def self.stripes
57
+ HashWithIndifferentAccess.new.tap do |klass|
58
+ klass[true] = :'progress-bar-striped'
59
+ end
60
+ end
61
+
62
+ # @return [Hash<Symbol, String>] the classes that Bootstrap requires to
63
+ # append to the progress bar to make it look animated.
64
+ def self.animations
65
+ HashWithIndifferentAccess.new.tap do |klass|
66
+ klass[true] = :'progress-bar-striped active'
67
+ end
68
+ end
69
+
70
+ # @return [Hash<Symbol, String>] the texts to uses as labels.
71
+ def labels
72
+ HashWithIndifferentAccess.new.tap do |label|
73
+ label[true] = text
74
+ label[false] = @app.content_tag(:span, text, class: 'sr-only')
75
+ end
76
+ end
77
+
78
+ def percentage
79
+ @options.fetch :percentage, 0
80
+ end
81
+
82
+ def text
83
+ "#{percentage}%".tap do |text|
84
+ text << " (#{@options[:context]})" if @options[:context]
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,19 @@
1
+ module Bh
2
+ module Classes
3
+ class Stack
4
+ @@stack = []
5
+
6
+ def self.unshift(item)
7
+ @@stack.unshift item
8
+ end
9
+
10
+ def self.shift
11
+ @@stack.shift
12
+ end
13
+
14
+ def self.find(helper_class)
15
+ @@stack.find{|helper| helper.is_a? helper_class}
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ require 'bh/classes/base'
2
+
3
+ module Bh
4
+ module Classes
5
+ class Vertical < Base
6
+ def toggle_button(navbar_id, options = {})
7
+ options[:'class'] = :'navbar-toggle'
8
+ options[:'data-target'] = :"##{navbar_id}"
9
+ options[:'data-toggle'] = :'collapse'
10
+ options[:'type'] = :'button'
11
+ @app.content_tag :button, options do
12
+ safe_join [toggle_text, toggle_bar, toggle_bar, toggle_bar]
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def toggle_text
19
+ @app.content_tag :span, 'Toggle navigation', class: :'sr-only'
20
+ end
21
+
22
+ def toggle_bar
23
+ @app.content_tag :span, nil, class: :'icon-bar'
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ module Bh
2
+ # @api private
3
+ # Provides methods to register Bh in third-party applications.
4
+ module Extensions
5
+ # Makes Bootstrap helpers available in Middleman applications.
6
+ #
7
+ # To use Bh in a Middleman app you need 2 steps:
8
+ #
9
+ # - include bh in the Gemfile
10
+ # - add `activate :bh` in the `config.rb` file
11
+ #
12
+ # The following class is registered as a Middleman extension, but you still
13
+ # need to activate it in the configuration file to make helpers available.
14
+ class MiddlemanExtension < Middleman::Extension
15
+ helpers do
16
+ include Bh::Helpers
17
+ end
18
+ end
19
+ end
20
+
21
+ Bh.framework = :middleman
22
+ end
23
+
24
+ ::Middleman::Extensions.register(:bh, Bh::Extensions::MiddlemanExtension)
@@ -0,0 +1,25 @@
1
+ module Bh
2
+ module Extensions
3
+ # Makes Bootstrap helpers available in Padrino applications.
4
+ #
5
+ # To use Bh in a Padrino app you need 2 steps:
6
+ #
7
+ # - include bh in the Gemfile
8
+ # - add `register Bh` in the `app.rb` file
9
+ #
10
+ # The following method adds `Bh` as one of the modules that can be registered
11
+ # in a Padrino app, but you still need to register it manually in order to
12
+ # make helpers available.
13
+ module Padrino
14
+ # Register Bh as a Padrino app.
15
+ def registered(app)
16
+ app.include Bh::Helpers
17
+ end
18
+ end
19
+
20
+ Bh.framework = :padrino
21
+ end
22
+
23
+ # Allows to register Bh in a Padrino app simply with `register Bh`.
24
+ extend Extensions::Padrino
25
+ end
@@ -0,0 +1,21 @@
1
+ require 'action_view'
2
+
3
+ module Bh
4
+ module Rails
5
+ # @api private
6
+ module BaseHelper
7
+ include ActionView::Helpers::TagHelper # for content_tag
8
+ include ActionView::Context # for capture
9
+ include ActionView::Helpers::OutputSafetyHelper # for safe_join
10
+ include ActionView::Helpers::RenderingHelper # for render
11
+ include ActionView::Helpers::UrlHelper # for link_to
12
+
13
+ private
14
+
15
+ def append_class!(hash, new_class, attribute = :class)
16
+ existing_class = hash[attribute]
17
+ hash[attribute] = [existing_class, new_class].compact.join ' '
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,9 +1,11 @@
1
+ require 'bh/core_ext/rails/base_helper'
1
2
  require 'bh/helpers/glyphicon_helper'
2
3
 
3
4
  module Bh
4
5
  module Form
5
6
  module BaseHelper
6
- include GlyphiconHelper # for glyphicon
7
+ include Bh::Rails::BaseHelper
8
+ include Bh::Helpers
7
9
 
8
10
  private
9
11
 
@@ -1,4 +1,4 @@
1
- require 'bh/helpers/form/base_helper'
1
+ require 'bh/core_ext/rails/form/base_helper'
2
2
 
3
3
  module Bh
4
4
  module Form
@@ -1,4 +1,4 @@
1
- require 'bh/helpers/form/base_helper'
1
+ require 'bh/core_ext/rails/form/base_helper'
2
2
 
3
3
  module Bh
4
4
  module Form
@@ -1,4 +1,4 @@
1
- require 'bh/helpers/form/fieldset_helper'
1
+ require 'bh/core_ext/rails/form/fieldset_helper'
2
2
 
3
3
  module Bh
4
4
  module Form
@@ -4,7 +4,7 @@ module Bh
4
4
  module Form
5
5
  module FieldsetHelper
6
6
  include BaseHelper
7
- include PanelHelper # for panel
7
+ include Bh::Helpers # for panel
8
8
 
9
9
  def fieldset(title = nil, &block)
10
10
  options = {tag: :fieldset, body: @template.capture(&block)}
@@ -1,4 +1,4 @@
1
- require 'bh/helpers/form/base_helper'
1
+ require 'bh/core_ext/rails/form/base_helper'
2
2
 
3
3
  module Bh
4
4
  module Form
@@ -1,4 +1,4 @@
1
- require 'bh/helpers/form/base_helper'
1
+ require 'bh/core_ext/rails/form/base_helper'
2
2
 
3
3
  module Bh
4
4
  module Form
@@ -1,4 +1,4 @@
1
- require 'bh/helpers/form/base_helper'
1
+ require 'bh/core_ext/rails/form/base_helper'
2
2
 
3
3
  module Bh
4
4
  module Form
@@ -1,4 +1,4 @@
1
- require 'bh/helpers/form/base_helper'
1
+ require 'bh/core_ext/rails/form/base_helper'
2
2
 
3
3
  module Bh
4
4
  module Form
@@ -1,4 +1,4 @@
1
- require 'bh/helpers/form/base_helper'
1
+ require 'bh/core_ext/rails/form/base_helper'
2
2
 
3
3
  module Bh
4
4
  module Form
@@ -1,4 +1,4 @@
1
- require 'bh/helpers/form/base_helper'
1
+ require 'bh/core_ext/rails/form/base_helper'
2
2
 
3
3
  module Bh
4
4
  module Form
@@ -1,15 +1,16 @@
1
- require 'bh/helpers/form/check_box_helper'
2
- require 'bh/helpers/form/field_helper'
3
- require 'bh/helpers/form/fieldset_helper'
4
- require 'bh/helpers/form/fields_for_helper'
5
- require 'bh/helpers/form/file_field_helper'
6
- require 'bh/helpers/form/legend_helper'
7
- require 'bh/helpers/form/radio_button_helper'
8
- require 'bh/helpers/form/select_helper'
9
- require 'bh/helpers/form/static_control_helper'
10
- require 'bh/helpers/form/submit_helper'
1
+ require 'bh/core_ext/rails/form/check_box_helper'
2
+ require 'bh/core_ext/rails/form/field_helper'
3
+ require 'bh/core_ext/rails/form/fieldset_helper'
4
+ require 'bh/core_ext/rails/form/fields_for_helper'
5
+ require 'bh/core_ext/rails/form/file_field_helper'
6
+ require 'bh/core_ext/rails/form/legend_helper'
7
+ require 'bh/core_ext/rails/form/radio_button_helper'
8
+ require 'bh/core_ext/rails/form/select_helper'
9
+ require 'bh/core_ext/rails/form/static_control_helper'
10
+ require 'bh/core_ext/rails/form/submit_helper'
11
11
 
12
12
  module Bh
13
+ # @api private
13
14
  class FormBuilder < ActionView::Helpers::FormBuilder
14
15
  include Form::CheckBoxHelper
15
16
  include Form::FieldHelper
@@ -0,0 +1,32 @@
1
+ require 'bh/core_ext/rails/base_helper'
2
+ require 'bh/core_ext/rails/form_builder'
3
+
4
+ module Bh
5
+ module Rails
6
+ module Helpers
7
+ include BaseHelper
8
+ include ActionView::Helpers::FormHelper # for form_for
9
+
10
+ def form_for(record, options = {}, &block)
11
+ add_form_options!(options) if options[:layout]
12
+ super record, options, &block
13
+ end
14
+
15
+ private
16
+
17
+ def add_form_options!(options)
18
+ options[:html] ||= {}
19
+ options[:html].merge! role: 'form'
20
+ append_class! options[:html], class_for(options[:layout])
21
+ options.merge! builder: FormBuilder
22
+ end
23
+
24
+ def class_for(layout)
25
+ case layout.to_s
26
+ when 'inline' then 'form-inline'
27
+ when 'horizontal' then 'form-horizontal'
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ require 'bh/core_ext/rails/form_for_helper'
2
+
3
+ module Bh
4
+ module Extensions
5
+ # Makes Bootstrap helpers available in Rails applications.
6
+ #
7
+ # To use Bh in a Rails app you need 1 step:
8
+ #
9
+ # - include bh in the Gemfile
10
+ #
11
+ # The current class is loaded during the initialization process, so
12
+ # there is no need to manually require any other file.
13
+ class Railtie < ::Rails::Railtie
14
+ initializer 'bh.add_helpers' do
15
+ ActionView::Base.send :include, Bh::Helpers
16
+ ActionView::Base.send :include, Bh::Rails::Helpers
17
+ end
18
+
19
+ initializer 'bh.add_views' do |app|
20
+ views_path = File.expand_path '../../views', __FILE__
21
+ ActionController::Base.prepend_view_path views_path
22
+ end
23
+ end
24
+ end
25
+
26
+ Bh.framework = :rails
27
+ end
@@ -0,0 +1,40 @@
1
+ require 'bh/classes/alert_box'
2
+
3
+ module Bh
4
+ module Helpers
5
+ # Displays a Bootstrap-styled alert message.
6
+ # @see http://getbootstrap.com/components/#alerts
7
+ # @return [String] the HTML to display a Bootstrap-styled alert message.
8
+ # @overload alert_box(content, options = {})
9
+ # @param [#to_s] content the content to display in the alert.
10
+ # @param [Hash] options the options for the alert box. Any option not
11
+ # listed below is passed as an HTML attribute to the alert’s `<div>`.
12
+ # @option options [Boolean] :dismissible (false) whether to display an
13
+ # '×' to the right of the box that can be clicked to dismiss the alert.
14
+ # @option options [#to_s] :context (:info) the contextual alternative to
15
+ # apply to the alert. Can be `:danger`, `:info`, `:success` or
16
+ # `:warning`.
17
+ # @option options [#to_s] :priority if set to one of the priority levels
18
+ # of Rails flash contents, determines the context of the alert box.
19
+ # Can be :alert or :notice.
20
+ # @example Display a dismissible alert box with a plain-text content.
21
+ # alert_box 'User updated successfully', dismissible: true
22
+ # @overload alert_box(options = {}, &block)
23
+ # @param [Hash] options the options for the alert box (see above).
24
+ # @yieldreturn [#to_s] the content to display in the alert.
25
+ # @example Display a success alert box with an HTML content.
26
+ # alert_box context: :success do
27
+ # content_tag :strong, 'User updated successfully'
28
+ # end
29
+ def alert_box(*args, &block)
30
+ alert_box = Bh::AlertBox.new(self, *args, &block)
31
+ alert_box.extract! :context, :priority, :dismissible
32
+
33
+ alert_box.append_class! :alert
34
+ alert_box.append_class! alert_box.context_class
35
+ alert_box.merge! role: :alert
36
+ alert_box.prepend_html! alert_box.dismissible_button
37
+ alert_box.render_tag :div
38
+ end
39
+ end
40
+ end