nfg_ui 0.9.24.3 → 0.9.25
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: 255605aaf79082c250a38e2021f2cef46d06c90bca81af9912574ac62d110ecb
|
4
|
+
data.tar.gz: 21a793d0674e7bb9f4aacac84617f57ab118ffe2cf923ff341a2ca61db0fb688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44bf230b5ee51da2b00f3bd8bf2e0410bf67d80310887f15c0978a74beccd4c3dbfcf59b96bbae0b77909c42bcc31a1df82a8499366f262b9e822d6a9a9d1da3
|
7
|
+
data.tar.gz: a827a15667b221b27e064897d7de30ba8142a36f1cb5962be21c30ffdc4880a3ae50735b72fab76e5626d353258d4a0e1e9e47897b0dd6d2ce12c554cab8134c
|
@@ -5,12 +5,14 @@ module NfgUi
|
|
5
5
|
module Traits
|
6
6
|
# Access to pre-designed Alert traits
|
7
7
|
module Alert
|
8
|
+
include NfgUi::Components::Utilities::Traits::TraitUtilities
|
9
|
+
|
8
10
|
TRAITS = %i[tip].freeze
|
9
11
|
|
10
12
|
def tip_trait
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
maybe_update_option(:icon, value: NfgUi::DEFAULT_TIP_ICON)
|
14
|
+
maybe_update_option(:theme, value: NfgUi::DEFAULT_TIP_THEME)
|
15
|
+
maybe_update_option(:dismissible, value: false)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -5,6 +5,8 @@ module NfgUi
|
|
5
5
|
module Traits
|
6
6
|
# Access to pre-designed Icon traits
|
7
7
|
module Icon
|
8
|
+
include NfgUi::Components::Utilities::Traits::TraitUtilities
|
9
|
+
|
8
10
|
TRAITS = %i[loader tip].freeze
|
9
11
|
|
10
12
|
def loader_trait
|
@@ -15,11 +17,12 @@ module NfgUi
|
|
15
17
|
# Usage:
|
16
18
|
# ui.nfg :icon, :tip, tooltip: 'The tip'
|
17
19
|
def tip_trait
|
18
|
-
|
19
|
-
|
20
|
+
maybe_update_option(:icon, value: NfgUi::DEFAULT_TIP_ICON)
|
21
|
+
|
22
|
+
maybe_update_option(:theme, value: NfgUi::DEFAULT_TIP_THEME)
|
20
23
|
|
21
24
|
if options[:text].present?
|
22
|
-
|
25
|
+
maybe_update_option(:right, value: true)
|
23
26
|
options[:class] += ' fa-fw'
|
24
27
|
end
|
25
28
|
end
|
@@ -5,12 +5,13 @@ module NfgUi
|
|
5
5
|
module Traits
|
6
6
|
# Access to pre-designed traits
|
7
7
|
module Navbar
|
8
|
+
include NfgUi::Components::Utilities::Traits::TraitUtilities
|
9
|
+
|
8
10
|
TRAITS = %i[white].freeze
|
9
11
|
|
10
12
|
def white_trait
|
11
|
-
|
12
|
-
|
13
|
-
options[:theme] = :white
|
13
|
+
maybe_update_option(:light, value: true)
|
14
|
+
maybe_update_option(:theme, value: :white)
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NfgUi
|
4
|
+
module Components
|
5
|
+
module Utilities
|
6
|
+
module Traits
|
7
|
+
module TraitUtilities
|
8
|
+
private
|
9
|
+
|
10
|
+
# As a practice, traits are designed to help not rule.
|
11
|
+
#
|
12
|
+
# Leveraging this method to conditionally overwrite values in the options hash
|
13
|
+
# ensures that users of the gem are able to use
|
14
|
+
# traits and further customize them on the fly.
|
15
|
+
#
|
16
|
+
# Example:
|
17
|
+
# An example trait adjusts an icon and the theme.
|
18
|
+
# Gem user wants to customize the theme in a unique setting
|
19
|
+
# = ui.nfg :icon, :tip, theme: :danger
|
20
|
+
#
|
21
|
+
# Without using this #maybe_update_option method, `theme: :danger`
|
22
|
+
# would be ignored (and thus overwritten) by by the :tip trait
|
23
|
+
#
|
24
|
+
# Thus, when using this method, the :tip trait would first check if :theme option is present _before_
|
25
|
+
# setting the established trait's options[:theme] value.
|
26
|
+
#
|
27
|
+
# It may not always be necessary or appropriate to use this method. For example,
|
28
|
+
# Some traits modify only one value in options, and if that trait is being overwritten by a supplied option,
|
29
|
+
# it defeats the purpose of the trait.
|
30
|
+
#
|
31
|
+
# Example where method usage is not necessary:
|
32
|
+
# def active_trait
|
33
|
+
# options[:active] = true
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# Overall, trait creation doctrine really
|
37
|
+
# prefers usage of this method.
|
38
|
+
#
|
39
|
+
#
|
40
|
+
# Example Usage:
|
41
|
+
#
|
42
|
+
# def white_trait
|
43
|
+
# maybe_update_option(:light, value: true)
|
44
|
+
# maybe_update_option(:theme, value: :white)
|
45
|
+
# end
|
46
|
+
def maybe_update_option(option_key, value:)
|
47
|
+
return if options[option_key].present?
|
48
|
+
options[option_key] = value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
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: 0.9.
|
4
|
+
version: 0.9.25
|
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: 2019-11-
|
12
|
+
date: 2019-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bootstrap
|
@@ -749,6 +749,7 @@ files:
|
|
749
749
|
- lib/nfg_ui/components/utilities/resource_themeable.rb
|
750
750
|
- lib/nfg_ui/components/utilities/titleable.rb
|
751
751
|
- lib/nfg_ui/components/utilities/traitable.rb
|
752
|
+
- lib/nfg_ui/components/utilities/traits/trait_utilities.rb
|
752
753
|
- lib/nfg_ui/components/utilities/vertically_alignable.rb
|
753
754
|
- lib/nfg_ui/engine.rb
|
754
755
|
- lib/nfg_ui/ui/base.rb
|