Class: ShadcnPhlexcomponents::Button

Inherits:
Base
  • Object
show all
Defined in:
lib/shadcn_phlexcomponents/components/button.rb

Constant Summary

Constants inherited from Base

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

Instance Method Summary collapse

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(variant: :default, size: :default, type: :button, **attributes) ⇒ Button

Returns a new instance of Button.



40
41
42
43
44
# File 'lib/shadcn_phlexcomponents/components/button.rb', line 40

def initialize(variant: :default, size: :default, type: :button, **attributes)
  @class_variants = { variant: variant, size: size }
  @type = type
  super(**attributes)
end

Instance Method Details

#default_attributesObject



46
47
48
# File 'lib/shadcn_phlexcomponents/components/button.rb', line 46

def default_attributes
  { type: @type }
end

#view_templateObject



50
51
52
# File 'lib/shadcn_phlexcomponents/components/button.rb', line 50

def view_template(&)
  button(**@attributes, &)
end