Class: Polaris::BaseRadioButton
- Defined in:
- app/components/polaris/base_radio_button.rb
Constant Summary
Constants included from ViewHelper
ViewHelper::POLARIS_HELPERS, ViewHelper::POLARIS_TEXT_STYLES
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form: nil, attribute: nil, name: nil, checked: nil, disabled: false, value: nil, **system_arguments) ⇒ BaseRadioButton
constructor
A new instance of BaseRadioButton.
- #system_arguments ⇒ Object
Methods included from ViewHelper
#polaris_body_styles, #polaris_html_classes, #polaris_html_styles, #polaris_icon_source
Methods included from StylesListHelper
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
Constructor Details
#initialize(form: nil, attribute: nil, name: nil, checked: nil, disabled: false, value: nil, **system_arguments) ⇒ BaseRadioButton
Returns a new instance of BaseRadioButton.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/components/polaris/base_radio_button.rb', line 3 def initialize( form: nil, attribute: nil, name: nil, checked: nil, disabled: false, value: nil, **system_arguments ) @form = form @attribute = attribute @name = name @checked = checked @disabled = disabled @value = value @system_arguments = system_arguments end |
Instance Method Details
#call ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/components/polaris/base_radio_button.rb', line 39 def call if @form.present? && @attribute.present? @form.(@attribute, @value, system_arguments) else (@name, @value, @checked, system_arguments) end end |
#system_arguments ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/polaris/base_radio_button.rb', line 21 def system_arguments @system_arguments.tap do |opts| opts[:disabled] = true if @disabled opts[:aria] ||= {} opts[:class] = opts.delete(:classes) if @form.present? && @attribute.present? unless @checked.nil? opts[:aria][:checked] = !!@checked opts[:checked] = !!@checked end else opts[:aria][:checked] = !!@checked opts[:checked] = !!@checked end end end |