Class: Ariadne::CheckboxComponent
- Defined in:
- app/components/ariadne/checkbox_component.rb
Overview
Just a checkbox with a label, state managed by toggleable controller
Constant Summary collapse
- DEFAULT_TAG =
:label- TAG_OPTIONS =
[DEFAULT_TAG].freeze
- DEFAULT_CLASSES =
{ input: "ariadne-mr-2", label: "ariadne-flex ariadne-items-center ariadne-cursor-pointer ariadne-w-fit", }
- DEFAULT_ATTRIBUTES =
{ input: { type: "checkbox", "data-controller": "toggleable", "data-toggleable-synced-attrs-value": '["checked", "aria-checked"]', "data-action": "click->toggleable#toggle", }, label: {}, }
Constants inherited from Component
Ariadne::Component::BASE_HIDDEN_CLASS, Ariadne::Component::BASE_MAIN_CLASSES, Ariadne::Component::BASE_WRAPPER_CLASSES, Ariadne::Component::INVALID_ARIA_LABEL_TAGS
Constants included from ActionViewExtensions::FormHelper
ActionViewExtensions::FormHelper::DEFAULT_FORM_CLASSES
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE
Instance Method Summary collapse
-
#initialize(tag: DEFAULT_TAG, classes: "", input_classes: "", initial_value: false, input_attributes: {}, attributes: {}) ⇒ CheckboxComponent
constructor
A new instance of CheckboxComponent.
Methods included from ActionViewExtensions::FormHelper
Methods included from ClassNameHelper
Methods included from LoggerHelper
#logger, #silence_deprecations?, #silence_warnings?
Methods included from FetchOrFallbackHelper
#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer
Constructor Details
#initialize(tag: DEFAULT_TAG, classes: "", input_classes: "", initial_value: false, input_attributes: {}, attributes: {}) ⇒ CheckboxComponent
Returns a new instance of CheckboxComponent.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/components/ariadne/checkbox_component.rb', line 31 def initialize(tag: DEFAULT_TAG, classes: "", input_classes: "", initial_value: false, input_attributes: {}, attributes: {}) @tag = @tag = check_incoming_tag(DEFAULT_TAG, tag) @label_attributes = DEFAULT_ATTRIBUTES[:label].merge(attributes) @label_classes = merge_class_names(DEFAULT_CLASSES[:label], classes) @input_classes = merge_class_names(DEFAULT_CLASSES[:input], input_classes) @input_attributes = DEFAULT_ATTRIBUTES[:input] .merge({ "data-toggleable-state-value": initial_value.to_s }) .merge(input_attributes) end |