bh 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/CHANGELOG.md +19 -0
- data/README.md +51 -18
- data/bh.gemspec +13 -9
- data/examples/middleman/.gitignore +18 -0
- data/examples/middleman/Gemfile +6 -0
- data/examples/middleman/config.rb +1 -0
- data/examples/middleman/source/index.html.erb +158 -0
- data/examples/padrino/Gemfile +9 -0
- data/examples/padrino/app/app.rb +16 -0
- data/examples/padrino/app/views/index.html.erb +155 -0
- data/examples/padrino/config.ru +5 -0
- data/examples/padrino/config/apps.rb +5 -0
- data/examples/padrino/config/boot.rb +8 -0
- data/examples/rails/.gitignore +12 -0
- data/examples/rails/Gemfile +5 -0
- data/examples/rails/app/controllers/application_controller.rb +6 -0
- data/examples/rails/app/controllers/users_controller.rb +2 -0
- data/examples/rails/app/models/user.rb +15 -0
- data/examples/rails/app/views/application/index.html.erb +160 -0
- data/examples/rails/bin/rails +4 -0
- data/examples/rails/config.ru +4 -0
- data/examples/rails/config/application.rb +12 -0
- data/examples/rails/config/boot.rb +3 -0
- data/examples/rails/config/environment.rb +5 -0
- data/examples/rails/config/environments/development.rb +7 -0
- data/examples/rails/config/routes.rb +4 -0
- data/examples/rails/config/secrets.yml +22 -0
- data/examples/rails/log/.keep +0 -0
- data/gemfiles/Gemfile.rails-3.x +2 -0
- data/gemfiles/Gemfile.rails-4.x +2 -0
- data/lib/bh.rb +15 -4
- data/lib/bh/classes/alert_box.rb +35 -0
- data/lib/bh/classes/base.rb +125 -0
- data/lib/bh/classes/button.rb +58 -0
- data/lib/bh/classes/button_to.rb +33 -0
- data/lib/bh/classes/cdn.rb +35 -0
- data/lib/bh/classes/dropdown.rb +56 -0
- data/lib/bh/classes/icon.rb +34 -0
- data/lib/bh/classes/link_to.rb +22 -0
- data/lib/bh/classes/modal.rb +68 -0
- data/lib/bh/classes/nav.rb +37 -0
- data/lib/bh/classes/navbar.rb +78 -0
- data/lib/bh/classes/panel.rb +72 -0
- data/lib/bh/classes/panel_row.rb +13 -0
- data/lib/bh/classes/progress_bar.rb +89 -0
- data/lib/bh/classes/stack.rb +19 -0
- data/lib/bh/classes/vertical.rb +27 -0
- data/lib/bh/core_ext/middleman.rb +24 -0
- data/lib/bh/core_ext/padrino.rb +25 -0
- data/lib/bh/core_ext/rails/base_helper.rb +21 -0
- data/lib/bh/{helpers → core_ext/rails}/form/base_helper.rb +3 -1
- data/lib/bh/{helpers → core_ext/rails}/form/check_box_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/field_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/fields_for_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/fieldset_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/file_field_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/legend_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/radio_button_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/select_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/static_control_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/submit_helper.rb +1 -1
- data/lib/bh/{form_builders → core_ext/rails}/form_builder.rb +11 -10
- data/lib/bh/core_ext/rails/form_for_helper.rb +32 -0
- data/lib/bh/core_ext/railtie.rb +27 -0
- data/lib/bh/helpers/alert_box_helper.rb +40 -0
- data/lib/bh/helpers/button_helper.rb +35 -58
- data/lib/bh/helpers/button_to_helper.rb +48 -10
- data/lib/bh/helpers/cdn_helper.rb +11 -35
- data/lib/bh/helpers/dropdown_helper.rb +29 -62
- data/lib/bh/helpers/glyphicon_helper.rb +7 -13
- data/lib/bh/helpers/horizontal_helper.rb +35 -0
- data/lib/bh/helpers/icon_helper.rb +15 -29
- data/lib/bh/helpers/link_to_helper.rb +52 -41
- data/lib/bh/helpers/modal_helper.rb +49 -79
- data/lib/bh/helpers/nav_helper.rb +25 -40
- data/lib/bh/helpers/navbar_helper.rb +36 -170
- data/lib/bh/helpers/panel_helper.rb +45 -72
- data/lib/bh/helpers/panel_row_helper.rb +20 -38
- data/lib/bh/helpers/progress_bar_helper.rb +48 -59
- data/lib/bh/helpers/vertical_helper.rb +33 -0
- data/lib/bh/version.rb +1 -1
- data/lib/bh/views/bh/_alert_dismiss_button.html +4 -0
- data/lib/bh/views/bh/_dropdown.html.erb +5 -5
- data/lib/bh/views/bh/_dropdown_split.html.erb +5 -5
- data/lib/bh/views/bh/_modal.html.erb +5 -8
- data/lib/bh/views/bh/_navbar.html.erb +5 -0
- data/spec/padrino/button_to_helper.rb +35 -0
- data/spec/padrino_spec.rb +28 -0
- data/spec/rails/button_to_helper.rb +31 -0
- data/spec/{helpers → rails}/form/check_box_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/field_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/fields_for_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/fieldset_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/file_field_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/legend_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/radio_button_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/select_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/static_control_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/submit_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form_for_helper_spec.rb +3 -3
- data/spec/rails_helper.rb +25 -0
- data/spec/rails_spec.rb +28 -0
- data/spec/shared/alert_box_helper.rb +62 -0
- data/spec/shared/button_helper.rb +52 -0
- data/spec/shared/button_to_helper.rb +42 -0
- data/spec/shared/cdn_helper.rb +36 -0
- data/spec/shared/dropdown_helper.rb +112 -0
- data/spec/shared/glyphicon_helper.rb +21 -0
- data/spec/shared/horizontal_helper.rb +37 -0
- data/spec/shared/icon_helper.rb +31 -0
- data/spec/shared/link_to_helper.rb +62 -0
- data/spec/shared/modal_helper.rb +104 -0
- data/spec/shared/nav_helper.rb +49 -0
- data/spec/shared/navbar_helper.rb +63 -0
- data/spec/shared/panel_helper.rb +76 -0
- data/spec/shared/panel_row_helper.rb +21 -0
- data/spec/shared/progress_bar_helper.rb +103 -0
- data/spec/shared/vertical_helper.rb +43 -0
- data/spec/spec_helper.rb +6 -29
- data/spec/support/matchers.rb +38 -0
- data/spec/support/padrino.rb +33 -0
- data/spec/support/rails.rb +27 -0
- metadata +183 -94
- data/config.rb +0 -6
- data/lib/bh/helpers/alert_helper.rb +0 -77
- data/lib/bh/helpers/base_helper.rb +0 -39
- data/lib/bh/helpers/form_for_helper.rb +0 -30
- data/lib/bh/middleman.rb +0 -39
- data/lib/bh/railtie.rb +0 -42
- data/spec/dummy/index.html.erb +0 -60
- data/spec/dummy/layouts/default.erb +0 -17
- data/spec/helpers/alert_helper_spec.rb +0 -84
- data/spec/helpers/button_helper_spec.rb +0 -100
- data/spec/helpers/button_to_helper_spec.rb +0 -25
- data/spec/helpers/cdn_helper_spec.rb +0 -100
- data/spec/helpers/dropdown_helper_spec.rb +0 -146
- data/spec/helpers/glyphicon_helper_spec.rb +0 -21
- data/spec/helpers/icon_helper_spec.rb +0 -45
- data/spec/helpers/link_to_helper_spec.rb +0 -124
- data/spec/helpers/modal_helper_spec.rb +0 -133
- data/spec/helpers/nav_helper_spec.rb +0 -53
- data/spec/helpers/navbar_helper_spec.rb +0 -194
- data/spec/helpers/panel_helper_spec.rb +0 -95
- data/spec/helpers/panel_row_helper_spec.rb +0 -27
- data/spec/helpers/progress_bar_helper_spec.rb +0 -114
data/config.rb
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
# If you are developing new helpers and want a quick way to see them in
|
2
|
-
# a browser, type `bundle exec middleman` and browse to http://localhost:4567
|
3
|
-
# The browser will show the interpolated content of spec/dummy/index.html.erb
|
4
|
-
# which you are free to edit as you please to display new helpers.
|
5
|
-
set :source, 'spec/dummy'
|
6
|
-
activate :bh
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'bh/helpers/base_helper'
|
2
|
-
|
3
|
-
module Bh
|
4
|
-
module AlertHelper
|
5
|
-
include BaseHelper
|
6
|
-
# Returns an HTML block tag that follows the Bootstrap documentation
|
7
|
-
# on how to display *alert boxes*.
|
8
|
-
# Alert boxes provide contextual feedback messages for typical user
|
9
|
-
# actions with the handful of available and flexible alert messages.
|
10
|
-
# @see http://getbootstrap.com/components/#alerts
|
11
|
-
#
|
12
|
-
# The message to display in the alert can either be passed as the first
|
13
|
-
# parameter (in which case, the options are the second parameter), or as
|
14
|
-
# a block (in which case, the options are the first parameter).
|
15
|
-
# @example An alert with a plain-text message passed as the first parameter.
|
16
|
-
# alert 'User updated successfully', dismissible: true
|
17
|
-
# @example An alert with an HTML message passed as a block.
|
18
|
-
# alert_box dismissible: true do
|
19
|
-
# content_tag :strong, "User updated successfully"
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# @return [String] an HTML block tag for an alert.
|
23
|
-
# @param [String] message_or_options_with_block the message to display in
|
24
|
-
# the alert.
|
25
|
-
# @param [Hash] options the options for the alert box.
|
26
|
-
# @option options [Boolean] :dismissible (false) whether to display an '×'
|
27
|
-
# to the right of the alert than can be clicked to dismiss the alert.
|
28
|
-
# @option options [#to_s] :context (:info) the contextual alternative to
|
29
|
-
# apply to the alert depending on its importance. Can be :success, :info,
|
30
|
-
# :warning or :danger.
|
31
|
-
# @option options [#to_s] :priority if the alert box is used to show a
|
32
|
-
# Rails flash message, the priority of the message. Can be :alert
|
33
|
-
# or :notice.
|
34
|
-
def alert_box(message_or_options_with_block = nil, options = nil, &block)
|
35
|
-
if block_given?
|
36
|
-
alert_string capture_alert(&block), message_or_options_with_block || {}
|
37
|
-
else
|
38
|
-
alert_string message_or_options_with_block, options || {}
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def alert_string(message = nil, options = {})
|
45
|
-
dismissible = options[:dismissible] || options[:priority]
|
46
|
-
message = add_dismiss_button_to(message) if dismissible
|
47
|
-
klass = alert_class options.fetch(:context, options[:priority])
|
48
|
-
content_tag :div, message, role: :alert, class: klass
|
49
|
-
end
|
50
|
-
|
51
|
-
def alert_class(context = nil)
|
52
|
-
valid_contexts = %w(success info warning danger)
|
53
|
-
context = context_for context, default: 'info', valid: valid_contexts
|
54
|
-
"alert alert-#{context}"
|
55
|
-
end
|
56
|
-
|
57
|
-
def add_dismiss_button_to(message)
|
58
|
-
options = {type: 'button', class: 'close', :'data-dismiss' => 'alert'}
|
59
|
-
dismiss_button = content_tag :button, options do
|
60
|
-
safe_join [
|
61
|
-
content_tag(:span, '×'.html_safe, :'aria-hidden' => true),
|
62
|
-
content_tag(:span, 'Close', class: 'sr-only'),
|
63
|
-
], ''
|
64
|
-
end
|
65
|
-
safe_join [dismiss_button, message], "\n"
|
66
|
-
end
|
67
|
-
|
68
|
-
# Captures the message passed as a block and sets a variable so that
|
69
|
-
# every +link_to+ helper called inside the block gets the "alert-link"
|
70
|
-
# class added, for links to look better.
|
71
|
-
# @see http://getbootstrap.com/components/#alerts-links
|
72
|
-
def capture_alert(&block)
|
73
|
-
@alert_link = true
|
74
|
-
capture(&block).tap{ @alert_link = false }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'action_view'
|
2
|
-
|
3
|
-
module Bh
|
4
|
-
module BaseHelper
|
5
|
-
include ActionView::Helpers::TagHelper # for content_tag
|
6
|
-
include ActionView::Context # for capture
|
7
|
-
include ActionView::Helpers::OutputSafetyHelper # for safe_join
|
8
|
-
include ActionView::Helpers::RenderingHelper # for render
|
9
|
-
include ActionView::Helpers::UrlHelper # for link_to
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def append_class!(hash, new_class, attribute = :class)
|
14
|
-
existing_class = hash[attribute]
|
15
|
-
hash[attribute] = [existing_class, new_class].compact.join ' '
|
16
|
-
end
|
17
|
-
|
18
|
-
def append_class_as!(attribute, new_class, *args, &block)
|
19
|
-
html_options = (block_given? ? args[1] : args[2]) || {}
|
20
|
-
append_class! html_options, new_class, attribute
|
21
|
-
block_given? ? args[1] = html_options : args[2] = html_options
|
22
|
-
args
|
23
|
-
end
|
24
|
-
|
25
|
-
def context_for(context = nil, options = {})
|
26
|
-
context = case context.to_s
|
27
|
-
when 'notice' then 'success'
|
28
|
-
when 'alert' then 'danger'
|
29
|
-
else context.to_s
|
30
|
-
end
|
31
|
-
|
32
|
-
if options.fetch(:valid, []).map(&:to_s).include? context
|
33
|
-
context
|
34
|
-
else
|
35
|
-
options.fetch :default, 'default'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'bh/helpers/base_helper'
|
2
|
-
require 'bh/form_builders/form_builder'
|
3
|
-
|
4
|
-
module Bh
|
5
|
-
module FormForHelper
|
6
|
-
include BaseHelper
|
7
|
-
include ActionView::Helpers::FormHelper # for form_for
|
8
|
-
|
9
|
-
def form_for(record, options = {}, &block)
|
10
|
-
add_form_options!(options) if options[:layout]
|
11
|
-
super record, options, &block
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def add_form_options!(options)
|
17
|
-
options[:html] ||= {}
|
18
|
-
options[:html].merge! role: 'form'
|
19
|
-
append_class! options[:html], class_for(options[:layout])
|
20
|
-
options.merge! builder: FormBuilder
|
21
|
-
end
|
22
|
-
|
23
|
-
def class_for(layout)
|
24
|
-
case layout.to_s
|
25
|
-
when 'inline' then 'form-inline'
|
26
|
-
when 'horizontal' then 'form-horizontal'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/lib/bh/middleman.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'bh/helpers/alert_helper'
|
2
|
-
require 'bh/helpers/button_helper'
|
3
|
-
require 'bh/helpers/button_to_helper'
|
4
|
-
require 'bh/helpers/cdn_helper'
|
5
|
-
require 'bh/helpers/dropdown_helper'
|
6
|
-
require 'bh/helpers/form_for_helper'
|
7
|
-
require 'bh/helpers/glyphicon_helper'
|
8
|
-
require 'bh/helpers/icon_helper'
|
9
|
-
require 'bh/helpers/link_to_helper'
|
10
|
-
require 'bh/helpers/modal_helper'
|
11
|
-
require 'bh/helpers/nav_helper'
|
12
|
-
require 'bh/helpers/navbar_helper'
|
13
|
-
require 'bh/helpers/panel_helper'
|
14
|
-
require 'bh/helpers/panel_row_helper'
|
15
|
-
require 'bh/helpers/progress_bar_helper'
|
16
|
-
|
17
|
-
module Bh
|
18
|
-
class MiddlemanExtension < Middleman::Extension
|
19
|
-
helpers do
|
20
|
-
include AlertHelper
|
21
|
-
include ButtonHelper
|
22
|
-
include ButtonToHelper
|
23
|
-
include CdnHelper
|
24
|
-
include DropdownHelper
|
25
|
-
include FormForHelper
|
26
|
-
include GlyphiconHelper
|
27
|
-
include IconHelper
|
28
|
-
include LinkToHelper
|
29
|
-
include ModalHelper
|
30
|
-
include NavHelper
|
31
|
-
include NavbarHelper
|
32
|
-
include PanelHelper
|
33
|
-
include PanelRowHelper
|
34
|
-
include ProgressBarHelper
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
::Middleman::Extensions.register(:bh, Bh::MiddlemanExtension)
|
data/lib/bh/railtie.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'bh/helpers/alert_helper'
|
2
|
-
require 'bh/helpers/button_helper'
|
3
|
-
require 'bh/helpers/button_to_helper'
|
4
|
-
require 'bh/helpers/cdn_helper'
|
5
|
-
require 'bh/helpers/dropdown_helper'
|
6
|
-
require 'bh/helpers/form_for_helper'
|
7
|
-
require 'bh/helpers/glyphicon_helper'
|
8
|
-
require 'bh/helpers/icon_helper'
|
9
|
-
require 'bh/helpers/link_to_helper'
|
10
|
-
require 'bh/helpers/modal_helper'
|
11
|
-
require 'bh/helpers/nav_helper'
|
12
|
-
require 'bh/helpers/navbar_helper'
|
13
|
-
require 'bh/helpers/panel_helper'
|
14
|
-
require 'bh/helpers/panel_row_helper'
|
15
|
-
require 'bh/helpers/progress_bar_helper'
|
16
|
-
|
17
|
-
module Bh
|
18
|
-
class Railtie < Rails::Railtie
|
19
|
-
initializer 'bh.add_helpers' do
|
20
|
-
ActionView::Base.send :include, AlertHelper
|
21
|
-
ActionView::Base.send :include, ButtonHelper
|
22
|
-
ActionView::Base.send :include, ButtonToHelper
|
23
|
-
ActionView::Base.send :include, CdnHelper
|
24
|
-
ActionView::Base.send :include, DropdownHelper
|
25
|
-
ActionView::Base.send :include, FormForHelper
|
26
|
-
ActionView::Base.send :include, GlyphiconHelper
|
27
|
-
ActionView::Base.send :include, IconHelper
|
28
|
-
ActionView::Base.send :include, LinkToHelper
|
29
|
-
ActionView::Base.send :include, ModalHelper
|
30
|
-
ActionView::Base.send :include, NavHelper
|
31
|
-
ActionView::Base.send :include, NavbarHelper
|
32
|
-
ActionView::Base.send :include, PanelHelper
|
33
|
-
ActionView::Base.send :include, PanelRowHelper
|
34
|
-
ActionView::Base.send :include, ProgressBarHelper
|
35
|
-
end
|
36
|
-
|
37
|
-
initializer 'bh.add_views' do |app|
|
38
|
-
views_path = File.dirname(__FILE__) + "/views"
|
39
|
-
ActionController::Base.prepend_view_path views_path
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/spec/dummy/index.html.erb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: default
|
3
|
-
---
|
4
|
-
<!-- Edit the code below to see how code looks in a browser -->
|
5
|
-
<!-- Note that only *a few* helpers are currently supported by Bh+Middleman,
|
6
|
-
so the use of this dummy file is currently limited to the helpers
|
7
|
-
listed below. The plan is to make all the helpers look in Middleman
|
8
|
-
in the future, as they do in Rails. -->
|
9
|
-
<h1>Alerts</h1>
|
10
|
-
|
11
|
-
<%= alert_box 'You accepted the Terms of service.', context: :success, dismissible: true %>
|
12
|
-
<%= alert_box 'You accepted the Terms of service.', context: :info, dismissible: true %>
|
13
|
-
<%= alert_box 'You accepted the Terms of service.', context: :warning, dismissible: true %>
|
14
|
-
<%= alert_box 'You accepted the Terms of service.', context: :danger, dismissible: true %>
|
15
|
-
<%= alert_box 'You accepted the Terms of service.', dismissible: true %>
|
16
|
-
|
17
|
-
|
18
|
-
<p>Alert boxes with HTML content currently not supported in Middleman.</p>
|
19
|
-
|
20
|
-
<h1>Panels</h1>
|
21
|
-
|
22
|
-
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks', context: :primary %>
|
23
|
-
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks', context: :success %>
|
24
|
-
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks', context: :info %>
|
25
|
-
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks', context: :warning %>
|
26
|
-
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks', context: :danger %>
|
27
|
-
<%= panel body: 'You accepted the Terms of service.', title: 'Thanks' %>
|
28
|
-
|
29
|
-
|
30
|
-
<p>Panels with HTML content currently not supported in Middleman.</p>
|
31
|
-
|
32
|
-
<h1>Panel rows</h1>
|
33
|
-
|
34
|
-
<p>Panel rows currently not supported in Middleman.</p>
|
35
|
-
|
36
|
-
<h1>Modals</h1>
|
37
|
-
|
38
|
-
<p>Modals currently not supported in Middleman.</p>
|
39
|
-
|
40
|
-
<h1>Navs</h1>
|
41
|
-
|
42
|
-
<p>Navs currently not supported in Middleman.</p>
|
43
|
-
|
44
|
-
<h1>Navbars</h1>
|
45
|
-
|
46
|
-
<p>Navbars currently not supported in Middleman.</p>
|
47
|
-
|
48
|
-
<h1>Forms</h1>
|
49
|
-
|
50
|
-
<p>Forms currently not supported in Middleman.</p>
|
51
|
-
|
52
|
-
<h1>Glyphicons</h1>
|
53
|
-
|
54
|
-
<%= icon :zoom_in %>
|
55
|
-
|
56
|
-
<h1>Icons</h1>
|
57
|
-
|
58
|
-
<%= icon :heart %>
|
59
|
-
<%= stylesheet_link_tag font_awesome_css %>
|
60
|
-
<%= icon :heart, library: :font_awesome, class: 'fa-5x' %>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
-
<%= stylesheet_link_tag font_awesome_css, bootstrap_css, bootstrap_theme_css %>
|
8
|
-
<title>Bh test page</title>
|
9
|
-
</head>
|
10
|
-
<body>
|
11
|
-
<div class='container'>
|
12
|
-
<%= yield %>
|
13
|
-
</div>
|
14
|
-
<%= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' %>
|
15
|
-
<%= javascript_include_tag bootstrap_js %>
|
16
|
-
</body>
|
17
|
-
</html>
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
require 'bh/helpers/alert_helper'
|
6
|
-
require 'bh/helpers/link_to_helper'
|
7
|
-
include Bh::AlertHelper
|
8
|
-
include Bh::LinkToHelper
|
9
|
-
|
10
|
-
describe 'alert_box' do
|
11
|
-
describe 'accepts as parameters:' do
|
12
|
-
let(:behave) { be_a String }
|
13
|
-
|
14
|
-
specify 'a string (message)' do
|
15
|
-
expect(alert_box 'message').to behave
|
16
|
-
end
|
17
|
-
|
18
|
-
specify 'a block (message)' do
|
19
|
-
expect(alert_box { 'message' }).to behave
|
20
|
-
end
|
21
|
-
|
22
|
-
specify 'a string (message) + a hash (options)' do
|
23
|
-
expect(alert_box 'message', context: :danger).to behave
|
24
|
-
end
|
25
|
-
|
26
|
-
specify 'a hash (options) + a block (message)' do
|
27
|
-
expect(alert_box(context: :danger) { 'message' }).to behave
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'with the :dismissible option' do
|
32
|
-
specify 'not set, does not show an × to dismiss the alert' do
|
33
|
-
expect(alert_box 'message').not_to include '×'
|
34
|
-
end
|
35
|
-
|
36
|
-
specify 'set to false, does not show an × to dismiss the alert' do
|
37
|
-
expect(alert_box 'message', dismissible: false).not_to include '×'
|
38
|
-
end
|
39
|
-
|
40
|
-
specify 'set to true, does not show an × to dismiss the alert' do
|
41
|
-
expect(alert_box 'message', dismissible: true).to include '×'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe 'with the :context option' do
|
46
|
-
specify 'set to :success, shows a "success" alert' do
|
47
|
-
expect(alert_box 'message', context: :success).to include 'alert-success'
|
48
|
-
end
|
49
|
-
|
50
|
-
specify 'set to :info, shows a "info" alert' do
|
51
|
-
expect(alert_box 'message', context: :info).to include 'alert-info'
|
52
|
-
end
|
53
|
-
|
54
|
-
specify 'set to :warning, shows a "warning" alert' do
|
55
|
-
expect(alert_box 'message', context: :warning).to include 'alert-warning'
|
56
|
-
end
|
57
|
-
|
58
|
-
specify 'set to :danger, shows a "danger" alert' do
|
59
|
-
expect(alert_box 'message', context: :danger).to include 'alert-danger'
|
60
|
-
end
|
61
|
-
|
62
|
-
specify 'set to any other value, shows an "info" alert' do
|
63
|
-
expect(alert_box 'message', context: :unknown).to include 'alert-info'
|
64
|
-
end
|
65
|
-
|
66
|
-
specify 'not set, shows an "info" alert' do
|
67
|
-
expect(alert_box 'message').to include 'alert-info'
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe 'with the :priority option' do
|
72
|
-
specify 'shows a dismissible alert' do
|
73
|
-
expect(alert_box 'message', priority: :notice).to include '×'
|
74
|
-
end
|
75
|
-
|
76
|
-
specify 'set to :notice, shows a "success" alert' do
|
77
|
-
expect(alert_box 'message', priority: :notice).to include 'alert-success'
|
78
|
-
end
|
79
|
-
|
80
|
-
specify 'set to :alert, shows a "danger" alert' do
|
81
|
-
expect(alert_box 'message', priority: :alert).to include 'alert-danger'
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'bh/helpers/button_helper'
|
5
|
-
include Bh::ButtonHelper
|
6
|
-
|
7
|
-
describe 'button' do
|
8
|
-
describe 'accepts as parameters:' do
|
9
|
-
let(:behave) { match %r{^<button class="btn.+?">content</button>} }
|
10
|
-
|
11
|
-
specify 'a string (content)' do
|
12
|
-
expect(button 'content').to behave
|
13
|
-
end
|
14
|
-
|
15
|
-
specify 'a block (content)' do
|
16
|
-
expect(button { 'content' }).to behave
|
17
|
-
end
|
18
|
-
|
19
|
-
specify 'a string (content) + a hash (options)' do
|
20
|
-
expect(button 'content', context: :danger).to behave
|
21
|
-
end
|
22
|
-
|
23
|
-
specify 'a hash (options) + a block (content)' do
|
24
|
-
expect(button(context: :danger) { 'content' }).to behave
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'with the :context option' do
|
29
|
-
let(:html) { button 'content', context: context }
|
30
|
-
|
31
|
-
describe 'set to :primary, shows a "primary" button' do
|
32
|
-
let(:context) { :primary }
|
33
|
-
it { expect(html).to include 'btn-primary' }
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'set to :success, shows a "success" button' do
|
37
|
-
let(:context) { :success }
|
38
|
-
it { expect(html).to include 'btn-success' }
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'set to :info, shows a "info" button' do
|
42
|
-
let(:context) { :info }
|
43
|
-
it { expect(html).to include 'btn-info' }
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'set to :warning, shows a "warning" button' do
|
47
|
-
let(:context) { :warning }
|
48
|
-
it { expect(html).to include 'btn-warning' }
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'set to :danger, shows a "danger" button' do
|
52
|
-
let(:context) { :danger }
|
53
|
-
it { expect(html).to include 'btn-danger' }
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'set to :link, shows a "link" button' do
|
57
|
-
let(:context) { :link }
|
58
|
-
it { expect(html).to include 'btn-link' }
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'set to any other value, shows a "default" button' do
|
62
|
-
let(:context) { :unknown }
|
63
|
-
it { expect(html).to include 'btn-default' }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe 'without the :context option, shows a "default" button' do
|
68
|
-
let(:html) { button 'content' }
|
69
|
-
it { expect(html).to include 'btn-default' }
|
70
|
-
end
|
71
|
-
|
72
|
-
describe 'with the :size option' do
|
73
|
-
let(:html) { button 'content', size: size }
|
74
|
-
|
75
|
-
describe 'set to :large, shows a large button' do
|
76
|
-
let(:size) { :large }
|
77
|
-
it { expect(html).to include 'btn-lg' }
|
78
|
-
end
|
79
|
-
|
80
|
-
describe 'set to :small, shows a small button' do
|
81
|
-
let(:size) { :small }
|
82
|
-
it { expect(html).to include 'btn-sm' }
|
83
|
-
end
|
84
|
-
|
85
|
-
describe 'set to :extra_small, shows an extra-small button' do
|
86
|
-
let(:size) { :extra_small }
|
87
|
-
it { expect(html).to include 'btn-xs' }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
describe 'with the :layout option' do
|
93
|
-
let(:html) { button 'content', layout: layout }
|
94
|
-
|
95
|
-
describe 'set to :block, shows a "block" button' do
|
96
|
-
let(:layout) { :block }
|
97
|
-
it { expect(html).to include 'btn-block' }
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|