diff --git a/app/components/DS/empty_state.rb b/app/components/DS/empty_state.rb new file mode 100644 index 000000000..937954d91 --- /dev/null +++ b/app/components/DS/empty_state.rb @@ -0,0 +1,33 @@ +class DS::EmptyState < DesignSystemComponent + # Centered empty / no-data / disabled state: icon, title, optional + # description, optional action slot. Replaces the repeated + # `text-center py-12 + icon + title + description + CTA` markup across the + # empty screens (#2137), and gives the bare-text feature-disabled pages a real + # state instead of unstyled top-left text. + # + # <%= render DS::EmptyState.new(icon: "repeat", title: "...", description: "...") do |es| %> + # <% es.with_action do %><%= render DS::Link.new(...) %><% end %> + # <% end %> + renders_one :action + + def initialize(icon:, title:, description: nil, icon_size: "xl", **opts) + @icon = icon + @title = title + @description = description + @icon_size = icon_size + @opts = opts + end + + erb_template <<~ERB + <%= content_tag :div, + class: class_names("flex flex-col items-center text-center px-4 py-12", @opts[:class]), + **@opts.except(:class) do %> +
<%= @title %>
+ <% if @description.present? %> +"><%= @description %>
+ <% end %> + <% if action? %><%= t("recurring_transactions.empty.title") %>
-<%= t("recurring_transactions.empty.description") %>
- <%= render DS::Link.new( - text: t("recurring_transactions.identify_patterns"), - icon: "search", - variant: "primary", - href: identify_recurring_transactions_path, - method: :post - ) %> -