Class: ToastComponent

Inherits:
Component show all
Includes:
Positionable
Defined in:
app/components/toast_component.rb

Overview

Toast — toast notifications.

Usage:

Toast(title: "Success", message: "Item saved.", type: :success)
Toast(title: "Error", message: "Something went wrong.", type: :error, position: "bottom right")

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/components/toast_component.rb', line 21

def to_s
  data = {
    controller: "fui-toast",
    fui_toast_class_value: type,
    fui_toast_position_value: position,
    fui_toast_display_time_value: display_time
  }
  data[:fui_toast_title_value] = title if title
  data[:fui_toast_message_value] = message if message
  data[:fui_toast_close_icon_value] = "true" if close_icon
  data[:fui_toast_compact_value] = "true" if compact
  data[:fui_toast_show_progress_value] = "true" if show_progress

  tag.div(data: data) { @content }
end