Class: HakumiComponents::Tag::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- HakumiComponents::Tag::Component
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/tag/component.rb
Constant Summary collapse
- Color =
T.type_alias { T.nilable(T.any(Symbol, String)) }
- Variant =
T.type_alias { T.any(Symbol, String) }
- IconName =
T.type_alias { T.nilable(T.any(Symbol, String)) }
- COLORS =
T.let(%i[magenta red volcano orange gold lime green cyan blue geekblue purple].freeze, T::Array[Symbol])
- STATUSES =
T.let(%i[success processing error default warning].freeze, T::Array[Symbol])
- VARIANTS =
T.let(%i[filled outlined borderless].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
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(color: nil, closable: nil, close_icon: nil, bordered: nil, variant: nil, href: nil, checkable: nil, checked: nil, draggable: nil, **html_options) ⇒ Component
constructor
A new instance of Component.
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(color: nil, closable: nil, close_icon: nil, bordered: nil, variant: nil, href: nil, checkable: nil, checked: nil, draggable: nil, **html_options) ⇒ Component
Returns a new instance of Component.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/components/hakumi_components/tag/component.rb', line 33 def initialize( color: nil, closable: nil, close_icon: nil, bordered: nil, variant: nil, href: nil, checkable: nil, checked: nil, draggable: nil, ** ) @color = T.let(color, Color) @closable = T.let(cast_boolean(closable) ? true : false, T::Boolean) @close_icon = T.let(close_icon, IconName) @bordered = T.let(cast_boolean(bordered) != false, T::Boolean) @variant = T.let((variant || :filled).to_sym, Symbol) @href = T.let(href, T.nilable(String)) @checkable = T.let(cast_boolean(checkable) ? true : false, T::Boolean) @checked = T.let(cast_boolean(checked) ? true : false, T::Boolean) @draggable = T.let(cast_boolean(draggable) ? true : false, T::Boolean) @html_options = T.let(, Types::HtmlAttributes) validate_props! end |
Class Method Details
.extract_controller_locals(params) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/components/hakumi_components/tag/component.rb', line 64 def self.extract_controller_locals(params) { color: html_primitive_param(html_param(params, :color)), closable: boolean_html_param(html_param(params, :closable)), close_icon: html_primitive_param(html_param(params, :close_icon)), bordered: boolean_html_param(html_param(params, :bordered)), variant: symbol_html_param(html_param(params, :variant)), href: html_primitive_param(html_param(params, :href)), checkable: boolean_html_param(html_param(params, :checkable)), checked: boolean_html_param(html_param(params, :checked)), draggable: boolean_html_param(html_param(params, :draggable)), content: html_primitive_param(html_param(params, :content)) } end |
Instance Method Details
#call ⇒ Object
80 81 82 83 84 85 86 |
# File 'app/components/hakumi_components/tag/component.rb', line 80 def call if @href.present? render_link_tag else render_span_tag end end |