booties 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/booties/application_helper.rb +3 -3
- data/app/helpers/booties/badge_helper.rb +11 -26
- data/app/helpers/booties/flag_helper.rb +9 -32
- data/app/helpers/booties/modal_helper.rb +4 -2
- data/app/helpers/booties/panel_helper.rb +3 -1
- data/app/helpers/booties/popover_helper.rb +63 -0
- data/app/helpers/booties/tooltip_helper.rb +21 -15
- data/lib/booties/modal.rb +33 -20
- data/lib/booties/panel.rb +55 -23
- data/lib/booties/utils.rb +9 -1
- data/lib/booties/version.rb +1 -1
- data/test/booties/modal_test.rb +36 -2
- data/test/booties/panel_test.rb +38 -14
- data/test/booties/utils_test.rb +5 -1
- data/test/dummy/app/controllers/home_controller.rb +3 -0
- data/test/dummy/app/views/home/modal.html.erb +1 -1
- data/test/dummy/app/views/home/panel.html.erb +11 -7
- data/test/dummy/app/views/home/popover.html.erb +7 -0
- data/test/dummy/config/routes.rb +1 -0
- data/test/dummy/log/test.log +8190 -0
- data/test/dummy/test/controllers/home_controller_test.rb +34 -12
- data/test/helpers/booties/badge_helper_test.rb +10 -0
- data/test/helpers/booties/flag_helper_test.rb +2 -2
- data/test/helpers/booties/modal_helper_test.rb +32 -2
- data/test/helpers/booties/popover_helper_test.rb +78 -0
- data/test/helpers/booties/tooltip_helper_test.rb +9 -2
- data/test/stub_view.rb +2 -2
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26c9342f582bef04df2c91615687875cb6b1cc8e
|
4
|
+
data.tar.gz: ce82e3caf2e664fa0a2c3b0c70323948ad547e25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 695beda958a1627ba5bab7cf35c8305fce7990895931c6fc13ada1cf050af21043be34ab7a2f055f7ec88cefc99f7b8c75d63bdf27df59441dd01306258b7891
|
7
|
+
data.tar.gz: b223bdd46a3ce55f2a40b5b80e85aa46401f4e440756e24565518a1bb21220da81feb198ed95904dfa84201d7fae48b7fdbff2a63e58a2d89ea828bb983aa5d1
|
@@ -4,7 +4,9 @@ module Booties
|
|
4
4
|
|
5
5
|
##
|
6
6
|
# Renders an ol tag with the "breadcrumb" class and fills it with the
|
7
|
-
# content of the block.
|
7
|
+
# content of the block.
|
8
|
+
#
|
9
|
+
# Example:
|
8
10
|
#
|
9
11
|
# <% breadcrumbs do %>
|
10
12
|
# <li>Foo</li>
|
@@ -12,8 +14,6 @@ module Booties
|
|
12
14
|
# <% end %>
|
13
15
|
# <%= yield :breadcrumb %>
|
14
16
|
#
|
15
|
-
# will produce:
|
16
|
-
#
|
17
17
|
# <ol class="breadcrumb">
|
18
18
|
# <li>Foo</li>
|
19
19
|
# <li class="active">Bar</li>
|
@@ -3,43 +3,28 @@ module Booties
|
|
3
3
|
include Utils
|
4
4
|
|
5
5
|
##
|
6
|
-
# Renders a
|
7
|
-
#
|
6
|
+
# Renders a Bootstrap badge. The text inside the badge may passed in
|
7
|
+
# through +content+ or with a block. Additional HTML attributes may be
|
8
|
+
# passed in through the +options+ hash.
|
8
9
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# will produce:
|
10
|
+
# Examples:
|
12
11
|
#
|
12
|
+
# <%= badge 'foo' %>
|
13
13
|
# <span class="badge">foo</span>
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# will produce:
|
20
|
-
#
|
15
|
+
# <%= badge do %>
|
16
|
+
# foo
|
17
|
+
# <% end %>
|
21
18
|
# <span class="badge">foo</span>
|
22
19
|
#
|
23
|
-
# Any options passed in through +options+ will be passed to #content_tag to
|
24
|
-
# be added as attributes to the span tag. The following:
|
25
|
-
#
|
26
20
|
# <%= badge 'foo', id: 'bar' %>
|
27
|
-
#
|
28
|
-
# will produce:
|
29
|
-
#
|
30
21
|
# <span class="badge" id="bar">foo</span>
|
31
22
|
#
|
32
|
-
# If the +:class+ option is passed in, the contents will be merged with the
|
33
|
-
# classes required by Bootstrap badges. The following:
|
34
|
-
#
|
35
23
|
# <%= badge 'foo', class: 'bar' %>
|
36
|
-
#
|
37
|
-
# will produce:
|
38
|
-
#
|
39
24
|
# <span class="badge bar">foo</span>
|
40
|
-
def badge(content = nil, **options, &block)
|
41
|
-
content ||= capture
|
42
|
-
classes = merge_classes ['badge'],
|
25
|
+
def badge(content = nil, class: nil, **options, &block)
|
26
|
+
content ||= capture(&block) if block_given?
|
27
|
+
classes = merge_classes ['badge'], binding.local_variable_get(:class)
|
43
28
|
content_tag :span, content, class: classes, **options
|
44
29
|
end
|
45
30
|
end
|
@@ -3,56 +3,33 @@ module Booties
|
|
3
3
|
include Utils
|
4
4
|
|
5
5
|
##
|
6
|
-
# Renders a
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# Renders a Bootstrap label. The label text may be passed in through
|
7
|
+
# +content+ or as a block. The +context+ keyword may be used to specify the
|
8
|
+
# label context; the default context is +:default+. Additional HTML
|
9
|
+
# attributes may be passed in through the +options+ hash.
|
9
10
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# will produce:
|
11
|
+
# Examples:
|
13
12
|
#
|
13
|
+
# <%= flag 'foo' %>
|
14
14
|
# <span class="label label-default">foo</span>
|
15
15
|
#
|
16
|
-
# Alternatively, you can pass the content in as a block. The following:
|
17
|
-
#
|
18
16
|
# <%= flag do %>
|
19
17
|
# foo
|
20
18
|
# <% end %>
|
21
|
-
#
|
22
|
-
# will produce:
|
23
|
-
#
|
24
19
|
# <span class="label label-default">foo</span>
|
25
20
|
#
|
26
|
-
# You can provide a different context for the label as +context+. The
|
27
|
-
# following:
|
28
|
-
#
|
29
21
|
# <%= flag 'foo', context: :primary %>
|
30
|
-
#
|
31
|
-
# will produce:
|
32
|
-
#
|
33
22
|
# <span class="label label-primary">foo</span>
|
34
23
|
#
|
35
|
-
# Additional options passed in through +options+ will be passed to
|
36
|
-
# #content_tag to be added as attributes to the span tag. The following:
|
37
|
-
#
|
38
24
|
# <%= flag 'foo', id: 'bar' %>
|
39
|
-
#
|
40
|
-
# will produce:
|
41
|
-
#
|
42
25
|
# <span class="label label-default" id="bar">foo</span>
|
43
26
|
#
|
44
|
-
# If the +:class+ option is passed in the contents will be merged with the
|
45
|
-
# classes required by Bootstrap labels. The following:
|
46
|
-
#
|
47
27
|
# <%= flag 'foo', class: 'bar' %>
|
48
|
-
#
|
49
|
-
# will produce:
|
50
|
-
#
|
51
28
|
# <span class="label label-default bar">foo</span>
|
52
|
-
def flag(content = nil, context: :default, **options, &block)
|
53
|
-
content ||= capture
|
29
|
+
def flag(content = nil, context: :default, class: nil, **options, &block)
|
30
|
+
content ||= capture(&block)
|
54
31
|
classes = merge_classes %W[label label-#{context}],
|
55
|
-
|
32
|
+
binding.local_variable_get(:class)
|
56
33
|
content_tag :span, content, class: classes, **options
|
57
34
|
end
|
58
35
|
end
|
@@ -8,6 +8,8 @@ module Booties
|
|
8
8
|
# Booties::Modal will be yielded as a parameter to the block (similar to
|
9
9
|
# the way a FormBuilder works in Rails).
|
10
10
|
#
|
11
|
+
# Example:
|
12
|
+
#
|
11
13
|
# <%= modal 'foo' do |m| %>
|
12
14
|
# <%= m.header do %>
|
13
15
|
# Nesciunt qui iste vel a.
|
@@ -27,8 +29,8 @@ module Booties
|
|
27
29
|
# <% end %>
|
28
30
|
# <% end %>
|
29
31
|
# <% end %>
|
30
|
-
def modal(id, fade: true, with: Modal, &block)
|
31
|
-
with.new(self, id: id, fade: fade).render &block
|
32
|
+
def modal(id, fade: true, size: nil, with: Modal, **options, &block)
|
33
|
+
with.new(self, id: id, fade: fade, size: size).render(**options, &block)
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
@@ -6,6 +6,8 @@ module Booties
|
|
6
6
|
# in as a block. An instance of the Booties::Panel will be yielded as a
|
7
7
|
# parameter to the block (similar to the way a FormBuilder works in Rails).
|
8
8
|
#
|
9
|
+
# Example:
|
10
|
+
#
|
9
11
|
# <%= panel do |p| %>
|
10
12
|
# <%= p.heading do %>
|
11
13
|
# <%= p.title 'Consequatur quibusdam quia vel et sed in.' %>
|
@@ -21,7 +23,7 @@ module Booties
|
|
21
23
|
# <% end %>
|
22
24
|
# <% end %>
|
23
25
|
def panel(with: Panel, **options, &block)
|
24
|
-
with.new(self, **options).render
|
26
|
+
with.new(self, **options).render(&block)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Booties
|
2
|
+
module PopoverHelper
|
3
|
+
include Utils
|
4
|
+
|
5
|
+
##
|
6
|
+
# Generates a popover toggle. The text of the toggle is provided by +text+
|
7
|
+
# or else it is captured from +block+.
|
8
|
+
#
|
9
|
+
# The required parameter +content+ provides the main body of text for the
|
10
|
+
# popup. An optional title can be provided with the +title+ parameter. The
|
11
|
+
# +placement+ parameter can be used to control the placement of the window;
|
12
|
+
# valid placements are :left, :right, :top, and :bottom.
|
13
|
+
#
|
14
|
+
# The default behavior of the popover is to close when the user clicks the
|
15
|
+
# toggle a second time. If the +trigger+ option is passed in with a truthy
|
16
|
+
# value, the popover will instead close when the user clicks anywhere
|
17
|
+
# outside the toggle.
|
18
|
+
#
|
19
|
+
# The default output tag is an anchor (<A>), but you can use the +tag+
|
20
|
+
# parameter to use a different tag, e.g., :button to output a <BUTTON> tag.
|
21
|
+
#
|
22
|
+
# Any remaining options are passed through to #content_tag to be included
|
23
|
+
# as is.
|
24
|
+
#
|
25
|
+
# A caveat: Bootstrap popovers are opt-in. You must initialize them
|
26
|
+
# yourself. One way to do this is to include the following Javascript
|
27
|
+
# snippet on the page:
|
28
|
+
#
|
29
|
+
# $(function() {
|
30
|
+
# $('[data-toggler="popover"]').popover();
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# Examples:
|
34
|
+
#
|
35
|
+
# <%= popover 'Link text', content: 'Lorem ipsum dolor sit amet.' %>
|
36
|
+
# <a role="button" data-toggle="popover" data-content="Lorem ipsum dolor sit amet.">Link text</a>
|
37
|
+
#
|
38
|
+
# <%= popover tag: :button, content: 'Lorem ipsum dolor sit amet.', title: 'Lorem ipsum', placement: :top, trigger: 'focus', class: 'btn btn-default' do %>
|
39
|
+
# Link text
|
40
|
+
# <% end %>
|
41
|
+
# <button class="btn btn-default" type="button" data-toggle="popover" data-content="Lorem ipsum dolor sit amet." data-placement="top" data-container="body" data-trigger="focus" title="Lorem ipsum">Link text</button>
|
42
|
+
def popover(text = nil, tag: :a, content:, title: nil, placement: nil, trigger: nil, **html_options, &block)
|
43
|
+
data = { toggle: 'popover', content: content, }
|
44
|
+
|
45
|
+
if placement
|
46
|
+
validate_placement! placement
|
47
|
+
data[:placement] = placement
|
48
|
+
end
|
49
|
+
|
50
|
+
if trigger
|
51
|
+
data[:container] = 'body'
|
52
|
+
data[:trigger] = 'focus'
|
53
|
+
end
|
54
|
+
|
55
|
+
role_or_type = tag == :button ? :type : :role
|
56
|
+
html_options[role_or_type] ||= 'button'
|
57
|
+
html_options[:data] ||= {}
|
58
|
+
html_options[:data].update data
|
59
|
+
|
60
|
+
content_tag tag, text, **html_options, title: title, &block
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,10 +1,18 @@
|
|
1
1
|
module Booties
|
2
2
|
module TooltipHelper
|
3
|
+
include Utils
|
4
|
+
|
3
5
|
##
|
4
6
|
# Wraps the content provided by +block+ with a Bootstrap tooltip. The text
|
5
|
-
# of the tooltip is passed in through the required +title+ parameter.
|
6
|
-
#
|
7
|
-
#
|
7
|
+
# of the tooltip is passed in through the required +title+ parameter.
|
8
|
+
#
|
9
|
+
# The optional +placement+ parameter can be used to control alignment of
|
10
|
+
# the tooltip. Valid placements are :top, :bottom, :left, and :right.
|
11
|
+
#
|
12
|
+
# The optional +wrapper_tag+ parameter can be used to specify an
|
13
|
+
# alternative container tag for the tooltip. (The default is to use a span
|
14
|
+
# tag.)
|
15
|
+
#
|
8
16
|
# Additional paramters given in +options+ are passed through to
|
9
17
|
# #content_tag to be placed on the resulting tag.
|
10
18
|
#
|
@@ -12,37 +20,35 @@ module Booties
|
|
12
20
|
# yourself. One way to do this is to include the following Javascript
|
13
21
|
# snippet on the page:
|
14
22
|
#
|
15
|
-
# $(function() {
|
23
|
+
# $(function() {
|
24
|
+
# $('[data-toggle="tooltip"]').tooltip();
|
25
|
+
# }
|
16
26
|
#
|
17
27
|
# Examples:
|
18
28
|
#
|
19
29
|
# <%= tooltip title: 'This is a tooltip' do %>
|
20
30
|
# This has a tooltip.
|
21
31
|
# <% end %>
|
22
|
-
#
|
23
32
|
# <span data-toggle="tooltip" title="This is a tooltip">This has a tooltip.</span>
|
24
33
|
#
|
25
34
|
# <%= tooltip title: 'This is a tooltip', placement: :bottom %>
|
26
35
|
# This has a tooltip.
|
27
36
|
# <% end %>
|
28
|
-
#
|
29
37
|
# <span data-toggle="tooltip" data-placement="bottom" title="This is a tooltip">This has a tooltip.</span>
|
30
38
|
#
|
31
39
|
# <%= tooltip title: 'This is a tooltip', class: 'tooltip' %>
|
32
40
|
# This has a tooltip.
|
33
41
|
# <% end %>
|
34
|
-
#
|
35
42
|
# <span data-toggle="tooltip" title="This is a tooltip" class="tooltip">This has a tooltip.</span>
|
36
|
-
def tooltip(title:, placement: nil, **options, &block)
|
37
|
-
|
38
|
-
raise ArgumentError, "invalid placement: #{placement.inspect}," \
|
39
|
-
' valid placements are: :top, :bottom, :right, :left'
|
40
|
-
end
|
43
|
+
def tooltip(title:, placement: nil, wrapper_tag: :span, **options, &block)
|
44
|
+
data = { toggle: 'tooltip', }
|
41
45
|
|
42
|
-
|
43
|
-
|
46
|
+
if placement
|
47
|
+
validate_placement! placement
|
48
|
+
data[:placement] = placement
|
49
|
+
end
|
44
50
|
|
45
|
-
content_tag
|
51
|
+
content_tag wrapper_tag, data: data, title: title, **options, &block
|
46
52
|
end
|
47
53
|
end
|
48
54
|
end
|
data/lib/booties/modal.rb
CHANGED
@@ -2,20 +2,23 @@ require 'forwardable'
|
|
2
2
|
|
3
3
|
module Booties
|
4
4
|
class Modal
|
5
|
+
include Utils
|
5
6
|
extend Forwardable
|
6
7
|
|
8
|
+
DEFAULT_DISMISSAL = '×'.freeze
|
9
|
+
MODAL_SIZE = { small: 'modal-sm', large: 'modal-lg' }.freeze
|
10
|
+
|
7
11
|
##
|
8
12
|
# Instantiates a new Modal. Several helper methods like #content_tag will
|
9
13
|
# be delegated to +view_context+. The required keyword +id+ will be used as
|
10
14
|
# the DOM ID of the modal element. By default, the modal will exhibit
|
11
15
|
# fading behavior, but this can be disabled by setting +fade+ to a falsey
|
12
16
|
# value.
|
13
|
-
|
14
|
-
# TODO: Pass additional arguments as attributes to top-level div.
|
15
|
-
def initialize(view_context, id:, fade: true)
|
17
|
+
def initialize(view_context, id:, fade: true, size: nil)
|
16
18
|
@view_context = view_context
|
17
19
|
@id = id
|
18
20
|
@fade = fade ? 'fade' : nil
|
21
|
+
@size = MODAL_SIZE[size]
|
19
22
|
end
|
20
23
|
|
21
24
|
def_delegators :@view_context, :button_tag, :capture, :content_tag,
|
@@ -25,9 +28,10 @@ module Booties
|
|
25
28
|
# Renders the top-level div for the modal dialog. +block+ is passed to
|
26
29
|
# #dialog to fill in the content of the modal. +@id+ is used as the DOM ID
|
27
30
|
# of the modal. +@fade+ is used to include or exclude fading behavior.
|
28
|
-
def render(&block)
|
29
|
-
|
30
|
-
|
31
|
+
def render(**options, &block)
|
32
|
+
classes = merge_classes ['modal', @fade], options.delete(:class)
|
33
|
+
content_tag :div, class: classes, id: @id, **options do
|
34
|
+
dialog(&block)
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
@@ -35,8 +39,8 @@ module Booties
|
|
35
39
|
# Renders the dialog section of the modal. +block+ is passed to #content to
|
36
40
|
# fill in the content of the dialog.
|
37
41
|
def dialog(&block)
|
38
|
-
content_tag :div, class: 'modal-dialog' do
|
39
|
-
content
|
42
|
+
content_tag :div, class: ['modal-dialog', @size] do
|
43
|
+
content(&block)
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
@@ -51,17 +55,26 @@ module Booties
|
|
51
55
|
end
|
52
56
|
|
53
57
|
##
|
54
|
-
# Renders the header section of a modal.
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
# Renders the header section of a modal.
|
59
|
+
#
|
60
|
+
# +block+ will be passed to #title to generate the title portion included
|
61
|
+
# within the header.
|
62
|
+
#
|
63
|
+
# If +close+ is truthy, a dismissal button will be rendered within the
|
64
|
+
# header as well. The default is +true+. The default dismissal is a
|
65
|
+
# +×+ symbol, but this can be customized by adding a translation for
|
66
|
+
# +booties.modal.dismiss_html+ or +booties.modal.dismiss+.
|
67
|
+
|
68
|
+
# TODO: rename +close+ option to +dismissible+?
|
69
|
+
def header(close: true, &block)
|
63
70
|
content_tag :div, class: 'modal-header' do
|
64
|
-
|
71
|
+
if close
|
72
|
+
dismissal = t :'booties.modal.dismiss_html',
|
73
|
+
default: [:'booties.modal.dismiss', raw(DEFAULT_DISMISSAL)]
|
74
|
+
dismiss(dismissal) << title(&block)
|
75
|
+
else
|
76
|
+
title(&block)
|
77
|
+
end
|
65
78
|
end
|
66
79
|
end
|
67
80
|
|
@@ -85,7 +98,7 @@ module Booties
|
|
85
98
|
#
|
86
99
|
# #title is called automatically from #header.
|
87
100
|
def title(content = nil, &block)
|
88
|
-
content ||= capture
|
101
|
+
content ||= capture(&block)
|
89
102
|
content_tag :h4, content, class: 'modal-title'
|
90
103
|
end
|
91
104
|
|
@@ -95,7 +108,7 @@ module Booties
|
|
95
108
|
# +block+. Additional HTML attributes for the button can be passed in
|
96
109
|
# through +options+.
|
97
110
|
def dismiss(content = nil, **options, &block)
|
98
|
-
content ||= capture
|
111
|
+
content ||= capture(&block)
|
99
112
|
options[:class] ||= 'close'
|
100
113
|
options.update data: { dismiss: 'modal' }, type: 'button'
|
101
114
|
button_tag content, options
|
data/lib/booties/panel.rb
CHANGED
@@ -5,15 +5,32 @@ module Booties
|
|
5
5
|
include Utils
|
6
6
|
extend Forwardable
|
7
7
|
|
8
|
+
CSS_CLASSES = {
|
9
|
+
heading: 'panel-heading'.freeze,
|
10
|
+
title: 'panel-title'.freeze,
|
11
|
+
body: 'panel-body'.freeze,
|
12
|
+
footer: 'panel-footer'.freeze,
|
13
|
+
}
|
14
|
+
|
8
15
|
##
|
9
16
|
# Instantiates a new Panel. Several helper methods like #content_tag will
|
10
|
-
# be delegated to +view_context+.
|
11
|
-
#
|
17
|
+
# be delegated to +view_context+.
|
18
|
+
#
|
19
|
+
# The optional +context+ argument can be passed in to specify the panel
|
20
|
+
# context; otherwise, the context +:default+ is used.
|
21
|
+
#
|
22
|
+
# The default behavior is to use a +div+ tag for to top-level panel
|
23
|
+
# container, but you may specify a different tag using the +wrapper_tag+
|
24
|
+
# keyword. (There are no guarantees on whether or not other tags will work
|
25
|
+
# correctly with Bootstrap panels.
|
26
|
+
#
|
12
27
|
# Any additional options will be included as attributes on the top-level
|
13
|
-
# panel
|
14
|
-
def initialize(view_context, context: :default, **options)
|
28
|
+
# panel container.
|
29
|
+
def initialize(view_context, context: :default, wrapper_tag: 'div', **options)
|
15
30
|
@view_context = view_context
|
31
|
+
@wrapper_tag = wrapper_tag
|
16
32
|
@context = context
|
33
|
+
# TODO: pass options to #render instead of constructor
|
17
34
|
@options = options
|
18
35
|
end
|
19
36
|
|
@@ -25,43 +42,58 @@ module Booties
|
|
25
42
|
# object will be passed as a parameter to +block+.
|
26
43
|
def render(&block)
|
27
44
|
options = @options.dup
|
28
|
-
classes = merge_classes %W[panel panel-#@context],
|
29
|
-
|
30
|
-
content_tag :div, class: classes, **options do
|
45
|
+
classes = merge_classes %W[panel panel-#@context], options.delete(:class)
|
46
|
+
content_tag @wrapper_tag, class: classes, **options do
|
31
47
|
capture self, &block
|
32
48
|
end
|
33
49
|
end
|
34
50
|
|
35
51
|
##
|
36
52
|
# Renders the panel heading. The content of the heading can be passed in
|
37
|
-
# through the +content+ parameter or as a block.
|
38
|
-
|
39
|
-
|
40
|
-
|
53
|
+
# through the +content+ parameter or as a block. If +class+ is given, it
|
54
|
+
# will be merged with the required panel heading class. Additional keyword
|
55
|
+
# arguments will be passed as an options Hash to #content_tag.
|
56
|
+
def heading(content = nil, class: nil, **options, &block)
|
57
|
+
content ||= capture(&block)
|
58
|
+
classes = merge_classes CSS_CLASSES[:heading],
|
59
|
+
binding.local_variable_get(:class)
|
60
|
+
content_tag :div, content, class: classes, **options
|
41
61
|
end
|
42
62
|
|
43
63
|
##
|
44
64
|
# Renders the panel title. The content of the title can be passed in
|
45
|
-
# through the +content+ paramter or as a block.
|
46
|
-
|
47
|
-
|
48
|
-
|
65
|
+
# through the +content+ paramter or as a block. If +class+ is given, it
|
66
|
+
# will be merged with the required panel title class. Additional keyword
|
67
|
+
# arguments will be passed as an options Hash to #content_tag.
|
68
|
+
def title(content = nil, class: nil, **options, &block)
|
69
|
+
content ||= capture(&block)
|
70
|
+
classes = merge_classes CSS_CLASSES[:title],
|
71
|
+
binding.local_variable_get(:class)
|
72
|
+
content_tag :h3, content, class: classes, **options
|
49
73
|
end
|
50
74
|
|
51
75
|
##
|
52
76
|
# Renders the panel body. The content of the body can be passed in through
|
53
|
-
# the +content+ parameter or as a block.
|
54
|
-
|
55
|
-
|
56
|
-
|
77
|
+
# the +content+ parameter or as a block. If +class+ is given, it will be
|
78
|
+
# merged with the required panel body class. Additional keyword arguments
|
79
|
+
# will be passed as an options Hash to #content_tag.
|
80
|
+
def body(content = nil, class: nil, **options, &block)
|
81
|
+
content ||= capture(&block)
|
82
|
+
classes = merge_classes CSS_CLASSES[:body],
|
83
|
+
binding.local_variable_get(:class)
|
84
|
+
content_tag :div, content, class: classes, **options
|
57
85
|
end
|
58
86
|
|
59
87
|
##
|
60
88
|
# Renders the panel footer. The content of the footer can be passed in
|
61
|
-
# through the +content+ parameter or as a block.
|
62
|
-
|
63
|
-
|
64
|
-
|
89
|
+
# through the +content+ parameter or as a block. If +class+ is given, it
|
90
|
+
# will be merged with the required panel footer class. Additional keyword
|
91
|
+
# arguments will be passed as an options Hash to #content_tag.
|
92
|
+
def footer(content = nil, class: nil, **options, &block)
|
93
|
+
content ||= capture(&block)
|
94
|
+
classes = merge_classes CSS_CLASSES[:footer],
|
95
|
+
binding.local_variable_get(:class)
|
96
|
+
content_tag :div, content, class: classes, **options
|
65
97
|
end
|
66
98
|
end
|
67
99
|
end
|