Class: NitroKit::Toast::Item
- Defined in:
- app/components/nitro_kit/toast.rb
Constant Summary collapse
- VARIANTS =
i[default warning error success]
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Attributes inherited from Component
Instance Method Summary collapse
-
#initialize(title: nil, description: nil, variant: :default, **attrs) ⇒ Item
constructor
A new instance of Item.
- #view_template(&block) ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(title: nil, description: nil, variant: :default, **attrs) ⇒ Item
Returns a new instance of Item.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/nitro_kit/toast.rb', line 27 def initialize(title: nil, description: nil, variant: :default, **attrs) @title = title @description = description @variant = variant super( **mattr( attrs, class: [ base_class, variant_class ], role: "status", aria: { live: "off", atomic: "true" }, tabindex: "0", data: { state: "closed" } ) ) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
47 48 49 |
# File 'app/components/nitro_kit/toast.rb', line 47 def description @description end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
47 48 49 |
# File 'app/components/nitro_kit/toast.rb', line 47 def title @title end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
47 48 49 |
# File 'app/components/nitro_kit/toast.rb', line 47 def variant @variant end |
Instance Method Details
#view_template(&block) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/components/nitro_kit/toast.rb', line 49 def view_template(&block) li(**attrs) do div(class: "grid gap-1") do div(class: "text-sm font-semibold", data: { slot: "title" }) do title && plain(title) end div(class: "text-sm opacity-90", data: { slot: "description" }) do text_or_block(description, &block) end end end end |