Class: Charming::Presentation::Components::EmptyState

Inherits:
Charming::Presentation::Component show all
Defined in:
lib/charming/presentation/components/empty_state.rb

Instance Method Summary collapse

Methods inherited from View

#focused?, #layout_assigns

Constructor Details

#initialize(message: "Nothing to show.", loading: false, loading_message: "Loading...", error: nil, error_message: nil, help: nil, theme: nil) ⇒ EmptyState

Returns a new instance of EmptyState.



7
8
9
10
11
12
13
14
15
# File 'lib/charming/presentation/components/empty_state.rb', line 7

def initialize(message: "Nothing to show.", loading: false, loading_message: "Loading...", error: nil, error_message: nil, help: nil, theme: nil)
  super(theme: theme)
  @message = message
  @loading = loading
  @loading_message = loading_message
  @error = error
  @error_message = error_message
  @help = help
end

Instance Method Details

#renderObject



17
18
19
20
21
22
# File 'lib/charming/presentation/components/empty_state.rb', line 17

def render
  return loading_state if @loading
  return error_state if error?

  text @message, style: theme.muted
end