Class: RubyUI::EmptyState

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/ruby_cms/templates/components/ruby_ui/empty_state/empty_state.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Constructor Details

#initialize(title: "No items yet", description: nil, icon: nil, primary_label: nil, primary_href: nil, primary_method: :get, primary_variant: :primary, secondary_label: nil, secondary_href: nil, secondary_method: :get, secondary_variant: :outline, learn_more_label: nil, learn_more_href: nil, centered: true, **user_attrs) ⇒ EmptyState

Returns a new instance of EmptyState.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/ruby_cms/templates/components/ruby_ui/empty_state/empty_state.rb', line 5

def initialize(
  title: "No items yet",
  description: nil,
  icon: nil,
  primary_label: nil,
  primary_href: nil,
  primary_method: :get,
  primary_variant: :primary,
  secondary_label: nil,
  secondary_href: nil,
  secondary_method: :get,
  secondary_variant: :outline,
  learn_more_label: nil,
  learn_more_href: nil,
  centered: true,
  **user_attrs
)
  @title = title
  @description = description
  @icon = icon
  @primary_label = primary_label
  @primary_href = primary_href
  @primary_method = primary_method
  @primary_variant = primary_variant
  @secondary_label = secondary_label
  @secondary_href = secondary_href
  @secondary_method = secondary_method
  @secondary_variant = secondary_variant
  @learn_more_label = learn_more_label
  @learn_more_href = learn_more_href
  @centered = centered
  super(**user_attrs)
end

Instance Method Details

#view_templateObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/generators/ruby_cms/templates/components/ruby_ui/empty_state/empty_state.rb', line 39

def view_template
  div(**attrs) do
    content_wrapper do
      render_icon

      h2(class: title_classes) { @title }

      p(class: "mt-2 text-sm text-muted-foreground") { @description } if @description

      render_actions
      render_learn_more
    end
  end
end