Class: Irelia::Button::Component

Inherits:
Component
  • Object
show all
Includes:
Options::Width
Defined in:
app/components/irelia/button/component.rb

Instance Method Summary collapse

Methods included from Options::Width

included

Methods inherited from Component

#add_css_classes, after_initialize, #html_options, inherited, run_after_initialize_hooks

Constructor Details

#initialize(**options) ⇒ Component

Returns a new instance of Component.



32
33
34
35
36
37
38
39
# File 'app/components/irelia/button/component.rb', line 32

def initialize(**options)
  super

  @tag = @url.present? ? :a : :button
  @html_options[:href] = @url if @url.present?
  @html_options[:type] = @type
  @html_options["data-turbo-frame"] = @modal if @modal.present?
end

Instance Method Details

#variantsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/components/irelia/button/component.rb', line 16

def variants
  class_names(
    "irelia-button",
    "irelia-button--default": variant == :default,
    "irelia-button--dropdown-item": variant == :dropdown_item,
    "irelia-button--color-primary": color == :primary,
    "irelia-button--color-secondary": color == :secondary,
    "irelia-button--color-danger": color == :danger,
    "irelia-button--xs": size == :xs,
    "irelia-button--sm": size == :sm,
    "irelia-button--md": size == :md,
    "irelia-button--lg": size == :lg,
    "irelia-button--xl": size == :xl
  )
end