Class: ShadcnPhlexcomponents::ToastActionTo

Inherits:
ToastAction show all
Defined in:
lib/shadcn_phlexcomponents/components/toast.rb

Constant Summary

Constants inherited from Base

Base::SANITIZER_ALLOWED_ATTRIBUTES, Base::SANITIZER_ALLOWED_TAGS, Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from ToastAction

#class_variants

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(name = nil, options = nil, html_options = nil) ⇒ ToastActionTo

Returns a new instance of ToastActionTo.



155
156
157
158
159
# File 'lib/shadcn_phlexcomponents/components/toast.rb', line 155

def initialize(name = nil, options = nil, html_options = nil)
  @name = name
  @options = options
  @html_options = html_options
end

Instance Method Details

#view_template ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/shadcn_phlexcomponents/components/toast.rb', line 161

def view_template(&)
  if block_given?
    @html_options = @options
    @options = @name
  end

  merge_default_attributes({})
  @html_options ||= {}
  @html_options = mix(@attributes, @html_options)
  @html_options[:form_class] = TAILWIND_MERGER.merge("inline-flex ml-auto #{@html_options[:form_class]}")

  if block_given?
    button_to(@options, @html_options, &)
  else
    button_to(@name, @options, @html_options)
  end
end