Class: ShadcnPhlexcomponents::DropdownMenuItemTo

Inherits:
DropdownMenuItem show all
Defined in:
lib/shadcn_phlexcomponents/components/dropdown_menu.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 DropdownMenuItem

#default_attributes

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) ⇒ DropdownMenuItemTo

Returns a new instance of DropdownMenuItemTo.



247
248
249
250
251
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 247

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

Instance Method Details

#class_variants(**args) ⇒ Object



253
254
255
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 253

def class_variants(**args)
  DropdownMenuItem.new.class_variants(class: "w-full #{args[:class]}")
end

#view_template ⇒ Object



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/shadcn_phlexcomponents/components/dropdown_menu.rb', line 257

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

  @html_options ||= {}
  @variant = @html_options.delete(:variant) || :default
  @disabled = @html_options[:disabled]
  merge_default_attributes({})
  @html_options = mix(@attributes, @html_options)

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