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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2012fb19a3b94a62a3278f1256167126ef85e203a967cc20f8cb67d6fc94bfcb
4
- data.tar.gz: ec7bf120843ba12c34f7bfbef26f5170fac8bd4e7f40d7717c6a478bf0116cbf
3
+ metadata.gz: 765533378fe25d4d376f7b79d3071f056438f7c94ddddcdd45043d54669c1859
4
+ data.tar.gz: d05e57bd9f860e806687b52ee20faeffb59b2774904ec6fb84f3403bdff7d692
5
5
  SHA512:
6
- metadata.gz: fceccde2ac9e59dad730915436bd9d8fc2193316c8ce494e76227ac6f64de4bbffa448adc06f70f811a3c869c4b767d489ad750aff41e942ecc4afdc3545b4cd
7
- data.tar.gz: b881d68c49c2e9cccea155e021aafcaad68ec2df3d48c9c78afac833b96e8c0cc325c174bf34660733ed64570501477351f8b8bf5672290fdd1ed10cf1ab41f3
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
- .each do |variant_type, variant|
19
- # dig the classes out and add them to the result
20
- result << @variants.dig(variant_type, variant)
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!
@@ -1,3 +1,3 @@
1
1
  module ClassVariants
2
- VERSION = "0.0.6" unless const_defined?(:VERSION)
2
+ VERSION = "0.0.7" unless const_defined?(:VERSION)
3
3
  end
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.6
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: 2022-12-21 00:00:00.000000000 Z
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.3.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.