From 691a557d5528e9558103cafca5f97e236a9dfb1d Mon Sep 17 00:00:00 2001 From: Tonksthebear Date: Thu, 28 Mar 2024 14:52:52 -0700 Subject: [PATCH] Allow option to opt out of base classes --- Gemfile.lock | 2 +- README.md | 13 +++++++++++++ classy-yaml-0.8.5.gem | Bin 8192 -> 0 bytes classy-yaml-1.2.gem | Bin 0 -> 8192 bytes lib/classy/yaml/helpers.rb | 27 +++++++++++++++------------ lib/classy/yaml/version.rb | 2 +- test/classy/yaml_component_test.rb | 5 +++++ test/classy/yaml_test.rb | 4 ++++ 8 files changed, 39 insertions(+), 14 deletions(-) delete mode 100644 classy-yaml-0.8.5.gem create mode 100644 classy-yaml-1.2.gem diff --git a/Gemfile.lock b/Gemfile.lock index d59df8d..fbf368c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - classy-yaml (1.1) + classy-yaml (1.2) actionpack (>= 6) activesupport (>= 6) railties (>= 6) diff --git a/README.md b/README.md index 1baecbe..b9cb281 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,19 @@ btn: Now, calling `yass(btn: :blue)` or `yass(btn: :yellow)` will ALSO pull in the classes from `btn: :base`. +### Optionally Skipping Base + +You can optionally skip including the base on a `yass` call by including the key/value `skip_base: true`. So, using the example above, +we can perform: +``` +btn: + base: "px-3 py-2" + blue: "text-blue-200 bg-blue-500" + yellow: "text-yellow-200 bg-blue-500" +``` + +Now, calling `yass(btn: :blue, skip_base: true)` and this will skip pulling in the classes from `btn: :base`. This is helpful +when defining animation classes and you only want to include the different classes, such as `active` and `inactive` for instance. ### ViewComponent There is a special helper built for ViewComponent and sidecar assets. In your `example_component.rb`, add the line `include Classy::Yaml::ComponentHelpers`. This helper will tell `yass` to check if there is a `example_component.yml` file, and first use that for definitions. If the definitions aren't found in the `example_component.yml`, then it will fallback to `config/utility_classes.yml`. diff --git a/classy-yaml-0.8.5.gem b/classy-yaml-0.8.5.gem deleted file mode 100644 index 0b57ed8b9a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HOFZD753HtpaTBvV3#VF>K7NQ&>LUWx47p zc*}Di2vXI*yuCorITnrlASqjQEA@1whLUjL%V>h>Fqr})v6-rLMCGL0!~LyE7*lbr z$YtghFUGWq7cFp-`moNUweUmtxc&5m9iXcONEJU|Ug5K1^b>&tSyFZ8v%Y?W*qYoM(aO%=z7TVg8sx(x7GX#MG9P9f z&D?99e4DK4n3h3@QX^{M*$V@_3tO-xPxtQbh`I&n=Kij4hdYU)ccdik9(pWy&@|pK z+qY!94}RJ31kh#?TV6mJ!I4Wah8k>4!e{G{uKjW1*=sIaTX9FH>I=-JH}!4lquG?4>2p1RY4UBu z>N7ReG>Tb+y97OuIM@xd@QPG(XCS*;PTBt{t&5hTWRoLBtY0Kwe{1ejnp}#bhqIpk z#Nt*_v!y$ixZ}C4tM%dn9NJB*)988nROafWzD2P+-(v9u84xR++2FMX@?X9uNACZi zi-NP=5DxVBrt9a+KTQZX0N|5Xsd(~NXHSKpf zp}Pgq$GD>ep#z2^QL05R7Ux~Zsqc=5nPal?*9vjM-@_Kxv8M zq)_=;bFKV@R8znWz+`X(RoC`FQMKaHAt^FUt$!5%A32KOi~L65Hv+#A_(u`=FMJVz As{jB1 diff --git a/classy-yaml-1.2.gem b/classy-yaml-1.2.gem new file mode 100644 index 0000000000000000000000000000000000000000..8e0c5786d24f706aa4220e784d229355eb066532 GIT binary patch literal 8192 zcmeHMRa6{Gwnal@!QGvpO>l35yEkqD0>K*#5V%d_!GpU53j}w)cyI_7tO@QOT>E9- z`?$02to7c{%$xbR=jT+_Syk)Qu2Xxh+U0EPX=P*OX~kpbhxD&9;4c#p5J38y|7Cyn zeEj@^NPGf9Kt6sU{+B>Lq+bmIegPzU;J+%NzhBqO!_&(BS4!{fZEcR5 zzILo(QBRn@TRE{|gVct(EVD1Nv7*mo&GGM*8qo?IisJ>1Txx-Hz11v z8)w`3P0Sdm92hLjp2f85k}LN0fR^hdY+i#^O6&SdcC+46nOj*}3*3>-TG@Q}>i5me$0=N%R)WV;+0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8c}21J;g-*BoiF9tn~DzfWC zRmiN5W<$xZ_q>9N%#PEj2Bfrud6Klh1{EerFkG=mu4`b=e#nZnvcHts!40;{y}zm2 zAxLEW5K8Zt-7=lci|#@l_HzQ388fhMPq}qU{reeL&qXXcCu?5gkJn8tMy4MD>+fxw t3tL&7B?6txZhCYm@t9nEAJA8%d^l&2|M{^0wc=k0{Dr_@2>ja-_%Hj*J4OHi literal 0 HcmV?d00001 diff --git a/lib/classy/yaml/helpers.rb b/lib/classy/yaml/helpers.rb index 0421b6e..ed247a4 100644 --- a/lib/classy/yaml/helpers.rb +++ b/lib/classy/yaml/helpers.rb @@ -16,8 +16,9 @@ def yass(*args) return if classy_yamls.blank? + skip_base_hash = args.find { |arg| arg.is_a?(Hash) && arg.keys.include?(:skip_base) } || {} keys, classes = flatten_args(values: args) - classes += fetch_classes(keys, classy_yamls: classy_yamls) + classes += fetch_classes(keys, classy_yamls: classy_yamls, skip_base: skip_base_hash[:skip_base]) return classes.flatten.join(" ") end @@ -48,7 +49,7 @@ def flatten_args(root: [], values: [], keys: [], added_classes: []) return keys, added_classes end - def fetch_classes(keys, classy_yamls: []) + def fetch_classes(keys, classy_yamls: [], skip_base: false) classes = [] keys.map do |key| @@ -56,14 +57,16 @@ def fetch_classes(keys, classy_yamls: []) fetched_classes = nil classy_yamls.reverse_each do |classy_yaml| - begin - base_classes ||= if classy_yaml.send(:dig, *key).is_a?(Hash) - classy_yaml.send(:dig, *(key + ['base'])).try(:split, " ") - else - classy_yaml.send(:dig, *(key[0...-1] + ['base'])).try(:split, " ") - end - rescue - Rails.logger.warn(Classy::Yaml::InvalidKeyError.new(data: key)) + unless skip_base == true + begin + base_classes ||= if classy_yaml.send(:dig, *key).is_a?(Hash) + classy_yaml.send(:dig, *(key + ['base'])).try(:split, " ") + else + classy_yaml.send(:dig, *(key[0...-1] + ['base'])).try(:split, " ") + end + rescue + Rails.logger.warn(Classy::Yaml::InvalidKeyError.new(data: key)) + end end begin @@ -78,8 +81,8 @@ def fetch_classes(keys, classy_yamls: []) end end - classes << base_classes - classes << fetched_classes + classes << base_classes unless base_classes.blank? + classes << fetched_classes unless fetched_classes.blank? end classes.reject!(&:blank?) diff --git a/lib/classy/yaml/version.rb b/lib/classy/yaml/version.rb index 837f511..1108a00 100644 --- a/lib/classy/yaml/version.rb +++ b/lib/classy/yaml/version.rb @@ -1,5 +1,5 @@ module Classy module Yaml - VERSION = '1.1' + VERSION = '1.2' end end diff --git a/test/classy/yaml_component_test.rb b/test/classy/yaml_component_test.rb index 6ac32b1..c417a13 100644 --- a/test/classy/yaml_component_test.rb +++ b/test/classy/yaml_component_test.rb @@ -70,4 +70,9 @@ class Classy::YamlComponentTest < ViewComponent::TestCase render_inline(TestComponent::NestedComponent.new classy: :nested_inherited, inherited: true) assert_text "nested-inherited" end + + test "can skip base" do + render_inline(TestComponent.new classy: {nested_base: :nested, skip_base: true}) + assert_text "nested-class" + end end diff --git a/test/classy/yaml_test.rb b/test/classy/yaml_test.rb index b840612..5e42019 100644 --- a/test/classy/yaml_test.rb +++ b/test/classy/yaml_test.rb @@ -73,4 +73,8 @@ class Classy::YamlTest < ActiveSupport::TestCase assert_equal "single-class", yass(:single) assert_equal 'extra-single-class', yass(:extra_single) end + + test "allow skipping of base" do + assert_equal "nested-class", yass(nested_base: :nested, skip_base: true) + end end