nfg_ui 0.15.2 → 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
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
|
|
@@ -10,7 +10,16 @@ module NfgUi
|
|
|
10
10
|
include Bootstrap::Utilities::Activatable
|
|
11
11
|
include Bootstrap::Utilities::Disableable
|
|
12
12
|
include Bootstrap::Utilities::Tooltipable
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
# We do not want to overwrite button_to's interpretation
|
|
15
|
+
# of `remote`. Conditionally include Remotable
|
|
16
|
+
# when not using as: :button_to
|
|
17
|
+
def initialize(*)
|
|
18
|
+
super
|
|
19
|
+
if as != :button_to
|
|
20
|
+
extend Bootstrap::Utilities::Remotable
|
|
21
|
+
end
|
|
22
|
+
end
|
|
14
23
|
|
|
15
24
|
def component_family
|
|
16
25
|
:dropdown
|
|
@@ -12,7 +12,6 @@ module NfgUi
|
|
|
12
12
|
include NfgUi::Components::Utilities::Describable
|
|
13
13
|
include NfgUi::Components::Utilities::DisableWithable
|
|
14
14
|
include NfgUi::Components::Utilities::Iconable
|
|
15
|
-
include NfgUi::Components::Utilities::Methodable
|
|
16
15
|
include NfgUi::Components::Utilities::Renderable
|
|
17
16
|
include NfgUi::Components::Utilities::Traitable
|
|
18
17
|
|
|
@@ -22,24 +21,34 @@ module NfgUi
|
|
|
22
21
|
include NfgUi::Components::Traits::Disable
|
|
23
22
|
include NfgUi::Components::Traits::Theme
|
|
24
23
|
|
|
24
|
+
# We do not want to overwrite button_to's interpretation
|
|
25
|
+
# of `method`. Conditionally include Methodable
|
|
26
|
+
# when not using as: :button_to
|
|
27
|
+
def initialize(*)
|
|
28
|
+
super
|
|
29
|
+
if as != :button_to
|
|
30
|
+
extend NfgUi::Components::Utilities::Methodable
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
25
34
|
def render
|
|
26
35
|
if tooltip && disabled
|
|
27
36
|
content_tag(:span, disabled_component_tooltip_wrapper_html_options) do
|
|
28
37
|
content_tag(as, html_options.except(:href)) do
|
|
29
|
-
|
|
30
|
-
NfgUi::Components::Foundations::Icon.new({ traits: ["#{icon} fw"], text: (block_given? ? yield : body), class: 'text-center' }, view_context).render
|
|
31
|
-
else
|
|
32
|
-
(block_given? ? yield : body)
|
|
33
|
-
end
|
|
38
|
+
yield_icon_or_body
|
|
34
39
|
end
|
|
35
40
|
end
|
|
41
|
+
elsif as == :button_to
|
|
42
|
+
# Manually pass in url_for args for routing
|
|
43
|
+
# example: = ui.nfg :dropdown_item, as: :button_to, button_url: some_action_path(@object)
|
|
44
|
+
url_for_option = options.delete(:button_url)
|
|
45
|
+
|
|
46
|
+
view_context.button_to(url_for_option, html_options) do
|
|
47
|
+
yield_icon_or_body
|
|
48
|
+
end
|
|
36
49
|
else
|
|
37
50
|
super do
|
|
38
|
-
|
|
39
|
-
NfgUi::Components::Foundations::Icon.new({ traits: ["#{icon} fw"], text: (block_given? ? yield : body), class: 'text-center' }, view_context).render
|
|
40
|
-
else
|
|
41
|
-
(block_given? ? yield : body)
|
|
42
|
-
end
|
|
51
|
+
yield_icon_or_body
|
|
43
52
|
end
|
|
44
53
|
end
|
|
45
54
|
end
|
|
@@ -52,6 +61,14 @@ module NfgUi
|
|
|
52
61
|
|
|
53
62
|
private
|
|
54
63
|
|
|
64
|
+
def yield_icon_or_body
|
|
65
|
+
if icon
|
|
66
|
+
NfgUi::Components::Foundations::Icon.new({ traits: ["#{icon} fw"], text: (block_given? ? yield : body), class: 'text-center' }, view_context).render
|
|
67
|
+
else
|
|
68
|
+
(block_given? ? yield : body)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
55
72
|
def base_element
|
|
56
73
|
as
|
|
57
74
|
end
|
|
@@ -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:
|
|
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-
|
|
12
|
+
date: 2022-11-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bootstrap
|