bh 1.3.5 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +8 -138
  4. data/app/assets/stylesheets/bh.css +29 -0
  5. data/app/javascript/controllers/bh/theme_controller.js +17 -0
  6. data/app/views/bh/_grid.html.erb +6 -0
  7. data/app/views/bh/_table.html.erb +46 -0
  8. data/bh.gemspec +5 -31
  9. data/gemfiles/Gemfile.rails-3.x +0 -1
  10. data/lib/bh/bootstrap_helpers.rb +131 -0
  11. data/lib/bh/engine.rb +13 -0
  12. data/lib/bh/version.rb +3 -1
  13. data/lib/bh.rb +6 -14
  14. data/spec/spec_helper.rb +1 -1
  15. metadata +14 -298
  16. data/examples/middleman/.gitignore +0 -18
  17. data/examples/middleman/Gemfile +0 -6
  18. data/examples/middleman/config.rb +0 -1
  19. data/examples/middleman/source/index.html.erb +0 -158
  20. data/examples/padrino/Gemfile +0 -9
  21. data/examples/padrino/app/app.rb +0 -16
  22. data/examples/padrino/app/views/index.html.erb +0 -155
  23. data/examples/padrino/config/apps.rb +0 -5
  24. data/examples/padrino/config/boot.rb +0 -8
  25. data/examples/padrino/config.ru +0 -5
  26. data/examples/rails/.gitignore +0 -12
  27. data/examples/rails/Gemfile +0 -5
  28. data/examples/rails/app/controllers/application_controller.rb +0 -6
  29. data/examples/rails/app/controllers/users_controller.rb +0 -2
  30. data/examples/rails/app/models/user.rb +0 -15
  31. data/examples/rails/app/views/application/index.html.erb +0 -160
  32. data/examples/rails/bin/rails +0 -4
  33. data/examples/rails/config/application.rb +0 -12
  34. data/examples/rails/config/boot.rb +0 -3
  35. data/examples/rails/config/environment.rb +0 -5
  36. data/examples/rails/config/environments/development.rb +0 -7
  37. data/examples/rails/config/routes.rb +0 -4
  38. data/examples/rails/config/secrets.yml +0 -22
  39. data/examples/rails/config.ru +0 -4
  40. data/examples/rails/log/.keep +0 -0
  41. data/lib/bh/classes/alert_box.rb +0 -35
  42. data/lib/bh/classes/base.rb +0 -125
  43. data/lib/bh/classes/button.rb +0 -58
  44. data/lib/bh/classes/button_to.rb +0 -33
  45. data/lib/bh/classes/cdn.rb +0 -35
  46. data/lib/bh/classes/dropdown.rb +0 -56
  47. data/lib/bh/classes/icon.rb +0 -34
  48. data/lib/bh/classes/link_to.rb +0 -26
  49. data/lib/bh/classes/modal.rb +0 -68
  50. data/lib/bh/classes/nav.rb +0 -37
  51. data/lib/bh/classes/navbar.rb +0 -78
  52. data/lib/bh/classes/panel.rb +0 -72
  53. data/lib/bh/classes/panel_row.rb +0 -13
  54. data/lib/bh/classes/progress_bar.rb +0 -89
  55. data/lib/bh/classes/stack.rb +0 -19
  56. data/lib/bh/classes/vertical.rb +0 -27
  57. data/lib/bh/core_ext/middleman.rb +0 -24
  58. data/lib/bh/core_ext/padrino.rb +0 -25
  59. data/lib/bh/core_ext/rails/base_helper.rb +0 -21
  60. data/lib/bh/core_ext/rails/form/base_helper.rb +0 -150
  61. data/lib/bh/core_ext/rails/form/check_box_helper.rb +0 -35
  62. data/lib/bh/core_ext/rails/form/field_helper.rb +0 -15
  63. data/lib/bh/core_ext/rails/form/fields_for_helper.rb +0 -23
  64. data/lib/bh/core_ext/rails/form/fieldset_helper.rb +0 -16
  65. data/lib/bh/core_ext/rails/form/file_field_helper.rb +0 -15
  66. data/lib/bh/core_ext/rails/form/legend_helper.rb +0 -17
  67. data/lib/bh/core_ext/rails/form/radio_button_helper.rb +0 -19
  68. data/lib/bh/core_ext/rails/form/select_helper.rb +0 -16
  69. data/lib/bh/core_ext/rails/form/static_control_helper.rb +0 -43
  70. data/lib/bh/core_ext/rails/form/submit_helper.rb +0 -23
  71. data/lib/bh/core_ext/rails/form_builder.rb +0 -46
  72. data/lib/bh/core_ext/rails/form_for_helper.rb +0 -41
  73. data/lib/bh/core_ext/railtie.rb +0 -27
  74. data/lib/bh/helpers/alert_box_helper.rb +0 -40
  75. data/lib/bh/helpers/button_helper.rb +0 -40
  76. data/lib/bh/helpers/button_to_helper.rb +0 -65
  77. data/lib/bh/helpers/cdn_helper.rb +0 -46
  78. data/lib/bh/helpers/dropdown_helper.rb +0 -49
  79. data/lib/bh/helpers/glyphicon_helper.rb +0 -18
  80. data/lib/bh/helpers/horizontal_helper.rb +0 -35
  81. data/lib/bh/helpers/icon_helper.rb +0 -27
  82. data/lib/bh/helpers/link_to_helper.rb +0 -59
  83. data/lib/bh/helpers/modal_helper.rb +0 -55
  84. data/lib/bh/helpers/nav_helper.rb +0 -36
  85. data/lib/bh/helpers/navbar_helper.rb +0 -48
  86. data/lib/bh/helpers/panel_helper.rb +0 -53
  87. data/lib/bh/helpers/panel_row_helper.rb +0 -28
  88. data/lib/bh/helpers/progress_bar_helper.rb +0 -55
  89. data/lib/bh/helpers/vertical_helper.rb +0 -33
  90. data/lib/bh/views/bh/_alert_dismiss_button.html +0 -4
  91. data/lib/bh/views/bh/_dropdown.html.erb +0 -9
  92. data/lib/bh/views/bh/_dropdown_split.html.erb +0 -10
  93. data/lib/bh/views/bh/_modal.html.erb +0 -14
  94. data/lib/bh/views/bh/_navbar.html.erb +0 -5
@@ -1,65 +0,0 @@
1
- require 'bh/classes/button_to'
2
- require 'bh/classes/navbar'
3
- require 'bh/classes/stack'
4
-
5
- module Bh
6
- module Helpers
7
- # Overrides `button_to` to display a Bootstrap-styled button.
8
- # Can only be used in Ruby frameworks that provide the `button_to` method.
9
- # Only overrides the original method if called with any of the `:context`,
10
- # `:size` or `:layout` option, otherwise calls the original method.
11
- # @see http://getbootstrap.com/css/#buttons
12
- # @see http://getbootstrap.com/components/#nav
13
- # @see http://getbootstrap.com/components/#navbar-buttons
14
- # @see http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to
15
- # @see http://rubydoc.info/gems/padrino-helpers/Padrino/Helpers/FormHelpers#button_to-instance_method
16
- # @return [String] the HTML to display a Bootstrap-styled button.
17
- # @overload button_to(caption, url, options = {})
18
- # @param [#to_s] caption the caption to display in the button.
19
- # @param [#to_s] url the URL to submit to.
20
- # @param [Hash] options the options for the button. Any option not
21
- # listed below is passed to the original `button_to` method.
22
- # @option options [#to_s] :context (:default) the contextual alternative
23
- # to apply to the button. Can be `:danger`, `:info`, `:link`,
24
- # `:primary`, `:success` or `:warning`.
25
- # @option options [#to_s] :size the size of the button.
26
- # Can be `:extra_small` (alias `:xs`), `:large` (alias `:lg`) or
27
- # `:small` (alias `:sm`).
28
- # @option options [#to_s] :layout if set to `:block`, span the button
29
- # for the full width of the parent.
30
- # @example Display a small button to submit to '/create_user'.
31
- # button_to 'Create', '/create_user', size: :small
32
- # @overload button_to(url, options = {}, &block)
33
- # @param [#to_s] url the URL to submit to (see above).
34
- # @param [Hash] options the options for the button (see above).
35
- # @yieldreturn [#to_s] the caption to display in the button.
36
- # @example Display a danger button with HTML content to delete a user.
37
- # button_to '/user_destroy', context: :danger do
38
- # content_tag :strong, "Delete user"
39
- # end
40
- def button_to(*args, &block)
41
- button_to = Bh::ButtonTo.new self, *args, &block
42
-
43
- if button_to.extract! :context, :size, :layout
44
- button_to.append_button_class! :btn
45
- button_to.append_button_class! button_to.context_class
46
- button_to.append_button_class! button_to.size_class
47
- button_to.append_button_class! button_to.layout_class
48
- button_to.append_form_class! 'navbar-form' if Bh::Stack.find(Bh::Navbar)
49
- end
50
-
51
- html = if block_given? && button_to.accepts_block?
52
- super button_to.url, button_to.attributes, &-> { button_to.content }
53
- else
54
- super button_to.content, button_to.url, button_to.attributes, &nil
55
- end
56
-
57
- if Bh::Stack.find(Bh::Nav)
58
- container = Bh::Base.new(self) { html }
59
- container.render_tag :li
60
- else
61
- html
62
- end
63
- end
64
- end
65
- end
@@ -1,46 +0,0 @@
1
- require 'bh/classes/cdn'
2
-
3
- module Bh
4
- module Helpers
5
- # @see http://www.bootstrapcdn.com
6
- # @return [String] the URL of the Bootstrap CSS file
7
- # @param [Hash] options the options for which CSS file to retrieve.
8
- # @option options [String] :version the version of Bootstrap.
9
- # @option options [String] :scheme the URI scheme to use.
10
- # @option options [Boolean] :minified whether to use the minified version.
11
- def bootstrap_css(options = {})
12
- Bh::Cdn.bootstrap options.merge(name: 'bootstrap', extension: 'css')
13
- end
14
-
15
- # @see http://www.bootstrapcdn.com
16
- # @return [String] the URL of the Bootstrap Theme CSS file
17
- # @param [Hash] options the options for which CSS file to retrieve.
18
- # @option options [String] :version the version of Bootstrap.
19
- # @option options [String] :scheme the URI scheme to use.
20
- # @option options [Boolean] :minified whether to use the minified version.
21
- def bootstrap_theme_css(options = {})
22
- Bh::Cdn.bootstrap options.merge(name: 'bootstrap-theme', extension: 'css')
23
- end
24
-
25
- # @see http://www.bootstrapcdn.com
26
- # @return [String] the URL of the Font Awesome CSS file
27
- # @param [Hash] options the options for which CSS file to retrieve.
28
- # @option options [String] :version the version of Font Awesome.
29
- # @option options [String] :scheme the URI scheme to use.
30
- # @option options [Boolean] :minified whether to use the minified version.
31
- # @see http://fontawesome.io/get-started/
32
- def font_awesome_css(options = {})
33
- Bh::Cdn.font_awesome options.merge(name: 'font-awesome', extension: 'css')
34
- end
35
-
36
- # @see http://www.bootstrapcdn.com
37
- # @return [String] the URL of the Bootstrap JS file
38
- # @param [Hash] options the options for which JS file to retrieve.
39
- # @option options [String] :version the version of Bootstrap.
40
- # @option options [String] :scheme the URI scheme to use.
41
- # @option options [Boolean] :minified whether to use the minified version.
42
- def bootstrap_js(options = {})
43
- Bh::Cdn.bootstrap options.merge(name: 'bootstrap', extension: 'js')
44
- end
45
- end
46
- end
@@ -1,49 +0,0 @@
1
- require 'bh/classes/dropdown'
2
-
3
- module Bh
4
- module Helpers
5
- # @see http://getbootstrap.com/components/#dropdowns
6
- # @see http://getbootstrap.com/components/#btn-dropdowns
7
- # @return [String] an HTML block to display a dropdown.
8
- # @example A right-aligned dropdown with a links.
9
- # dropdown 'Menu', align: :right do
10
- # content_tag :li, link_to('Home', '/')
11
- # end
12
- # @param [#to_s] caption the caption for the dropdown button.
13
- # @param [Hash] options the display options for the dropdown.
14
- # @option options [Boolean] :groupable (true) if true, uses the "btn-group"
15
- # class rather than then "dropdown" class, so that multiple dropdown
16
- # buttons can be aligned in the same row (as a group of buttons).
17
- # @option options [Boolean] :split (false) if true, creates a split button
18
- # that only toggles the dropdown when clicked on the rightmost part.
19
- # @option options [#to_s] :direction if set to :up, the dropdown appears
20
- # above the button, rather than below.
21
- # @option options [#to_s] :layout if set to `:block`, span the dropdown
22
- # button for the full width of the parent. Note that :groupable takes
23
- # precedence, so it must be set to `false` to display a full-width button.
24
- # @option options [#to_s] :align if set to :right, the dropdown is aligned
25
- # to the right-end of the button, rather than to the left-end.
26
- # @option options [#to_s] :context (:default) the context for the button,
27
- # which determines its color.
28
- # @option options [#to_s] :size the size of the button.
29
- # @yieldreturn [#to_s] the content of the dropdown.
30
- def dropdown(caption, options = {}, &block)
31
- dropdown = Bh::Dropdown.new self, nil, options, &block
32
- dropdown.extract! :id, :groupable, :direction, :align, :split, :context,
33
- :size, :layout, :button
34
-
35
- dropdown.extract_from :button, [:context, :size, :layout]
36
- dropdown.merge! button: {caption: caption, id: dropdown.id}
37
- dropdown.append_class_to! :button, :btn
38
- dropdown.append_class_to! :button, dropdown.context_class
39
- dropdown.append_class_to! :button, dropdown.size_class
40
- dropdown.append_class_to! :button, dropdown.layout_class
41
- dropdown.append_class_to! :div, dropdown.groupable_class
42
- dropdown.append_class_to! :div, dropdown.direction_class
43
- dropdown.append_class_to! :ul, :'dropdown-menu'
44
- dropdown.append_class_to! :ul, dropdown.align_class
45
-
46
- dropdown.render_partial dropdown.partial
47
- end
48
- end
49
- end
@@ -1,18 +0,0 @@
1
- require 'bh/helpers/icon_helper'
2
-
3
- module Bh
4
- module Helpers
5
- # Displays any of the 200 glyphicons available in Bootstrap.
6
- # @deprecated Use {#icon} instead.
7
- # @see http://getbootstrap.com/components/#glyphicons
8
- # @return [String] the HTML to display a glyphicon.
9
- # @param [#to_s] name the name of the icon to display, with either dashes
10
- # or underscores to separate multiple words.
11
- # @param [Hash] options the options to pass to the icon’s `<span>`.
12
- # @example Display the "zoom-in" glyphicon
13
- # glyphicon :zoom_in
14
- def glyphicon(name = nil, options = {})
15
- icon name, options.merge(library: :glyphicons)
16
- end
17
- end
18
- end
@@ -1,35 +0,0 @@
1
- require 'bh/classes/navbar'
2
-
3
- module Bh
4
- module Helpers
5
- # Displays the collapsable portion of a Bootstrap-styled navbar.
6
- # @see http://getbootstrap.com/components/#navbar
7
- # @return [String] the HTML to display the collapsable portion of a
8
- # Bootstrap-styled navbar.
9
- # @overload horizontal(content, options = {})
10
- # @param [#to_s] content the collapsable content to display in the navbar.
11
- # @param [Hash] options the options to pass to the wrapping `<div>`.
12
- # Note that the `:id` option is ignored since the id must generated
13
- # by the navbar in order to match with the target of the toggle button.
14
- # @overload horizontal(options = {}, &block)
15
- # @param [Hash] options the options to pass to the wrapping `<div>`.
16
- # @yieldreturn [#to_s] the collapsable content to display in the navbar.
17
- # @example Display a navbar with two collapsable links.
18
- # navbar do
19
- # horizontal do
20
- # nav do
21
- # link_to 'Home', '/'
22
- # link_to 'Profile', '/profile'
23
- # end
24
- # end
25
- # end
26
- def horizontal(*args, &block)
27
- if navbar = Bh::Stack.find(Bh::Navbar)
28
- horizontal = Bh::Base.new self, *args, &block
29
- horizontal.append_class! :'collapse navbar-collapse'
30
- horizontal.merge! id: navbar.id
31
- horizontal.render_tag :div
32
- end
33
- end
34
- end
35
- end
@@ -1,27 +0,0 @@
1
- require 'bh/classes/icon'
2
-
3
- module Bh
4
- module Helpers
5
- # Displays a Bootstrap-styled vector icon.
6
- # @see http://getbootstrap.com/components/#glyphicons
7
- # @see http://fortawesome.github.io/Font-Awesome/examples/#bootstrap
8
- # @return [String] the HTML to display a vector (font) icon.
9
- # @param [#to_s] name the name of the icon to display, with either dashes
10
- # or underscores to separate multiple words.
11
- # @param [Hash] options the options for the icon tag. Any option not
12
- # listed below is passed as an HTML attribute to the icon’s `<span>`.
13
- # @option options [#to_s] :library (:glyphicons) the vector icon library
14
- # to use. Valid values are 'glyphicon', 'glyphicons' (for Glyphicons),
15
- # 'font-awesome', 'font_awesome' and 'fa' (for Font Awesome).
16
- # @example Display the "fire" font awesome icon with a title
17
- # icon 'fire', library: :font_awesome, title: 'Hot'
18
- def icon(name = nil, options = {})
19
- icon = Bh::Icon.new self, nil, options.merge(name: name)
20
- icon.extract! :library, :name
21
-
22
- icon.append_class! icon.library_class
23
- icon.append_class! icon.name_class
24
- icon.render_tag :span
25
- end
26
- end
27
- end
@@ -1,59 +0,0 @@
1
- require 'bh/classes/link_to'
2
- require 'bh/classes/alert_box'
3
- require 'bh/classes/dropdown'
4
- require 'bh/classes/nav'
5
- require 'bh/classes/stack'
6
- require 'bh/classes/vertical'
7
-
8
- module Bh
9
- module Helpers
10
- # Overrides `link_to` to display a Bootstrap-styled link.
11
- # Can only be used in Ruby frameworks that provide the `link_to` method.
12
- # @see http://getbootstrap.com/components/#dropdowns
13
- # @see http://getbootstrap.com/components/#nav
14
- # @see http://getbootstrap.com/components/#navbar-brand-image
15
- # @see http://getbootstrap.com/components/#navbar-links
16
- # @see http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
17
- # @see http://www.rubydoc.info/github/padrino/padrino-framework/Padrino/Helpers/AssetTagHelpers#link_to-instance_method
18
- # @return [String] the HTML to display a Bootstrap-styled link.
19
- # @overload link_to(caption, url, options = {})
20
- # @param [#to_s] caption the caption to display in the link.
21
- # @param [#to_s] url the URL to link to.
22
- # @param [Hash] options the options for the original `link_to` method.
23
- # @example Display a plain-text link inside an alert-box.
24
- # alert_box do
25
- # link_to 'Check the terms and conditions', '/#terms'
26
- # end
27
- # @overload button_to(url, options = {}, &block)
28
- # @param [#to_s] url the URL to link to (see above).
29
- # @param [Hash] options the options for the original `link_to` method.
30
- # @yieldreturn [#to_s] the caption to display in the link.
31
- # @example Display a link with HTML inside a dropdown.
32
- # dropdown 'Menu' do
33
- # link_to '/#terms' do
34
- # content_tag :strong, 'Check the terms and conditions'
35
- # end
36
- # end
37
- def link_to(*args, &block)
38
- link_to = Bh::LinkTo.new self, *args, &block
39
-
40
- link_to.append_class! :'alert-link' if Bh::Stack.find(Bh::AlertBox)
41
- link_to.append_class! :'navbar-brand' if Bh::Stack.find(Bh::Vertical)
42
- link_to.merge! role: :menuitem if Bh::Stack.find(Bh::Dropdown)
43
- link_to.merge! tabindex: -1 if Bh::Stack.find(Bh::Dropdown)
44
- html = super link_to.content, link_to.url, link_to.attributes, &nil
45
-
46
- if Bh::Stack.find(Bh::Dropdown)
47
- container = Bh::Base.new(self) { html }
48
- container.merge! role: :presentation
49
- container.render_tag :li
50
- elsif Bh::Stack.find(Bh::Nav)
51
- container = Bh::Base.new(self) { html }
52
- container.append_class! :active if link_to.current_page?
53
- container.render_tag :li
54
- else
55
- html
56
- end
57
- end
58
- end
59
- end
@@ -1,55 +0,0 @@
1
- require 'bh/classes/modal'
2
-
3
- module Bh
4
- module Helpers
5
- # Displays a Bootstrap-styled modal.
6
- # @see http://getbootstrap.com/javascript/#modals
7
- # @return [String] the HTML to display a Bootstrap-styled modal.
8
- # @overload modal(body, options = {})
9
- # @param [#to_s] body the content to display as the modal body.
10
- # @param [Hash] options the options for the modal. Any option not listed
11
- # below is ignored, except for `:id` which is passed as an HTML
12
- # attribute to the modal’s `<div>`.
13
- # @option options [#to_s] :title ('Modal') the title of the modal.
14
- # @option options [#to_s] :body the content to display as the modal body.
15
- # Using this option is equivalent to passing the body as an argument.
16
- # @option options [#to_s] :size the size of the modal. Can be `:large`
17
- # (alias `:lg`) or `:small` (alias `:sm`).
18
- # @option options [Hash] :button the options for the toggle button.
19
- # * :caption (#to_s) ('Modal') the caption of the toggle button.
20
- # * :context (#to_s) (:default) the contextual alternative to apply to
21
- # the toggle button. Can be `:danger`, `:info`, `:link`, `:primary`,
22
- # `:success` or `:warning`.
23
- # * :size (#to_s) the size of the toggle button. Can be `:extra_small`
24
- # (alias `:xs`), `:large` (alias `:lg`) or `:small` (alias `:sm`).
25
- # * :layout (#to_s) if set to `:block`, span the button for the full
26
- # width of the parent.
27
- # @example Display a simple modal toggled by a blue button.
28
- # modal 'You clicked me!', title: 'Click me', button: {context: :info}
29
- # @overload modal(options = {}, &block)
30
- # @param [Hash] options the options for the modal (see above).
31
- # @yieldreturn [#to_s] the content to display in the modal.
32
- # @example Display a modal with HTML content.
33
- # modal title: 'Click me' do
34
- # content_tag :div, class: 'modal-body' do
35
- # content_tag :em, 'You clicked me!'
36
- # end
37
- # end
38
- def modal(*args, &block)
39
- modal = Bh::Modal.new self, *args, &block
40
- modal.extract! :button, :size, :body, :title, :id
41
-
42
- modal.extract_from :button, [:context, :size, :layout, :caption]
43
- modal.append_class_to! :button, :btn
44
- modal.append_class_to! :button, modal.button_context_class
45
- modal.append_class_to! :button, modal.button_size_class
46
- modal.merge! button: {caption: modal.caption}
47
-
48
- modal.append_class_to! :div, :'modal-dialog'
49
- modal.append_class_to! :div, modal.dialog_size_class
50
- modal.merge! div: {title: modal.title, id: modal.id}
51
-
52
- modal.render_partial 'modal'
53
- end
54
- end
55
- end
@@ -1,36 +0,0 @@
1
- require 'bh/classes/nav'
2
- require 'bh/classes/navbar'
3
-
4
- module Bh
5
- module Helpers
6
- # Displays a Bootstrap-styled nav.
7
- # @see http://getbootstrap.com/components/#nav
8
- # @return [String] the HTML to display a Bootstrap-styled nav.
9
- # @param [Hash] options the options for the nav. Any option not listed below
10
- # is passed as an HTML attribute to the alert’s `<ul>`.
11
- # @option options [#to_s] :as (:tabs) the style of the nav. Can be `:tabs`
12
- # or `:pills`.
13
- # @option options [#to_s] :layout the layout of the nav. Can be
14
- # `:justified` or `:stacked`.
15
- # @yieldreturn [#to_s] the content to display in the nav.
16
- # @example Display a pills-styled nav with a link.
17
- # nav as: :pills do
18
- # link_to 'Home', '/'
19
- # end
20
- def nav(options = {}, &block)
21
- nav = Bh::Nav.new(self, options, &block)
22
- nav.extract! :as, :layout
23
-
24
- nav.append_class! :nav
25
- if Bh::Stack.find(Bh::Navbar)
26
- nav.append_class! :'navbar-nav'
27
- else
28
- nav.merge! role: :tablist
29
- nav.append_class! nav.style_class
30
- nav.append_class! nav.layout_class
31
- end
32
-
33
- nav.render_tag :ul
34
- end
35
- end
36
- end
@@ -1,48 +0,0 @@
1
- require 'bh/helpers/horizontal_helper'
2
- require 'bh/helpers/vertical_helper'
3
-
4
- module Bh
5
- module Helpers
6
- # Displays a Bootstrap-styled navbar.
7
- # @see http://getbootstrap.com/components/#navbar
8
- # @return [String] the HTML to display a Bootstrap-styled navbar.
9
- # @param [Hash] options the options for the navbar. Any option not listed
10
- # below is ignored, except for `:id` which is passed as an HTML
11
- # attribute to the navbar’s collapsable `<div>`.
12
- # @option options [Boolean] :fluid (false) whether to use a fluid container
13
- # to surround the navbar content.
14
- # @option options [Boolean] :inverted (false) whether to use an inverted
15
- # palette of colors.
16
- # @option options [#to_s] :position the position of the navbar. Can be
17
- # `:top` (alias `:fixed_top`), `:bottom` (alias `:fixed_bottom`) or
18
- # `:static` (alias `:static_top`).
19
- # @option options [#to_s] :padding (70) if position is set to :top or
20
- # :bottom, the padding to at the top (or bottom) of <body> to prevent the
21
- # navbar from overlaying the content.
22
- # @yieldreturn [#to_s] the content to display in the navbar.
23
- # @example Display an inverted navbar with three links.
24
- # navbar inverted: true do
25
- # vertical do
26
- # image_tag('logo')
27
- # end
28
- # horizontal do
29
- # nav do
30
- # link_to 'Home', '/'
31
- # link_to 'Profile', '/profile'
32
- # end
33
- # end
34
- # end
35
- def navbar(options = {}, &block)
36
- navbar = Bh::Navbar.new(self, options, &block)
37
- navbar.extract! :inverted, :position, :padding, :fluid, :id
38
-
39
- navbar.append_class_to! :navigation, :navbar
40
- navbar.append_class_to! :navigation, navbar.style_class
41
- navbar.append_class_to! :navigation, navbar.position_class
42
- navbar.append_class_to! :div, navbar.layout_class
43
- navbar.prepend_html! navbar.body_padding_style
44
-
45
- navbar.render_partial 'navbar'
46
- end
47
- end
48
- end
@@ -1,53 +0,0 @@
1
- require 'bh/classes/panel'
2
- require 'bh/classes/panel_row'
3
- require 'bh/classes/stack'
4
-
5
- module Bh
6
- module Helpers
7
- # Displays a Bootstrap-styled panel.
8
- # @see http://getbootstrap.com/components/#panels
9
- # @return [String] the HTML to display a Bootstrap-styled panel.
10
- # @overload panel(body, options = {})
11
- # @param [#to_s] body the content to display as the panel body.
12
- # @param [Hash] options the options for the panel. Any option not
13
- # listed below is passed as an HTML attribute to the panel’s `<div>`.
14
- # @option options [#to_s] :title the text to display as the panel title.
15
- # @option options [#to_s] :heading the text to display as the panel
16
- # heading.
17
- # @option options [#to_s] :body the text to display as the panel body.
18
- # Using this option is equivalent to passing the body as an argument.
19
- # @option options [#to_s] :context (#to_s) (:default) the contextual
20
- # alternative to apply to the panel heading and border. Can be
21
- # `:danger`, `:info`, `:primary`, `:success` or `:warning`.
22
- # @option options [#to_s] :tag (#to_s) (:div) the HTML tag to wrap the
23
- # panel into.
24
- # @example Display an informative panel with plain-text content.
25
- # panel 'You accepted the Terms of service.', context: :success
26
- # @overload panel(options = {}, &block)
27
- # @param [Hash] options the options for the panel (see above).
28
- # @yieldreturn [#to_s] the content to display in the panel.
29
- # @example Display a panel with HTML content.
30
- # panel title: 'Thanks' do
31
- # content_tag :div, class: 'panel-body' do
32
- # content_tag :em, 'ou accepted the Terms of service.'
33
- # end
34
- # end
35
- def panel(*args, &block)
36
- panel = Bh::Panel.new self, *args, &block
37
- panel.extract! :body, :context, :title, :heading, :tag
38
-
39
- panel.append_class! :panel
40
- panel.append_class! panel.context_class
41
- panel.merge_html! panel.body
42
- panel.prepend_html! panel.heading
43
-
44
- if panel_row = Bh::Stack.find(Bh::PanelRow)
45
- container = Bh::Base.new(self) { panel.content_tag panel.tag }
46
- container.append_class! panel_row.column_class
47
- container.render_tag :div
48
- else
49
- panel.render_tag panel.tag
50
- end
51
- end
52
- end
53
- end
@@ -1,28 +0,0 @@
1
- require 'bh/classes/panel_row'
2
-
3
- module Bh
4
- module Helpers
5
- # Wraps a set of Bootstrap-styled panels in a row.
6
- # @see http://getbootstrap.com/components/#panels
7
- # @see http://getbootstrap.com/css/#grid
8
- # @return [String] the HTML to display a row of Bootstrap-styled panels.
9
- # @param [Hash] options the options for the row. Any option not
10
- # listed below is passed as an HTML attribute to the row’s `<div>`.
11
- # @option options [#to_s] :column_class the class to wrap each panel with.
12
- # Useful to specify a grid size for the column such as 'col-sm-4' to
13
- # indicate how many columns of the row each panel should occupy.
14
- # @yieldreturn [#to_s] the panels to display in a row.
15
- # @example Display a row of two panels with the same width.
16
- # panel_row column_class: 'col-sm-6' do
17
- # panel 'Panel #1', context: :success
18
- # panel 'Panel #2', context: :info
19
- # end
20
- def panel_row(options = {}, &block)
21
- panel_row = Bh::PanelRow.new self, options, &block
22
- panel_row.extract! :column_class
23
-
24
- panel_row.append_class! :row
25
- panel_row.render_tag :div
26
- end
27
- end
28
- end
@@ -1,55 +0,0 @@
1
- require 'bh/classes/progress_bar'
2
-
3
- module Bh
4
- module Helpers
5
- # Displays one or more Bootstrap-styled progress bars.
6
- # @see http://getbootstrap.com/components/#progress
7
- # @return [String] the HTML to display Bootstrap-styled progress bars.
8
- # @overload progress_bar(bar_options = {}, container_options = {})
9
- # @param [Hash] bar_options the options to display a single progress bar.
10
- # Any option not listed below is passed as an HTML attribute to the
11
- # bar’s `<div>`.
12
- # @option bar_options [Boolean, #to_s] :label (false) the label to display
13
- # on top of the progress bar. If set to false, the label is hidden. If
14
- # set to true, the label is generated from the percentage value. Any
15
- # other provided value is used directly as the label.
16
- # @option bar_options [Boolean] :striped (false) whether to display a
17
- # striped version of the progress bar (rather than solid color).
18
- # @option bar_options [Boolean] :animated (false) whether to display an
19
- # animated version of the progress bar (rather than solid color).
20
- # @option bar_options [#to_s] :context (:default) the contextual
21
- # alternative to apply to the progress bar. Can be `:success`, `:info`,
22
- # `:warning` or `:danger`.
23
- # @param [Hash] container_options the options to pass as HTML attributes
24
- # to the container’s `<div>`.
25
- # @example Display a 30% warning progress bar.
26
- # progress_bar percentage: 30, context: :warning
27
- # @overload progress_bar(stacked_bars_options = [], container_options = {})
28
- # @param [Hash] stacked_bars_options an array of bar_options (see above).
29
- # When an array is provided, a group of stacked progress bars is
30
- # displayed, each one matching the corresponding bar options.
31
- # @param [Hash] container_options the options to pass as HTML attributes
32
- # to the container’s `<div>`.
33
- # @example Display two stacked progress bars.
34
- # progress_bar [{percentage: 30, context: :warning}, {percentage: 20}]
35
- def progress_bar(args = nil, container_options = {})
36
- progress_bars = Array.wrap(args).map do |options|
37
- progress_bar = Bh::ProgressBar.new self, nil, options
38
- progress_bar.extract! :percentage, :context, :striped, :animated, :label
39
-
40
- progress_bar.merge! progress_bar.aria_values
41
- progress_bar.append_class! :'progress-bar'
42
- progress_bar.append_class! progress_bar.context_class
43
- progress_bar.append_class! progress_bar.striped_class
44
- progress_bar.append_class! progress_bar.animated_class
45
- progress_bar.merge! progress_bar.values
46
- progress_bar.prepend_html! progress_bar.label
47
- progress_bar
48
- end
49
-
50
- container = Bh::Base.new self, progress_bars, container_options
51
- container.append_class! :progress
52
- container.render_tag :div
53
- end
54
- end
55
- end
@@ -1,33 +0,0 @@
1
- require 'bh/classes/navbar'
2
- require 'bh/classes/vertical'
3
-
4
- module Bh
5
- module Helpers
6
- # Displays the non-collapsable portion of a Bootstrap-styled navbar.
7
- # @see http://getbootstrap.com/components/#navbar
8
- # @return [String] the HTML to display the non-collapsable portion of a
9
- # Bootstrap-styled navbar.
10
- # @overload vertical(content, options = {})
11
- # @param [#to_s] content the non-collapsable content to display in the
12
- # navbar.
13
- # @param [Hash] options the options to pass to the wrapping `<div>`.
14
- # @overload vertical(options = {}, &block)
15
- # @param [Hash] options the options to pass to the wrapping `<div>`.
16
- # @yieldreturn [#to_s] the non-collapsable content to display in the
17
- # navbar.
18
- # @example Display a navbar a non-collapsable links.
19
- # navbar do
20
- # vertical do
21
- # link_to 'Home', '/'
22
- # end
23
- # end
24
- def vertical(*args, &block)
25
- if navbar = Bh::Stack.find(Bh::Navbar)
26
- vertical = Bh::Vertical.new self, *args, &block
27
- vertical.append_class! :'navbar-header'
28
- vertical.prepend_html! vertical.toggle_button(navbar.id)
29
- vertical.render_tag :div
30
- end
31
- end
32
- end
33
- end
@@ -1,4 +0,0 @@
1
- <button type="button" class="close" data-dismiss="alert">
2
- <span aria-hidden="true">&times;</span>
3
- <span class="sr-only">Close</span>
4
- </button>
@@ -1,9 +0,0 @@
1
- <div class="<%= div[:class] %>">
2
- <button class="dropdown-toggle <%= button[:class] %>" type="button" id="<%= button[:id] %>" data-toggle="dropdown">
3
- <%= button[:caption] %>
4
- <span class="caret"></span>
5
- </button>
6
- <ul class="<%= ul[:class] %>" role="menu" aria-labelledby="<%= button[:id] %>">
7
- <%= content %>
8
- </ul>
9
- </div>
@@ -1,10 +0,0 @@
1
- <div class="<%= div[:class] %>">
2
- <button type="button" class="<%= button[:class] %>"><%= button[:caption] %></button>
3
- <button class="dropdown-toggle <%= button[:class] %>" type="button" id="<%= button[:id] %>" data-toggle="dropdown">
4
- <span class="caret"></span>
5
- <span class="sr-only">Toggle Dropdown</span>
6
- </button>
7
- <ul class="<%= ul[:class] %>" role="menu" aria-labelledby="<%= button[:id] %>">
8
- <%= content %>
9
- </ul>
10
- </div>