Module: UI::CarouselContentBehavior
- Defined in:
- app/behaviors/ui/carousel_content_behavior.rb
Overview
Shared behavior for Carousel Content component
Instance Method Summary collapse
-
#carousel_content_base_classes ⇒ Object
Base CSS classes for carousel content wrapper (outer div/viewport).
-
#carousel_content_classes ⇒ Object
Merge base classes with custom classes for outer div.
-
#carousel_content_container_base_classes ⇒ Object
Base CSS classes for flex container (inner div) Includes default horizontal spacing.
-
#carousel_content_container_classes ⇒ Object
Merge base classes with custom classes for inner flex container User classes can override the -ml-4 default (e.g., -ml-1 for custom spacing).
-
#carousel_content_container_data_attributes ⇒ Object
Data attributes for flex container (inner div).
-
#carousel_content_container_html_attributes ⇒ Object
Build complete HTML attributes hash for inner container.
-
#carousel_content_data_attributes ⇒ Object
Data attributes for Stimulus target (outer div).
-
#carousel_content_html_attributes ⇒ Object
Build complete HTML attributes hash.
-
#merged_carousel_content_data_attributes ⇒ Object
Merge user-provided data attributes.
Instance Method Details
#carousel_content_base_classes ⇒ Object
Base CSS classes for carousel content wrapper (outer div/viewport)
8 9 10 |
# File 'app/behaviors/ui/carousel_content_behavior.rb', line 8 def carousel_content_base_classes "overflow-hidden" end |
#carousel_content_classes ⇒ Object
Merge base classes with custom classes for outer div
19 20 21 |
# File 'app/behaviors/ui/carousel_content_behavior.rb', line 19 def carousel_content_classes carousel_content_base_classes end |
#carousel_content_container_base_classes ⇒ Object
Base CSS classes for flex container (inner div) Includes default horizontal spacing
14 15 16 |
# File 'app/behaviors/ui/carousel_content_behavior.rb', line 14 def carousel_content_container_base_classes "flex -ml-4" end |
#carousel_content_container_classes ⇒ Object
Merge base classes with custom classes for inner flex container User classes can override the -ml-4 default (e.g., -ml-1 for custom spacing)
25 26 27 |
# File 'app/behaviors/ui/carousel_content_behavior.rb', line 25 def carousel_content_container_classes TailwindMerge::Merger.new.merge([carousel_content_container_base_classes, @classes].compact.join(" ")) end |
#carousel_content_container_data_attributes ⇒ Object
Data attributes for flex container (inner div)
37 38 39 40 41 |
# File 'app/behaviors/ui/carousel_content_behavior.rb', line 37 def carousel_content_container_data_attributes { ui__carousel_target: "container" } end |
#carousel_content_container_html_attributes ⇒ Object
Build complete HTML attributes hash for inner container
44 45 46 47 48 49 |
# File 'app/behaviors/ui/carousel_content_behavior.rb', line 44 def carousel_content_container_html_attributes { class: carousel_content_container_classes, data: carousel_content_container_data_attributes } end |
#carousel_content_data_attributes ⇒ Object
Data attributes for Stimulus target (outer div)
30 31 32 33 34 |
# File 'app/behaviors/ui/carousel_content_behavior.rb', line 30 def carousel_content_data_attributes { ui__carousel_target: "viewport" } end |
#carousel_content_html_attributes ⇒ Object
Build complete HTML attributes hash
58 59 60 61 62 63 64 |
# File 'app/behaviors/ui/carousel_content_behavior.rb', line 58 def carousel_content_html_attributes base_attrs = @attributes&.except(:data) || {} base_attrs.merge( class: carousel_content_classes, data: merged_carousel_content_data_attributes ) end |
#merged_carousel_content_data_attributes ⇒ Object
Merge user-provided data attributes
52 53 54 55 |
# File 'app/behaviors/ui/carousel_content_behavior.rb', line 52 def merged_carousel_content_data_attributes user_data = @attributes&.fetch(:data, {}) || {} user_data.merge(carousel_content_data_attributes) end |