Class: Flowbite::Toast

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/flowbite/toast.rb,
app/components/flowbite/toast/icon.rb

Overview

Renders a toast notification element.

See flowbite.com/docs/components/toast/

Defined Under Namespace

Classes: Icon

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message:, style: :default, dismissible: true, class: [], **options) ⇒ Toast

Returns a new instance of Toast.



22
23
24
25
26
27
28
# File 'app/components/flowbite/toast.rb', line 22

def initialize(message:, style: :default, dismissible: true, class: [], **options)
  @message = message
  @style = style
  @dismissible = dismissible
  @additional_classes = Array(binding.local_variable_get(:class)) || []
  @options = options
end

Instance Attribute Details

#additional_classesObject (readonly)

Returns the value of attribute additional_classes.



20
21
22
# File 'app/components/flowbite/toast.rb', line 20

def additional_classes
  @additional_classes
end

#dismissibleObject (readonly)

Returns the value of attribute dismissible.



20
21
22
# File 'app/components/flowbite/toast.rb', line 20

def dismissible
  @dismissible
end

#messageObject (readonly)

Returns the value of attribute message.



20
21
22
# File 'app/components/flowbite/toast.rb', line 20

def message
  @message
end

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'app/components/flowbite/toast.rb', line 20

def options
  @options
end

#styleObject (readonly)

Returns the value of attribute style.



20
21
22
# File 'app/components/flowbite/toast.rb', line 20

def style
  @style
end

Class Method Details

.classesObject



15
16
17
# File 'app/components/flowbite/toast.rb', line 15

def classes
  ["flex", "items-center", "w-full", "max-w-xs", "p-4", "text-gray-500", "bg-white", "rounded-lg", "shadow-sm", "dark:text-gray-400", "dark:bg-gray-800"]
end

Instance Method Details

#container_classesObject



30
31
32
# File 'app/components/flowbite/toast.rb', line 30

def container_classes
  self.class.classes + additional_classes
end