From c9717ebda5974c6dd343606d03e5b14c7ba5d724 Mon Sep 17 00:00:00 2001 From: David Alejandro <15317732+davidalejandroaguilar@users.noreply.github.com> Date: Sun, 22 Sep 2024 18:16:20 +0200 Subject: [PATCH] Add conditional modifiers --- lib/phlexy_ui/class_list.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/phlexy_ui/class_list.rb b/lib/phlexy_ui/class_list.rb index b7cd968..b731f13 100644 --- a/lib/phlexy_ui/class_list.rb +++ b/lib/phlexy_ui/class_list.rb @@ -19,6 +19,7 @@ def to_a classes = [] add_component_class(classes) add_selected_modifiers_classes(classes) + add_conditioned_modifiers_classes(classes) add_responsive_modifiers_classes(classes) add_class_option_classes(classes) classes @@ -46,6 +47,14 @@ def add_selected_modifiers_classes(classes) ) end + def add_conditioned_modifiers_classes(classes) + modifiers_map.each do |modifier, class_name| + next unless options.delete(modifier) + + classes << with_config_prefix(class_name) + end + end + def html_classes_for_modifiers(modifiers, responsive_prefix: nil) modifiers.map do |modifier| with_responsive_prefix(