Class: HakumiComponents::Skeleton::Button::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- HakumiComponents::Skeleton::Button::Component
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/skeleton/button/component.rb
Constant Summary collapse
- SHAPES =
T.let(%i[default circle round].freeze, T::Array[Symbol])
Constants inherited from BaseComponent
BaseComponent::ControllerOptions, BaseComponent::DateInput, BaseComponent::DateLikeValue, BaseComponent::DimensionInput, BaseComponent::HtmlPayloadInput, BaseComponent::I18nOptionValue, BaseComponent::PresenceArray, BaseComponent::PresenceScalar, BaseComponent::PresenceValue, BaseComponent::RawHtmlInput, BaseComponent::SIZES, BaseComponent::SizeValue, BaseComponent::SymbolInput
Instance Method Summary collapse
- #button_classes ⇒ Object
-
#initialize(active: false, size: :default, shape: :default, block: false, **html_options) ⇒ Component
constructor
A new instance of Component.
- #wrapper_attributes ⇒ Object
Methods inherited from BaseComponent
#append_data_token, boolean_html_param, #build_inline_style, cast_boolean, #cast_boolean, #class_names, #component_classes, #data_attributes_from, #dimension_to_css, #ensure_dom_id!, float_html_param, #generate_id, #html_classes, html_param, html_primitive_param, #html_style, #i18n_scope, integer_html_param, #merge_attributes, #render_value, #size_to_pixels, #stimulus_attrs, string_html_param, string_or_symbol_array_html_param, symbol_html_param, #t_default, #translate_with_default, #validate_inclusion!, #validate_required!, #value_present?
Constructor Details
#initialize(active: false, size: :default, shape: :default, block: false, **html_options) ⇒ Component
Returns a new instance of Component.
21 22 23 24 25 26 27 28 29 |
# File 'app/components/hakumi_components/skeleton/button/component.rb', line 21 def initialize(active: false, size: :default, shape: :default, block: false, **) @active = T.let(active, T::Boolean) @size = T.let(normalize_size(size), Symbol) @shape = T.let(normalize_shape(shape), Symbol) @block = T.let(block, T::Boolean) @html_options = T.let(, Types::HtmlAttributes) validate_props! end |
Instance Method Details
#button_classes ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/components/hakumi_components/skeleton/button/component.rb', line 37 def modifiers = T.let({}, Types::ClassModifiers) modifiers[@size] = true if @size != :default modifiers[@shape] = true if @shape != :default class_names("skeleton-button", modifiers) end |
#wrapper_attributes ⇒ Object
32 33 34 |
# File 'app/components/hakumi_components/skeleton/button/component.rb', line 32 def wrapper_attributes merge_attributes({ class: wrapper_classes }, @html_options.except(:class)) end |