Class: UI::AspectRatioComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::AspectRatioComponent
- Includes:
- AspectRatioBehavior
- Defined in:
- app/view_components/ui/aspect_ratio_component.rb
Overview
AspectRatio - ViewComponent implementation
Displays content within a desired aspect ratio.
Constant Summary
Constants included from AspectRatioBehavior
UI::AspectRatioBehavior::DEFAULT_RATIO
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(ratio: 1.0, classes: "", **attributes) ⇒ AspectRatioComponent
constructor
A new instance of AspectRatioComponent.
Methods included from AspectRatioBehavior
#aspect_ratio_classes, #aspect_ratio_content_attributes, #aspect_ratio_html_attributes, #aspect_ratio_padding, #aspect_ratio_padding_attributes
Constructor Details
#initialize(ratio: 1.0, classes: "", **attributes) ⇒ AspectRatioComponent
Returns a new instance of AspectRatioComponent.
12 13 14 15 16 |
# File 'app/view_components/ui/aspect_ratio_component.rb', line 12 def initialize(ratio: 1.0, classes: "", **attributes) @ratio = ratio @classes = classes @attributes = attributes end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/view_components/ui/aspect_ratio_component.rb', line 18 def call tag.div(**aspect_ratio_html_attributes) do tag.div(**aspect_ratio_padding_attributes) + tag.div(**aspect_ratio_content_attributes) do content end end end |