Class: ShadcnPhlexcomponents::ToastAction
- Defined in:
- lib/shadcn_phlexcomponents/components/toast.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER
Instance Method Summary collapse
- #class_variants(**args) ⇒ Object
-
#initialize(as_child: false, **attributes) ⇒ ToastAction
constructor
A new instance of ToastAction.
- #view_template ⇒ Object
Methods inherited from Base
#before_template, #convert_collection_hash_to_struct, #default_attributes, #find_as_child, #icon, #item_disabled?, #merge_default_attributes, #merged_as_child_attributes, #nokogiri_attributes_to_hash, #overlay, #sanitize_as_child
Constructor Details
#initialize(as_child: false, **attributes) ⇒ ToastAction
Returns a new instance of ToastAction.
129 130 131 132 |
# File 'lib/shadcn_phlexcomponents/components/toast.rb', line 129 def initialize(as_child: false, **attributes) @as_child = as_child super(**attributes) end |
Instance Method Details
#class_variants(**args) ⇒ Object
134 135 136 |
# File 'lib/shadcn_phlexcomponents/components/toast.rb', line 134 def class_variants(**args) Button.new.class_variants(variant: :default, size: :sm, class: "text-xs h-6 py-0 px-2 rounded-sm ml-auto #{args[:class]}") end |
#view_template ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/shadcn_phlexcomponents/components/toast.rb', line 138 def view_template(&) if @as_child content = capture(&) element = find_as_child(content.to_s) vanish(&) merged_attributes = merged_as_child_attributes(element, @attributes) send(element.name, **merged_attributes) do sanitize_as_child(element.children.to_s) end else (**@attributes, &) end end |