Class: Daisy::DataDisplay::FigureComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::DataDisplay::FigureComponent
- Includes:
- LocoMotion::Concerns::LinkableComponent
- Defined in:
- app/components/daisy/data_display/figure_component.rb
Constant Summary
Constants inherited from LocoMotion::BaseComponent
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary
Attributes inherited from LocoMotion::BaseComponent
Instance Method Summary collapse
- #before_render ⇒ Object
- #call ⇒ Object
-
#initialize(**kws, &block) ⇒ FigureComponent
constructor
Creates a new figure component.
Methods inherited from LocoMotion::BaseComponent
build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces
Methods included from LocoMotion::Concerns::InspectableComponent
Constructor Details
#initialize(**kws, &block) ⇒ FigureComponent
Creates a new figure component.
46 47 48 49 50 51 52 53 54 |
# File 'app/components/daisy/data_display/figure_component.rb', line 46 def initialize(**kws, &block) super @src = kws[:src] @alt = kws[:alt] @position = kws[:position] || :top validate_position! end |
Instance Method Details
#before_render ⇒ Object
56 57 58 59 60 61 |
# File 'app/components/daisy/data_display/figure_component.rb', line 56 def before_render set_tag_name(:component, :figure) add_html(:image, { src: @src, alt: @alt }) if @src super end |
#call ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/components/daisy/data_display/figure_component.rb', line 63 def call part(:component) do if @position == :bottom # Show content first, then image concat(content) concat(part(:image)) if @src else # Default: show image first, then content concat(part(:image)) if @src concat(content) end end end |