Class: Arara::ChipComponent

Inherits:
ActionView::Component::Base
  • Object
show all
Includes:
BaseComponent
Defined in:
app/components/arara/chip_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseComponent

#default_data_controller, #default_html_tag, #html_class, #html_content, #html_data, #html_options, #html_tag, included

Constructor Details

#initialize(id:, label:, variant: "choice", selected: false, should_remove_on_trailing_icon_click: false, **kw) ⇒ ChipComponent

Returns a new instance of ChipComponent.



7
8
9
10
11
12
13
# File 'app/components/arara/chip_component.rb', line 7

def initialize(id:, label:, variant: "choice", selected: false, should_remove_on_trailing_icon_click: false, **kw)
  @id = id
  @label = label
  @selected = selected
  @should_remove_on_trailing_icon_click = should_remove_on_trailing_icon_click
  super(tag: "div", variant: variant, **kw)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



15
16
17
# File 'app/components/arara/chip_component.rb', line 15

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



15
16
17
# File 'app/components/arara/chip_component.rb', line 15

def label
  @label
end

#selectedObject (readonly)

Returns the value of attribute selected.



15
16
17
# File 'app/components/arara/chip_component.rb', line 15

def selected
  @selected
end

#user_variantObject (readonly)

Returns the value of attribute user_variant.



15
16
17
# File 'app/components/arara/chip_component.rb', line 15

def user_variant
  @user_variant
end

Instance Method Details

#default_html_classObject



17
18
19
20
# File 'app/components/arara/chip_component.rb', line 17

def default_html_class
  return "mdc-chip mdc-chip--selected" if selected
  "mdc-chip"
end