Class: UI::ResponsiveDialogComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::ResponsiveDialogComponent
- Includes:
- ResponsiveDialogBehavior
- Defined in:
- app/view_components/ui/responsive_dialog_component.rb
Overview
ResponsiveDialog component (ViewComponent) Combines Dialog (desktop) and Drawer (mobile) with responsive switching
Hybrid CSS + Stimulus approach:
-
Renders both Dialog and Drawer
-
CSS hides one based on breakpoint (md:hidden / md:block)
-
Stimulus controller syncs state between them
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(open: false, breakpoint: 768, direction: "bottom", classes: "", attributes: {}) ⇒ ResponsiveDialogComponent
constructor
A new instance of ResponsiveDialogComponent.
Methods included from ResponsiveDialogBehavior
#merged_responsive_dialog_data_attributes, #responsive_dialog_base_classes, #responsive_dialog_classes, #responsive_dialog_data_attributes, #responsive_dialog_html_attributes
Constructor Details
#initialize(open: false, breakpoint: 768, direction: "bottom", classes: "", attributes: {}) ⇒ ResponsiveDialogComponent
Returns a new instance of ResponsiveDialogComponent.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/view_components/ui/responsive_dialog_component.rb', line 32 def initialize( open: false, breakpoint: 768, direction: "bottom", classes: "", attributes: {} ) @open = open @breakpoint = breakpoint @direction = direction @classes = classes @attributes = attributes end |
Instance Method Details
#call ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/view_components/ui/responsive_dialog_component.rb', line 46 def call attrs = responsive_dialog_html_attributes attrs[:data] = attrs[:data].merge(@attributes.fetch(:data, {})) content_tag :div, **attrs.merge(@attributes.except(:data)) do # Mobile: Drawer (hidden on md and up) mobile_wrapper + desktop_wrapper end end |