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
Overview
The FigureComponent is used to display images with optional captions. It is commonly used within cards and other content containers.
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
Constructor Details
#initialize(**kws, &block) ⇒ FigureComponent
Creates a new figure component.
31 32 33 34 35 |
# File 'app/components/daisy/data_display/figure_component.rb', line 31 def initialize(**kws, &block) super @src = kws[:src] end |
Instance Method Details
#before_render ⇒ Object
37 38 39 40 41 42 |
# File 'app/components/daisy/data_display/figure_component.rb', line 37 def before_render set_tag_name(:component, :figure) add_html(:image, src: @src) if @src super end |
#call ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'app/components/daisy/data_display/figure_component.rb', line 44 def call part(:component) do if @src concat(part(:image)) end # Always show the content concat(content) end end |