Class: UI::DialogComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::DialogComponent
- Includes:
- DialogBehavior
- Defined in:
- app/view_components/ui/dialog_component.rb
Overview
Dialog container component (ViewComponent) A modal dialog window that renders content over the main page
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(open: false, close_on_escape: true, close_on_overlay_click: true, classes: "", **attributes) ⇒ DialogComponent
constructor
A new instance of DialogComponent.
Methods included from DialogBehavior
#dialog_base_classes, #dialog_classes, #dialog_data_attributes, #dialog_html_attributes, #merged_dialog_data_attributes
Constructor Details
#initialize(open: false, close_on_escape: true, close_on_overlay_click: true, classes: "", **attributes) ⇒ DialogComponent
Returns a new instance of DialogComponent.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/view_components/ui/dialog_component.rb', line 30 def initialize( open: false, close_on_escape: true, close_on_overlay_click: true, classes: "", **attributes ) @open = open @close_on_escape = close_on_escape @close_on_overlay_click = @classes = classes @attributes = attributes end |
Instance Method Details
#call ⇒ Object
44 45 46 47 48 49 |
# File 'app/view_components/ui/dialog_component.rb', line 44 def call attrs = dialog_html_attributes attrs[:data] = attrs[:data].merge(@attributes.fetch(:data, {})) content_tag :div, content, **attrs.merge(@attributes.except(:data)) end |