Class: HakumiComponents::Skeleton::Image::Component
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- HakumiComponents::Skeleton::Image::Component
show all
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/skeleton/image/component.rb
Constant Summary
collapse
- SizeInput =
T.type_alias { BaseComponent::DimensionInput }
- DEFAULT_ICON_NAME =
T.let("picture", String)
- DEFAULT_ICON_THEME =
T.let(:outlined, Symbol)
- DEFAULT_ICON_SIZE =
T.let(48, Integer)
- ICON_SCALE =
T.let(0.55, Float)
- MIN_ICON_SIZE =
T.let(32, Integer)
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
#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, width: 96, height: 96, **html_options) ⇒ Component
Returns a new instance of Component.
25
26
27
28
29
30
31
32
|
# File 'app/components/hakumi_components/skeleton/image/component.rb', line 25
def initialize(active: false, width: 96, height: 96, **html_options)
@active = T.let(active, T::Boolean)
@width = T.let(width, SizeInput)
@height = T.let(height, SizeInput)
@html_options = T.let(html_options, Types::HtmlAttributes)
validate_props!
end
|
Instance Method Details
#icon_component_options ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'app/components/hakumi_components/skeleton/image/component.rb', line 55
def icon_component_options
{
name: DEFAULT_ICON_NAME,
theme: DEFAULT_ICON_THEME,
size: calculated_icon_size,
color: "currentColor",
style: "line-height: 1"
}
end
|
#image_classes ⇒ Object
40
41
42
|
# File 'app/components/hakumi_components/skeleton/image/component.rb', line 40
def image_classes
class_names("skeleton-image")
end
|
#image_style ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'app/components/hakumi_components/skeleton/image/component.rb', line 45
def image_style
styles = T.let([], T::Array[String])
width_css = dimension_to_css(@width)
height_css = dimension_to_css(@height)
styles << "width: #{width_css}" if width_css
styles << "height: #{height_css}" if height_css
styles.any? ? styles.join("; ") : nil
end
|
#wrapper_attributes ⇒ Object
35
36
37
|
# File 'app/components/hakumi_components/skeleton/image/component.rb', line 35
def wrapper_attributes
merge_attributes({ class: wrapper_classes }, @html_options.except(:class))
end
|