Class: ShadcnPhlexcomponents::ToastContainer
- Defined in:
- lib/shadcn_phlexcomponents/components/toast_container.rb
Constant Summary
Constants inherited from Base
Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER
Instance Method Summary collapse
- #default_attributes ⇒ Object
-
#initialize(side: :top_center, **attributes) ⇒ ToastContainer
constructor
A new instance of ToastContainer.
- #toast(variant) ⇒ Object
- #view_template ⇒ Object
Methods inherited from Base
#before_template, #convert_collection_hash_to_struct, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child
Constructor Details
#initialize(side: :top_center, **attributes) ⇒ ToastContainer
Returns a new instance of ToastContainer.
27 28 29 30 |
# File 'lib/shadcn_phlexcomponents/components/toast_container.rb', line 27 def initialize(side: :top_center, **attributes) @class_variants = { side: side } super(**attributes) end |
Instance Method Details
#default_attributes ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/shadcn_phlexcomponents/components/toast_container.rb', line 32 def default_attributes { tabindex: -1, data: { controller: "toast-container", }, } end |
#toast(variant) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/shadcn_phlexcomponents/components/toast_container.rb', line 57 def toast(variant) Toast(variant: variant) do |t| t.content do t.title { "" } t.description { "" } end t.action { "" } end end |
#view_template ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/shadcn_phlexcomponents/components/toast_container.rb', line 41 def view_template(&) div( role: "region", tabindex: -1, aria: { label: "Notifications", }, ) do ol(**@attributes) do template(data: { variant: "default" }) { toast(:default) } template(data: { variant: "destructive" }) { toast(:destructive) } yield end end end |