spark-component 1.1.3 → 1.1.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/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/spark/component/attribute.rb +22 -0
- data/lib/spark/component/element.rb +2 -1
- data/lib/spark/component/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: 55e7c87e7b78b2e073ed5d8ba8612f51fd038aa4a91902782930a5a2367d305b
|
4
|
+
data.tar.gz: b13756de2909fef4c1cdc93b1e674350c5c100c0b1109c6ba001187081f5cfd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69753141da46b8361c76f0dd895ae440c123e5ece47f71a17bd9e95aa4a8c597c74a576d39c882fdcd33eb38afabd6d15a8dedab164d1bb4d1f2b8b688058da5
|
7
|
+
data.tar.gz: 1a04eab2d9d35cdb8e691173d14f5874e94ecbee3d82ae5b823dadb71c07fa1537f28909a4eda3cdbec93e4648c4d5f604f47e56ba96906255996f922fb4a06b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# v1.1.4 - 2020-01-28
|
2
|
+
- Fix: attrtibute_default_group now accepts booleans and normalizes keys.
|
3
|
+
- Fix: element_attribute_default now merges attributes.
|
4
|
+
|
1
5
|
# v1.1.3 - 2020-01-15
|
2
6
|
- Fix: Extending a component will now extend its class defined tag attributes, aria attributes, and data attributes.
|
3
7
|
|
data/Gemfile.lock
CHANGED
@@ -75,12 +75,34 @@ module Spark
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
# Takes attributes passed to a component or element and assigns values to other
|
79
|
+
# attributes as defined in their group.
|
80
|
+
#
|
81
|
+
# For example, with an attribute group:
|
82
|
+
# theme: {
|
83
|
+
# notice: { icon: "message", color: "blue" }
|
84
|
+
# error: { icon: "error", color: "red" }
|
85
|
+
# }
|
86
|
+
#
|
87
|
+
# If the attributes include `theme: :notice`, the icon and color attributes
|
88
|
+
# would default to "message" and "blue", but could be overriden if the user
|
89
|
+
# set values for them.
|
90
|
+
#
|
78
91
|
def initialize_attribute_default_groups(attrs)
|
79
92
|
self.class.attribute_default_groups.each do |group, group_options|
|
80
93
|
# Determine what group name is set for this attribute.
|
94
|
+
# In the above example the group would be `theme` and the name
|
95
|
+
# would be the value passed for `theme`, or its default value.
|
96
|
+
#
|
97
|
+
# So `name` might be `:notice`.
|
81
98
|
name = attrs[group] || self.class.attributes[group]
|
82
99
|
|
100
|
+
# Normalize name for hash lookup. to_s.to_sym converts booleans as well.
|
101
|
+
name = name.to_s.to_sym unless name.nil?
|
102
|
+
|
83
103
|
# Get defaults to set from group name
|
104
|
+
# In the above example, if the name were `notice` this would be the hash
|
105
|
+
# `{ icon: "message", color: "blue" }`
|
84
106
|
defaults = group_options[name]
|
85
107
|
|
86
108
|
next unless defaults
|
@@ -95,7 +95,8 @@ module Spark
|
|
95
95
|
|
96
96
|
# Override the default value for an element's attribute(s)
|
97
97
|
def set_element_attribute_default(element, attrs = {})
|
98
|
-
element_attribute_default[element]
|
98
|
+
element_attribute_default[element] ||= {}
|
99
|
+
element_attribute_default[element].merge!(attrs)
|
99
100
|
end
|
100
101
|
|
101
102
|
def element_attribute_default
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spark-component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview-component
|