Class: IronAdmin::Ui::EmptyStateComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/iron_admin/ui/empty_state_component.rb

Overview

Renders an empty state placeholder when no records exist.

Examples:

Basic empty state

render IronAdmin::Ui::EmptyStateComponent.new(
  title: "No users yet",
  description: "Get started by creating your first user."
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title: "No results found", description: nil, icon: "inbox", action_text: nil, action_href: nil) ⇒ EmptyStateComponent

Returns a new instance of EmptyStateComponent.

Parameters:

  • title (String) (defaults to: "No results found")

    Title (default: "No results found")

  • description (String, nil) (defaults to: nil)

    Description

  • icon (String) (defaults to: "inbox")

    Icon name (default: "inbox")

  • action_text (String, nil) (defaults to: nil)

    Button text

  • action_href (String, nil) (defaults to: nil)

    Button URL



33
34
35
36
37
38
39
40
# File 'app/components/iron_admin/ui/empty_state_component.rb', line 33

def initialize(title: "No results found", description: nil, icon: "inbox",
               action_text: nil, action_href: nil)
  @title = title
  @description = description
  @icon = icon
  @action_text = action_text
  @action_href = action_href
end

Instance Attribute Details

#action_hrefString? (readonly)

Returns Action button URL.

Returns:

  • (String, nil)

    Action button URL



26
27
28
# File 'app/components/iron_admin/ui/empty_state_component.rb', line 26

def action_href
  @action_href
end

#action_textString? (readonly)

Returns Action button text.

Returns:

  • (String, nil)

    Action button text



23
24
25
# File 'app/components/iron_admin/ui/empty_state_component.rb', line 23

def action_text
  @action_text
end

#descriptionString? (readonly)

Returns Description text.

Returns:

  • (String, nil)

    Description text



17
18
19
# File 'app/components/iron_admin/ui/empty_state_component.rb', line 17

def description
  @description
end

#iconString (readonly)

Returns Heroicon name.

Returns:

  • (String)

    Heroicon name



20
21
22
# File 'app/components/iron_admin/ui/empty_state_component.rb', line 20

def icon
  @icon
end

#titleString (readonly)

Returns Title text.

Returns:

  • (String)

    Title text



14
15
16
# File 'app/components/iron_admin/ui/empty_state_component.rb', line 14

def title
  @title
end

Instance Method Details

#has_action?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Whether action button should be shown.

Returns:

  • (Boolean)

    Whether action button should be shown



50
51
52
# File 'app/components/iron_admin/ui/empty_state_component.rb', line 50

def has_action?
  action_text.present? && action_href.present?
end

#themeIronAdmin::Configuration::Theme

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Theme configuration.

Returns:



44
45
46
# File 'app/components/iron_admin/ui/empty_state_component.rb', line 44

def theme
  IronAdmin.configuration.theme
end