Class: Pulse::Toast

Inherits:
Component
  • Object
show all
Includes:
Turbo::FramesHelper
Defined in:
app/components/pulse/toast.rb

Overview

Renders a toast popup.

Constant Summary collapse

{
  default: 'pulse-text-white hover:pulse-text-white',
  error: 'pulse-text-gray hover:pulse-text-gray',
  success: 'pulse-text-white hover:pulse-text-white'
}.freeze
THEME_MAPPINGS =
{
  default: 'pulse-bg-gray-700 pulse-text-white',
  error: 'pulse-bg-error-100 pulse-text-gray-900',
  success: 'pulse-bg-gray-700 pulse-text-white'
}.freeze
DEFAULT_THEME =
:default

Instance Method Summary collapse

Constructor Details

#initialize(auto_hide: true, theme: DEFAULT_THEME, **system_arguments) ⇒ Toast

Returns a new instance of Toast.



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/components/pulse/toast.rb', line 31

def initialize(
  auto_hide: true,
  theme: DEFAULT_THEME,
  **system_arguments
)
  @auto_hide = auto_hide
  @system_arguments = system_arguments
  @theme = theme

  @system_arguments[:tag] ||= :div
  @system_arguments[:data] = data_attributes
  @system_arguments[:classes] = class_attributes
end