Class: Practical::Views::ButtonToComponent

Inherits:
BaseComponent
  • Object
show all
Includes:
Practical::Views::Button::Styling
Defined in:
app/components/practical/views/button_to_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ElementHelper

#grab, #mix

Constructor Details

#initialize(url:, options:, appearance: nil, color_variant: nil, size: nil, html_options: {}) ⇒ ButtonToComponent

Returns a new instance of ButtonToComponent.



7
8
9
10
11
12
# File 'app/components/practical/views/button_to_component.rb', line 7

def initialize(url:, options:, appearance: nil, color_variant: nil, size: nil, html_options: {})
  self.url = url
  self.options = options
  self.html_options = html_options
  initialize_style_utilities(appearance: appearance, color_variant: color_variant, size: size)
end

Instance Attribute Details

#appearanceObject

Returns the value of attribute appearance.



5
6
7
# File 'app/components/practical/views/button_to_component.rb', line 5

def appearance
  @appearance
end

#color_variantObject

Returns the value of attribute color_variant.



5
6
7
# File 'app/components/practical/views/button_to_component.rb', line 5

def color_variant
  @color_variant
end

#html_optionsObject

Returns the value of attribute html_options.



5
6
7
# File 'app/components/practical/views/button_to_component.rb', line 5

def html_options
  @html_options
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'app/components/practical/views/button_to_component.rb', line 5

def options
  @options
end

#sizeObject

Returns the value of attribute size.



5
6
7
# File 'app/components/practical/views/button_to_component.rb', line 5

def size
  @size
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'app/components/practical/views/button_to_component.rb', line 5

def url
  @url
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
# File 'app/components/practical/views/button_to_component.rb', line 14

def call
  html_option_defaults = {
    class: css_classes_from_style_utilities,
    data: {disable: true}
  }

  finalized_html_options = mix(html_option_defaults, html_options)
  helpers.button_to(url, **options, **finalized_html_options) { content }
end