nfg_ui 5.15.3 → 5.15.4
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 +4 -4
- data/lib/nfg_ui/components/patterns/collapse.rb +27 -1
- data/lib/nfg_ui/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 44a92bdd16747ddbe83d9bc5bf872094e7344d6205391b356d8c5e01cc2209cb
|
|
4
|
+
data.tar.gz: 2dc7bdf3bfcad4046d0ea6162d36d3b1e6a3a023e83f0813f88d6e393ca16da6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2557d3579278fd434faa9d0c1e246f95d3fc4ba4eaf7d320b1c9f7e284f4eb74800147e6c06ad9946ae70969db4d3f52d17b4539ae320c92cc533257158428b
|
|
7
|
+
data.tar.gz: beca0a9fcebd58ab9cf36bbe2d4f6f598a3a7d5698092b0a90e6554ab4b632cf0f1cccf1314220b0f1f52f83832dd20d65050272cacc3eebbd9de3a77698cfb7
|
|
@@ -15,16 +15,42 @@ module NfgUi
|
|
|
15
15
|
|
|
16
16
|
include NfgUi::Components::Traits::Collapse
|
|
17
17
|
|
|
18
|
+
# Because it is common to forget to add the required :id
|
|
19
|
+
# to the component options when doing a "speed built"
|
|
20
|
+
# collapse, example:
|
|
21
|
+
# = ui.nfg :collapse, :collapsed, body: 'Collapse body content', heading: 'My Link'
|
|
22
|
+
#
|
|
23
|
+
# Send in a random string that is carried through
|
|
24
|
+
# from the speed built heading / button AND
|
|
25
|
+
# to the collapse component.
|
|
26
|
+
def component_initialize
|
|
27
|
+
# Only create and supply a random ID this when a :heading is present
|
|
28
|
+
return unless heading
|
|
29
|
+
new_id = options[:id].nil? ? random_id : options[:id]
|
|
30
|
+
options[:id] = new_id
|
|
31
|
+
end
|
|
32
|
+
|
|
18
33
|
def render
|
|
19
34
|
capture do
|
|
20
35
|
if heading
|
|
21
|
-
|
|
36
|
+
icon = options.fetch(:icon, 'caret-down')
|
|
37
|
+
opts = { collapse: "##{html_options[:id]}", body: heading, icon: icon, class: 'pl-0 text-left' }
|
|
22
38
|
opts.merge!(traits: [:link, :block])
|
|
23
39
|
concat(NfgUi::Components::Elements::Button.new(opts, view_context).render)
|
|
24
40
|
end
|
|
25
41
|
concat(super)
|
|
26
42
|
end
|
|
27
43
|
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
# Generate a string of random letters
|
|
48
|
+
# We must insert a random letter before SecureRandom because
|
|
49
|
+
# if a css ID starts with a number, it seems to break
|
|
50
|
+
# the collapse JS functionality.
|
|
51
|
+
def random_id
|
|
52
|
+
"#{('a'..'z').to_a.sample}-#{SecureRandom.alphanumeric(6)}"
|
|
53
|
+
end
|
|
28
54
|
end
|
|
29
55
|
end
|
|
30
56
|
end
|
data/lib/nfg_ui/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nfg_ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.15.
|
|
4
|
+
version: 5.15.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Roehm
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2022-11-
|
|
12
|
+
date: 2022-11-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bootstrap
|