Class: Polaris::OptionList::CheckboxComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/polaris/option_list/checkbox_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(label:, value:, wrapper_arguments: {}, **system_arguments) ⇒ CheckboxComponent

Returns a new instance of CheckboxComponent.



2
3
4
5
6
7
8
9
10
11
12
# File 'app/components/polaris/option_list/checkbox_component.rb', line 2

def initialize(
  label:,
  value:,
  wrapper_arguments: {},
  **system_arguments
)
  @label = label
  @value = value
  @wrapper_arguments = wrapper_arguments
  @system_arguments = system_arguments
end

Instance Method Details

#checkboxObject



34
35
36
# File 'app/components/polaris/option_list/checkbox_component.rb', line 34

def checkbox
  render Polaris::BaseCheckbox.new(value: @value, **system_arguments)
end

#system_argumentsObject



25
26
27
28
29
30
31
32
# File 'app/components/polaris/option_list/checkbox_component.rb', line 25

def system_arguments
  @system_arguments.tap do |opts|
    opts[:classes] = class_names(
      @system_arguments[:classes],
      "Polaris-Checkbox__Input"
    )
  end
end

#wrapper_argumentsObject



14
15
16
17
18
19
20
21
22
23
# File 'app/components/polaris/option_list/checkbox_component.rb', line 14

def wrapper_arguments
  @wrapper_arguments.tap do |opts|
    opts[:tag] = "li"
    opts[:tabindex] = "-1"
    opts[:classes] = class_names(
      @wrapper_arguments[:classes],
      "Polaris-OptionList-Option"
    )
  end
end