effective_bootstrap 0.6.13 → 0.6.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3d04bbf79147ce531834750ed14cd478e0ade598109b99edb02c9ea802f699d
4
- data.tar.gz: 315e01d14c50b6ad3ec6f39b4981e5030b911a0a525b11f7dc5da6fe512bd020
3
+ metadata.gz: 3d09651afef44e467ac4bc172e6f6848b3c7b4f2963d397ff537d0eb3f6a09aa
4
+ data.tar.gz: 017f6dc69cf9ccbf155ce434d92507af48e4d2df2d44bc195002d3a03108fc4d
5
5
  SHA512:
6
- metadata.gz: 3f5ab04bf8c5217f683cc7897a2dd7b3ade20628cb1ecb63940901e774e8f1e0927d7109cdda6bfe0ca9de38103d3df90355ecdb9fb0248f3febc2d7e3342f31
7
- data.tar.gz: f9ff1619e0a42e7e7fe552ff7e6e5b5dc12c462e51ed119cadd8a0e11ead4a3f43513a1f62aa3984c355ac1d61949e5ce08e38e7b421d53e07dd96aac32f5d11
6
+ metadata.gz: a1ad447346b7471e0d189358e3db06a1aa65579abd361862e398009ec166055b3c3aeb33d57ba8bca3bbaa93caa3770ab41e22343367d8df4159e03d66dd806a
7
+ data.tar.gz: 2d754bdc159fb50a80f8a8ea8a15cc1a61528a1942da36f8012c08996018cba15d5044e7c2f53d3a3fc1469b32e578ea72272f34f3c2d3a45f50b233a4be0c27
@@ -1,6 +1,21 @@
1
1
  # Boostrap4 Helpers
2
2
 
3
3
  module EffectiveBootstrapHelper
4
+ # This is a special variant of collapse
5
+ # = accordion do
6
+ # = collapse('Add thing...') do
7
+ # %p Something to add
8
+ def accordion(options = nil, &block)
9
+ (options ||= {})[:class] = "accordion #{options.delete(:class)}".strip
10
+
11
+ id = "accordion-#{''.object_id}"
12
+
13
+ @_accordion_active = id
14
+ content = content_tag(:div, capture(&block), options.merge(id: id))
15
+ @_accordion_active = nil
16
+ content
17
+ end
18
+
4
19
  # https://getbootstrap.com/docs/4.0/components/collapse/
5
20
 
6
21
  # = collapse('toggle visibility') do
@@ -19,12 +34,29 @@ module EffectiveBootstrapHelper
19
34
  show = (opts.delete(:show) == true)
20
35
 
21
36
  link_opts = { 'data-toggle': 'collapse', role: 'button', href: "##{id}", 'aria-controls': "##{id}", 'aria-expanded': show }
37
+
38
+ link_opts[:class] = opts.delete(:link_class) || 'btn btn-link'
22
39
  div_class = opts.delete(:div_class)
23
40
  card_class = opts.delete(:card_class) || 'my-2'
24
41
 
25
- content_tag(:a, label, link_opts.merge(opts)) +
26
- content_tag(:div, id: id, class: ['collapse', div_class, ('show' if show)].compact.join(' ')) do
27
- content_tag(:div, capture(&block), class: ['card', 'card-body', card_class].compact.join(' '))
42
+ if @_accordion_active
43
+ # Accordion collapse
44
+ content_tag(:div, class: "card mb-0") do
45
+ content_tag(:div, class: "card-header") do
46
+ content_tag(:h2, class: "mb-0") do
47
+ content_tag(:button, label, link_opts.merge(class: "btn btn-link"))
48
+ end
49
+ end +
50
+ content_tag(:div, id: id, class: ['collapse', div_class, ('show' if show)].compact.join(' '), "data-parent": "##{@_accordion_active}") do
51
+ content_tag(:div, capture(&block), class: "card-body")
52
+ end
53
+ end
54
+ else
55
+ # Normal collapse
56
+ content_tag(:a, label, link_opts) +
57
+ content_tag(:div, id: id, class: ['collapse', div_class, ('show' if show)].compact.join(' ')) do
58
+ content_tag(:div, capture(&block), class: ['card', 'card-body', card_class].compact.join(' '))
59
+ end
28
60
  end
29
61
  end
30
62
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.6.13'.freeze
2
+ VERSION = '0.6.14'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.13
4
+ version: 0.6.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-31 00:00:00.000000000 Z
11
+ date: 2020-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails