Class: Polaris::RadioButtonComponent

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

Constant Summary

Constants included from ViewHelper

ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from ViewHelper

#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source

Methods included from StylesListHelper

#styles_list

Methods included from OptionHelper

#append_option, #prepend_option

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #fetch_or_fallback_nested

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(form: nil, attribute: nil, name: nil, label: nil, label_hidden: false, checked: nil, disabled: false, help_text: nil, value: nil, wrapper_arguments: {}, input_options: {}, **system_arguments) ⇒ RadioButtonComponent

Returns a new instance of RadioButtonComponent.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/components/polaris/radio_button_component.rb', line 5

def initialize(
  form: nil,
  attribute: nil,
  name: nil,
  label: nil,
  label_hidden: false,
  checked: nil,
  disabled: false,
  help_text: nil,
  value: nil,
  wrapper_arguments: {},
  input_options: {},
  **system_arguments
)
  @form = form
  @attribute = attribute
  @name = name
  @checked = checked
  @disabled = disabled
  @value = value

  @system_arguments = system_arguments
  @system_arguments[:tag] = "span"
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "Polaris-RadioButton",
    "Polaris-RadioButton--labelHidden": label_hidden
  )

  @wrapper_arguments = {
    label: label,
    label_hidden: label_hidden,
    help_text: help_text,
    disabled: disabled
  }.merge(wrapper_arguments)

  @input_options = input_options
  @input_options[:classes] = class_names(
    @input_options[:classes],
    "Polaris-RadioButton__Input"
  )
end

Instance Method Details

#radio_buttonObject



53
54
55
56
57
58
59
60
61
62
63
# File 'app/components/polaris/radio_button_component.rb', line 53

def radio_button
  render Polaris::BaseRadioButton.new(
    form: @form,
    attribute: @attribute,
    name: @name,
    checked: @checked,
    disabled: @disabled,
    value: @value,
    **@input_options
  )
end

#wrapper_argumentsObject



48
49
50
51
# File 'app/components/polaris/radio_button_component.rb', line 48

def wrapper_arguments
  @wrapper_arguments[:children_content] = content
  @wrapper_arguments
end