Skip to content

Commit

Permalink
Use register_modifiers method in all components
Browse files Browse the repository at this point in the history
  • Loading branch information
davidalejandroaguilar committed Sep 20, 2024
1 parent c59236b commit c4629c2
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 53 deletions.
6 changes: 3 additions & 3 deletions lib/phlexy_ui/badge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(*, as: :span, **)
def view_template(&)
generate_classes!(
component_html_class: :badge,
modifiers_map: BADGE_MODIFIERS_MAP,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand All @@ -20,7 +20,7 @@ def view_template(&)

private

BADGE_MODIFIERS_MAP = {
register_modifiers(
# "sm:badge-neutral"
# "md:badge-neutral"
# "lg:badge-neutral"
Expand Down Expand Up @@ -77,6 +77,6 @@ def view_template(&)
# "md:badge-xs"
# "lg:badge-xs"
xs: "badge-xs"
}.freeze
)
end
end
6 changes: 3 additions & 3 deletions lib/phlexy_ui/button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(*, as: :button, **)
def view_template(&)
generate_classes!(
component_html_class: :btn,
modifiers_map: BUTTON_MODIFIERS_MAP,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand All @@ -20,7 +20,7 @@ def view_template(&)

private

BUTTON_MODIFIERS_MAP = {
register_modifiers(
# Modifiers
# "sm:no-animation"
# "md:no-animation"
Expand Down Expand Up @@ -115,6 +115,6 @@ def view_template(&)
# "md:btn-error"
# "lg:btn-error"
error: "btn-error"
}.freeze
).freeze
end
end
18 changes: 9 additions & 9 deletions lib/phlexy_ui/drawer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(*, id:, as: :section, **)
def view_template(&)
generate_classes!(
component_html_class: :drawer,
modifiers_map: DRAWER_MODIFIERS_MAP,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand Down Expand Up @@ -61,15 +61,15 @@ def button(*, **, &)

private

DRAWER_MODIFIERS_MAP = {
# "sm:drawer-end",
# "md:drawer-end",
# "lg:drawer-end",
register_modifiers(
# "sm:drawer-end"
# "md:drawer-end"
# "lg:drawer-end"
end: "drawer-end",
# "sm:drawer-open",
# "md:drawer-open",
# "lg:drawer-open",
# "sm:drawer-open"
# "md:drawer-open"
# "lg:drawer-open"
open: "drawer-open"
}.freeze
)
end
end
6 changes: 3 additions & 3 deletions lib/phlexy_ui/dropdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(*, as: :div, **)
def view_template(&)
generate_classes!(
component_html_class: :dropdown,
modifiers_map: DROPDOWN_MODIFIERS_MAP,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand Down Expand Up @@ -58,7 +58,7 @@ def menu(*, **options, &)

private

DROPDOWN_MODIFIERS_MAP = {
register_modifiers(
# "sm:dropdown-end"
# "md:dropdown-end"
# "lg:dropdown-end"
Expand Down Expand Up @@ -87,6 +87,6 @@ def menu(*, **options, &)
# "md:dropdown-open"
# "lg:dropdown-open"
open: "dropdown-open"
}.freeze
)
end
end
6 changes: 3 additions & 3 deletions lib/phlexy_ui/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module PhlexyUI
class Link < Base
def view_template(&)
generate_classes!(
modifiers_map: LINK_MODIFIERS_MAP,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand All @@ -16,7 +16,7 @@ def view_template(&)

attr_reader :link_to_name

LINK_MODIFIERS_MAP = {
register_modifiers(
# "sm:link"
# "md:link"
# "lg:link"
Expand Down Expand Up @@ -85,6 +85,6 @@ def view_template(&)
# "md:link-error"
# "lg:link-error"
error: "link-error"
}.freeze
).freeze
end
end
6 changes: 3 additions & 3 deletions lib/phlexy_ui/loading.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(*, as: :span, **)
def view_template(&)
generate_classes!(
component_html_class: :loading,
modifiers_map: LOADING_MODIFIERS_MAP,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand All @@ -20,7 +20,7 @@ def view_template(&)

private

LOADING_MODIFIERS_MAP = {
register_modifiers(
# "sm:loading-spinner"
# "md:loading-spinner"
# "lg:loading-spinner"
Expand Down Expand Up @@ -93,6 +93,6 @@ def view_template(&)
# "md:text-error"
# "lg:text-error"
error: "text-error"
}.freeze
).freeze
end
end
6 changes: 3 additions & 3 deletions lib/phlexy_ui/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Menu < Base
def view_template(&)
generate_classes!(
component_html_class: :menu,
modifiers_map: MENU_MODIFIERS_MAP,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand Down Expand Up @@ -40,7 +40,7 @@ def submenu(*base_modifiers, **, &)

private

MENU_MODIFIERS_MAP = {
register_modifiers(
# "sm:menu-xs"
# "md:menu-xs"
# "lg:menu-xs"
Expand Down Expand Up @@ -109,6 +109,6 @@ def submenu(*base_modifiers, **, &)
# "md:bg-error md:text-error-content"
# "lg:bg-error lg:text-error-content"
error: "bg-error text-error-content"
}.freeze
)
end
end
6 changes: 3 additions & 3 deletions lib/phlexy_ui/menu_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module PhlexyUI
class MenuItem < Base
def view_template(&)
generate_classes!(
modifiers_map: MENU_ITEM_MODIFIERS_MAP,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand All @@ -32,7 +32,7 @@ def submenu(*base_modifiers, **, &)

private

MENU_ITEM_MODIFIERS_MAP = {
register_modifiers(
# "sm:disabled"
# "md:disabled"
# "lg:disabled"
Expand All @@ -45,6 +45,6 @@ def submenu(*base_modifiers, **, &)
# "md:focus"
# "lg:focus"
focus: "focus"
}.freeze
)
end
end
13 changes: 0 additions & 13 deletions lib/phlexy_ui/tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,5 @@ def content(*, **options, &)
end
end
end

private

TAB_MODIFIERS_CLASSES = {
# "sm:tab-active"
# "md:tab-active"
# "lg:tab-active"
active: "tab-active",
# "sm:tab-disabled"
# "md:tab-disabled"
# "lg:tab-disabled"
disabled: "tab-disabled"
}.freeze
end
end
13 changes: 12 additions & 1 deletion lib/phlexy_ui/tab_with_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def view_template(&)

generate_classes!(
component_html_class: :tab,
modifiers_map: Tab::TAB_MODIFIERS_CLASSES,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand All @@ -46,5 +46,16 @@ def view_template(&)
open: {checked: true},
closed: true
}.freeze

register_modifiers(
# "sm:tab-active"
# "md:tab-active"
# "lg:tab-active"
active: "tab-active",
# "sm:tab-disabled"
# "md:tab-disabled"
# "lg:tab-disabled"
disabled: "tab-disabled"
)
end
end
6 changes: 3 additions & 3 deletions lib/phlexy_ui/tab_without_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TabWithoutContent < Base
def view_template(&)
generate_classes!(
component_html_class: :tab,
modifiers_map: Tab::TAB_MODIFIERS_CLASSES,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand All @@ -18,7 +18,7 @@ def view_template(&)

attr_reader :title

TAB_MODIFIERS_CLASSES = {
register_modifiers(
# "sm:tab-active"
# "md:tab-active"
# "lg:tab-active"
Expand All @@ -27,6 +27,6 @@ def view_template(&)
# "md:tab-disabled"
# "lg:tab-disabled"
disabled: "tab-disabled"
}.freeze
)
end
end
6 changes: 3 additions & 3 deletions lib/phlexy_ui/tabs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(*, id: nil, as: :div, **)
def view_template(&)
generate_classes!(
component_html_class: :tabs,
modifiers_map: TABS_MODIFIERS_CLASSES,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand All @@ -25,7 +25,7 @@ def tab(*, **, &)

private

TABS_MODIFIERS_CLASSES = {
register_modifiers(
# "sm:tabs-boxed"
# "md:tabs-boxed"
# "lg:tabs-boxed"
Expand Down Expand Up @@ -54,6 +54,6 @@ def tab(*, **, &)
# "md:tabs-lg"
# "lg:tabs-lg"
lg: "tabs-lg"
}.freeze
)
end
end
6 changes: 3 additions & 3 deletions lib/phlexy_ui/tooltip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(*, tip:, as: :div, **)
def view_template(&)
generate_classes!(
component_html_class: :tooltip,
modifiers_map: TOOLTIP_MODIFIERS_MAP,
modifiers_map: modifiers,
base_modifiers:,
options:
).then do |classes|
Expand All @@ -23,7 +23,7 @@ def view_template(&)

attr_reader :tip

TOOLTIP_MODIFIERS_MAP = {
register_modifiers(
# "sm:tooltip-open"
# "md:tooltip-open"
# "lg:tooltip-open"
Expand Down Expand Up @@ -72,6 +72,6 @@ def view_template(&)
# "md:tooltip-error"
# "lg:tooltip-error"
error: "tooltip-error"
}.freeze
)
end
end

0 comments on commit c4629c2

Please sign in to comment.