diff --git a/app/components/alert_component.html.erb b/app/components/DS/alert.html.erb similarity index 100% rename from app/components/alert_component.html.erb rename to app/components/DS/alert.html.erb diff --git a/app/components/alert_component.rb b/app/components/DS/alert.rb similarity index 97% rename from app/components/alert_component.rb rename to app/components/DS/alert.rb index 47c348f8..22241133 100644 --- a/app/components/alert_component.rb +++ b/app/components/DS/alert.rb @@ -1,4 +1,4 @@ -class AlertComponent < ViewComponent::Base +class DS::Alert < DesignSystemComponent def initialize(message:, variant: :info) @message = message @variant = variant diff --git a/app/components/button_component.html.erb b/app/components/DS/button.html.erb similarity index 100% rename from app/components/button_component.html.erb rename to app/components/DS/button.html.erb diff --git a/app/components/button_component.rb b/app/components/DS/button.rb similarity index 95% rename from app/components/button_component.rb rename to app/components/DS/button.rb index 36600a3c..a253c04c 100644 --- a/app/components/button_component.rb +++ b/app/components/DS/button.rb @@ -2,7 +2,7 @@ # An extension to `button_to` helper. All options are passed through to the `button_to` helper with some additional # options available. -class ButtonComponent < ButtonishComponent +class DS::Button < DS::Buttonish attr_reader :confirm def initialize(confirm: nil, **opts) diff --git a/app/components/buttonish_component.rb b/app/components/DS/buttonish.rb similarity index 96% rename from app/components/buttonish_component.rb rename to app/components/DS/buttonish.rb index 4bbb2882..b83557b1 100644 --- a/app/components/buttonish_component.rb +++ b/app/components/DS/buttonish.rb @@ -1,4 +1,4 @@ -class ButtonishComponent < ViewComponent::Base +class DS::Buttonish < DesignSystemComponent VARIANTS = { primary: { container_classes: "text-inverse bg-inverse hover:bg-inverse-hover disabled:bg-gray-500 theme-dark:disabled:bg-gray-400", @@ -71,7 +71,7 @@ class ButtonishComponent < ViewComponent::Base end def call - raise NotImplementedError, "ButtonishComponent is an abstract class and cannot be instantiated directly." + raise NotImplementedError, "Buttonish is an abstract class and cannot be instantiated directly." end def container_classes(override_classes = nil) diff --git a/app/components/dialog_component.html.erb b/app/components/DS/dialog.html.erb similarity index 92% rename from app/components/dialog_component.html.erb rename to app/components/DS/dialog.html.erb index ac4cd07f..ca8f86b7 100644 --- a/app/components/dialog_component.html.erb +++ b/app/components/DS/dialog.html.erb @@ -1,7 +1,7 @@ <%= wrapper_element do %> <%= tag.dialog class: "w-full h-full bg-transparent theme-dark:backdrop:bg-alpha-black-900 backdrop:bg-overlay #{drawer? ? "lg:p-3" : "lg:p-1"}", **merged_opts do %> <%= tag.div class: dialog_outer_classes do %> - <%= tag.div class: dialog_inner_classes, data: { dialog_target: "content" } do %> + <%= tag.div class: dialog_inner_classes, data: { DS__dialog_target: "content" } do %>
<% if header? %> <%= header %> diff --git a/app/components/dialog_component.rb b/app/components/DS/dialog.rb similarity index 77% rename from app/components/dialog_component.rb rename to app/components/DS/dialog.rb index 94246872..3385003c 100644 --- a/app/components/dialog_component.rb +++ b/app/components/DS/dialog.rb @@ -1,9 +1,9 @@ -class DialogComponent < ViewComponent::Base +class DS::Dialog < DesignSystemComponent renders_one :header, ->(title: nil, subtitle: nil, hide_close_icon: false, **opts, &block) do content_tag(:header, class: "px-4 flex flex-col gap-2", **opts) do title_div = content_tag(:div, class: "flex items-center justify-between gap-2") do title = content_tag(:h2, title, class: class_names("font-medium text-primary", drawer? ? "text-lg" : "")) if title - close_icon = render ButtonComponent.new(variant: "icon", class: "ml-auto", icon: "x", tabindex: "-1", data: { action: "dialog#close" }) unless hide_close_icon + close_icon = render DS::Button.new(variant: "icon", class: "ml-auto", icon: "x", tabindex: "-1", data: { action: "DS--dialog#close" }) unless hide_close_icon safe_join([ title, close_icon ].compact) end @@ -19,16 +19,16 @@ class DialogComponent < ViewComponent::Base renders_many :actions, ->(cancel_action: false, **button_opts) do merged_opts = if cancel_action - button_opts.merge(type: "button", data: { action: "modal#close" }) + button_opts.merge(type: "button", data: { action: "DS--dialog#close" }) else button_opts end - render ButtonComponent.new(**merged_opts) + render DS::Button.new(**merged_opts) end renders_many :sections, ->(title:, **disclosure_opts, &block) do - render DisclosureComponent.new(title: title, align: :right, **disclosure_opts) do + render DS::Disclosure.new(title: title, align: :right, **disclosure_opts) do block.call end end @@ -99,11 +99,11 @@ class DialogComponent < ViewComponent::Base merged_opts = opts.dup data = merged_opts.delete(:data) || {} - data[:controller] = [ "dialog", "hotkey", data[:controller] ].compact.join(" ") - data[:dialog_auto_open_value] = auto_open - data[:dialog_reload_on_close_value] = reload_on_close - data[:action] = [ "mousedown->dialog#clickOutside", data[:action] ].compact.join(" ") - data[:hotkey] = "esc:dialog#close" + data[:controller] = [ "DS--dialog", "hotkey", data[:controller] ].compact.join(" ") + data[:DS__dialog_auto_open_value] = auto_open + data[:DS__dialog_reload_on_close_value] = reload_on_close + data[:action] = [ "mousedown->DS--dialog#clickOutside", data[:action] ].compact.join(" ") + data[:hotkey] = "esc:DS--dialog#close" merged_opts[:data] = data merged_opts diff --git a/app/components/dialog_controller.js b/app/components/DS/dialog_controller.js similarity index 100% rename from app/components/dialog_controller.js rename to app/components/DS/dialog_controller.js diff --git a/app/components/disclosure_component.html.erb b/app/components/DS/disclosure.html.erb similarity index 100% rename from app/components/disclosure_component.html.erb rename to app/components/DS/disclosure.html.erb diff --git a/app/components/disclosure_component.rb b/app/components/DS/disclosure.rb similarity index 82% rename from app/components/disclosure_component.rb rename to app/components/DS/disclosure.rb index 5aba01b2..d301d671 100644 --- a/app/components/disclosure_component.rb +++ b/app/components/DS/disclosure.rb @@ -1,4 +1,4 @@ -class DisclosureComponent < ViewComponent::Base +class DS::Disclosure < DesignSystemComponent renders_one :summary_content attr_reader :title, :align, :open, :opts diff --git a/app/components/filled_icon_component.html.erb b/app/components/DS/filled_icon.html.erb similarity index 100% rename from app/components/filled_icon_component.html.erb rename to app/components/DS/filled_icon.html.erb diff --git a/app/components/filled_icon_component.rb b/app/components/DS/filled_icon.rb similarity index 97% rename from app/components/filled_icon_component.rb rename to app/components/DS/filled_icon.rb index 1f903243..73113a0b 100644 --- a/app/components/filled_icon_component.rb +++ b/app/components/DS/filled_icon.rb @@ -1,4 +1,4 @@ -class FilledIconComponent < ViewComponent::Base +class DS::FilledIcon < DesignSystemComponent attr_reader :icon, :text, :hex_color, :size, :rounded, :variant VARIANTS = %i[default text surface container inverse].freeze diff --git a/app/components/link_component.html.erb b/app/components/DS/link.html.erb similarity index 100% rename from app/components/link_component.html.erb rename to app/components/DS/link.html.erb diff --git a/app/components/link_component.rb b/app/components/DS/link.rb similarity index 94% rename from app/components/link_component.rb rename to app/components/DS/link.rb index 4bbe10e5..209f86b0 100644 --- a/app/components/link_component.rb +++ b/app/components/DS/link.rb @@ -1,6 +1,6 @@ # An extension to `link_to` helper. All options are passed through to the `link_to` helper with some additional # options available. -class LinkComponent < ButtonishComponent +class DS::Link < DS::Buttonish attr_reader :frame VARIANTS = VARIANTS.reverse_merge( diff --git a/app/components/menu_component.html.erb b/app/components/DS/menu.html.erb similarity index 59% rename from app/components/menu_component.html.erb rename to app/components/DS/menu.html.erb index 00f19b2a..d4f0ea8d 100644 --- a/app/components/menu_component.html.erb +++ b/app/components/DS/menu.html.erb @@ -1,17 +1,17 @@ -<%= tag.div data: { controller: "menu", menu_placement_value: placement, menu_offset_value: offset, testid: testid } do %> +<%= tag.div data: { controller: "DS--menu", DS__menu_placement_value: placement, DS__menu_offset_value: offset, testid: testid } do %> <% if variant == :icon %> - <%= render ButtonComponent.new(variant: "icon", icon: icon_vertical ? "more-vertical" : "more-horizontal", data: { menu_target: "button" }) %> + <%= render DS::Button.new(variant: "icon", icon: icon_vertical ? "more-vertical" : "more-horizontal", data: { DS__menu_target: "button" }) %> <% elsif variant == :button %> <%= button %> <% elsif variant == :avatar %> - <% end %> -