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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ec7aa9c72ddbc58533cf76bf8eb8843f957bc2f79be9604f35a41948bbd03e4
|
4
|
+
data.tar.gz: 064e9a0da7b7d2721953348524dcc38f16cd9fb0bffcaca88fe181aa4d7b9e6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1237917f4abb0ab752d26a6c7af13169ed0a971c048cfeb1b984912dc54bfa58e7f6bdf312a9b54fa1108d8cf725fba038e0a876ee492522a7a53345ce99537b
|
7
|
+
data.tar.gz: 368f386c0683a11fb99060a79a60cd9d6b6870cf9299173b7a1cb7da865ce23c976af625397f6f2fd0c715999d6b266387efb66b8af02ef73792ac6d88696ace
|
@@ -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
|
-
|
75
|
-
|
76
|
-
content_tag(:div, class:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
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.
|
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-
|
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
|