class_variants 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/class_variants/instance.rb +13 -5
- data/lib/class_variants/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 765533378fe25d4d376f7b79d3071f056438f7c94ddddcdd45043d54669c1859
|
4
|
+
data.tar.gz: d05e57bd9f860e806687b52ee20faeffb59b2774904ec6fb84f3403bdff7d692
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7517aed893faec0040d34907290f335135631fd12268359687dbcf411b4cbe1cc206ed9a1bffd34ad667bd3e43166300efa9fae7f81ae44c5bf129d6587805e
|
7
|
+
data.tar.gz: c1bb443cc535bd4eec83ebcc6880a851ab8c3bd89342406f904c83136006a082f60092111a20d05273b014639342ca8fb3faa9e67cb6a326e351411e18e57522
|
@@ -3,9 +3,10 @@ class ClassVariants::Instance
|
|
3
3
|
attr_reader :variants
|
4
4
|
attr_reader :defaults
|
5
5
|
|
6
|
-
def initialize(classes = "", variants: {}, defaults: {})
|
6
|
+
def initialize(classes = "", variants: {}, compoundVariants: [], defaults: {})
|
7
7
|
@classes = classes
|
8
8
|
@variants = expand_boolean_variants(variants)
|
9
|
+
@compoundVariants = compoundVariants
|
9
10
|
@defaults = defaults
|
10
11
|
end
|
11
12
|
|
@@ -14,11 +15,18 @@ class ClassVariants::Instance
|
|
14
15
|
result = [@classes]
|
15
16
|
|
16
17
|
# Then merge the passed in overrides on top of the defaults
|
17
|
-
@defaults.merge(overrides)
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
selected = @defaults.merge(overrides)
|
19
|
+
|
20
|
+
selected.each do |variant_type, variant|
|
21
|
+
# dig the classes out and add them to the result
|
22
|
+
result << @variants.dig(variant_type, variant)
|
23
|
+
end
|
24
|
+
|
25
|
+
@compoundVariants.each do |compound_variant|
|
26
|
+
if (compound_variant.keys - [:class]).all? { |key| selected[key] == compound_variant[key] }
|
27
|
+
result << compound_variant[:class]
|
21
28
|
end
|
29
|
+
end
|
22
30
|
|
23
31
|
# Compact out any nil values we may have dug up
|
24
32
|
result.compact!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: class_variants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
|
-
rubygems_version: 3.
|
60
|
+
rubygems_version: 3.4.6
|
61
61
|
signing_key:
|
62
62
|
specification_version: 4
|
63
63
|
summary: Easily configure styles and apply them as classes.
|