effective_bootstrap 0.9.39 → 0.9.40

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac9e0d6013b991db010ef717fe181ea041d2d9e756e0bb477d9ff7544248b718
4
- data.tar.gz: f212aea0848dd0d7d50b0186b798ce9cb52d8c5e17bba7f4cfd63b69cc716861
3
+ metadata.gz: 3ec7aa9c72ddbc58533cf76bf8eb8843f957bc2f79be9604f35a41948bbd03e4
4
+ data.tar.gz: 064e9a0da7b7d2721953348524dcc38f16cd9fb0bffcaca88fe181aa4d7b9e6e
5
5
  SHA512:
6
- metadata.gz: a87134d9311b1837d06e9e37857c03930a52cb0c211a2bd1dd05276ecd7eca76d57615e71cea80b271b9f11a7469647ff4915f790330f19ddd8a2c185a0604c6
7
- data.tar.gz: 35fca4a527a44b58237cc6e71ab8846aa4da76d0f1c7e82078d272323bfb90be12ca16c4f27574603b118a90f5831753fb0e010bc7e5586626c982cf8be33901
6
+ metadata.gz: 1237917f4abb0ab752d26a6c7af13169ed0a971c048cfeb1b984912dc54bfa58e7f6bdf312a9b54fa1108d8cf725fba038e0a876ee492522a7a53345ce99537b
7
+ data.tar.gz: 368f386c0683a11fb99060a79a60cd9d6b6870cf9299173b7a1cb7da865ce23c976af625397f6f2fd0c715999d6b266387efb66b8af02ef73792ac6d88696ace
@@ -1,4 +1,4 @@
1
+ @import './collapse';
1
2
  @import './forms';
2
3
  @import './icons';
3
4
  @import './overrides';
4
-
@@ -0,0 +1,7 @@
1
+ .effective-collapse-actions {
2
+ .collapse-label-expand { display: none; }
3
+ .collapse-label-collapse { display: inline-block; }
4
+
5
+ &.collapsed .collapse-label-expand { display: inline-block; }
6
+ &.collapsed .collapse-label-collapse { display: none; }
7
+ }
@@ -18,6 +18,31 @@ module EffectiveBootstrapHelper
18
18
  content
19
19
  end
20
20
 
21
+ def accordion_collapse(label, opts = {}, &block)
22
+ raise 'expected a block' unless block_given?
23
+
24
+ id = "collapse-#{effective_bootstrap_unique_id}"
25
+ show = (opts.delete(:show) == true)
26
+
27
+ link_opts = { 'data-toggle': 'collapse', role: 'button', href: "##{id}", 'aria-controls': "##{id}", 'aria-expanded': show }
28
+
29
+ link_opts[:class] = opts.delete(:link_class) || 'btn btn-link'
30
+ div_class = opts.delete(:div_class)
31
+ card_class = opts.delete(:card_class) || 'card card-body my-2'
32
+
33
+ # Accordion collapse
34
+ content_tag(:div, class: "card mb-0") do
35
+ content_tag(:div, class: "card-header") do
36
+ content_tag(:h2, class: "mb-0") do
37
+ content_tag(:button, label, link_opts.merge(class: "btn btn-link"))
38
+ end
39
+ end +
40
+ content_tag(:div, id: id, class: ['collapse', div_class, ('show' if show)].compact.join(' '), "data-parent": "##{@_accordion_active}") do
41
+ content_tag(:div, capture(&block), class: "card-body")
42
+ end
43
+ end
44
+ end
45
+
21
46
  # https://getbootstrap.com/docs/4.0/components/card/
22
47
  # = card('title do')
23
48
  # %p Stuff
@@ -56,40 +81,67 @@ module EffectiveBootstrapHelper
56
81
  # = collapse('already expanded', show: true) do
57
82
  # %p Something Expanded
58
83
 
84
+ # the word 'show' will automatically be replaced with hide and an icon added
85
+ # = collapse('show items') do
86
+ # %p Something Expanded
87
+
88
+ # Override the expand and collapse labels directly
89
+ # = collapse('show items', expand: "Show items" + icon('ok'), collapse: "Hide items" + icon('x')) do
90
+ # %p Something Expanded
91
+
59
92
  # collapse(items.length, class: 'btn btn-primary', class: 'mt-2') do
60
93
  # items.map { |item| content_tag(:div, item.to_s) }.join.html_safe
61
94
  # end
95
+
96
+ COLLAPSE_SUBSTITUTIONS = {
97
+ 'Show ' => 'Hide ',
98
+ 'show ' => 'hide ',
99
+ 'Expand ' => 'Collapse ',
100
+ 'expand ' => 'collapse ',
101
+ ' More' => ' Less',
102
+ ' more' => ' less'
103
+ }
104
+
62
105
  def collapse(label, opts = {}, &block)
63
106
  raise 'expected a block' unless block_given?
64
107
 
108
+ return accordian_collapse(label, opts, &block) if @_accordion_active
109
+
65
110
  id = "collapse-#{effective_bootstrap_unique_id}"
66
111
  show = (opts.delete(:show) == true)
67
112
 
113
+ # Figure out all the button / link options
68
114
  link_opts = { 'data-toggle': 'collapse', role: 'button', href: "##{id}", 'aria-controls': "##{id}", 'aria-expanded': show }
69
115
 
116
+ # Two link labels
117
+ label_expand = opts.delete(:expand) || label.to_s.tap do |label|
118
+ COLLAPSE_SUBSTITUTIONS.each { |show, hide| label.sub!(hide, show) }
119
+ end + icon('chevron-down')
120
+
121
+ label_collapse = opts.delete(:collapse) || label.to_s.tap do |label|
122
+ COLLAPSE_SUBSTITUTIONS.each { |show, hide| label.sub!(show, hide) }
123
+ end + icon('chevron-up')
124
+
125
+ # The link html classes
70
126
  link_opts[:class] = opts.delete(:link_class) || 'btn btn-link'
127
+ link_opts[:class] += ' effective-collapse-actions hidden-print'
128
+ link_opts[:class] += ' collapsed' unless show
129
+
130
+ # The div and the card now
71
131
  div_class = opts.delete(:div_class)
72
132
  card_class = opts.delete(:card_class) || 'card card-body my-2'
73
133
 
74
- if @_accordion_active
75
- # Accordion collapse
76
- content_tag(:div, class: "card mb-0") do
77
- content_tag(:div, class: "card-header") do
78
- content_tag(:h2, class: "mb-0") do
79
- content_tag(:button, label, link_opts.merge(class: "btn btn-link"))
80
- end
81
- end +
82
- content_tag(:div, id: id, class: ['collapse', div_class, ('show' if show)].compact.join(' '), "data-parent": "##{@_accordion_active}") do
83
- content_tag(:div, capture(&block), class: "card-body")
84
- end
85
- end
86
- else
87
- # Normal collapse
88
- content_tag(:a, label, link_opts) +
89
- content_tag(:div, id: id, class: ['collapse', div_class, ('show' if show)].compact.join(' ')) do
90
- content_tag(:div, capture(&block), class: card_class)
91
- end
134
+ # Normal collapse
135
+ link_tag = content_tag(:a, link_opts) do
136
+ content_tag(:div, label_expand.html_safe, class: 'collapse-label-expand') +
137
+ content_tag(:div, label_collapse.html_safe, class: 'collapse-label-collapse')
138
+ end
139
+
140
+ div_tag = content_tag(:div, id: id, class: ['effective-collapse collapse', div_class, ('show' if show)].compact.join(' ')) do
141
+ content_tag(:div, capture(&block), class: card_class)
92
142
  end
143
+
144
+ link_tag + div_tag
93
145
  end
94
146
 
95
147
  # Button Dropdowns
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.9.39'.freeze
2
+ VERSION = '0.9.40'.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.9.39
4
+ version: 0.9.40
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: 2021-07-28 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -615,6 +615,7 @@ files:
615
615
  - app/assets/stylesheets/effective_article_editor/input.scss
616
616
  - app/assets/stylesheets/effective_bootstrap.scss
617
617
  - app/assets/stylesheets/effective_bootstrap/base.scss
618
+ - app/assets/stylesheets/effective_bootstrap/collapse.scss
618
619
  - app/assets/stylesheets/effective_bootstrap/forms.scss
619
620
  - app/assets/stylesheets/effective_bootstrap/icons.scss
620
621
  - app/assets/stylesheets/effective_bootstrap/overrides.scss