Class: Polaris::OptionList::RadioButtonComponent

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

Instance Method Summary collapse

Constructor Details

#initialize(label:, value:, prefix: nil, suffix: nil, wrapper_arguments: {}, **system_arguments) ⇒ RadioButtonComponent

Returns a new instance of RadioButtonComponent.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/components/polaris/option_list/radio_button_component.rb', line 5

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

Instance Method Details

#radio_buttonObject



41
42
43
# File 'app/components/polaris/option_list/radio_button_component.rb', line 41

def radio_button
  render Polaris::BaseRadioButton.new(value: @value, **system_arguments)
end

#system_argumentsObject



32
33
34
35
36
37
38
39
# File 'app/components/polaris/option_list/radio_button_component.rb', line 32

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

#wrapper_argumentsObject



21
22
23
24
25
26
27
28
29
30
# File 'app/components/polaris/option_list/radio_button_component.rb', line 21

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