Class: UI::DrawerOverlayComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
DrawerOverlayBehavior
Defined in:
app/view_components/ui/drawer_overlay_component.rb

Overview

Drawer overlay component (ViewComponent) Backdrop with fade animation

Examples:

<%= render UI::OverlayComponent.new(open: false) %>

Instance Method Summary collapse

Methods included from DrawerOverlayBehavior

#drawer_overlay_base_classes, #drawer_overlay_classes, #drawer_overlay_container_base_classes, #drawer_overlay_container_classes, #drawer_overlay_container_data_attributes, #drawer_overlay_container_html_attributes, #drawer_overlay_data_attributes, #drawer_overlay_html_attributes, #merged_drawer_overlay_container_data_attributes

Constructor Details

#initialize(open: false, classes: "", attributes: {}) ⇒ DrawerOverlayComponent

Returns a new instance of DrawerOverlayComponent.

Parameters:

  • open (Boolean) (defaults to: false) —

    whether the drawer is open

  • classes (String) (defaults to: "") —

    additional CSS classes

  • attributes (Hash) (defaults to: {}) —

    additional HTML attributes



14
15
16
17
18
# File 'app/view_components/ui/drawer_overlay_component.rb', line 14

def initialize(open: false, classes: "", attributes: {})
  @open = open
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#call ⇒ Object



20
21
22
23
24
25
26
27
# File 'app/view_components/ui/drawer_overlay_component.rb', line 20

def call
  container_attrs = drawer_overlay_container_html_attributes
  container_attrs[:data] = container_attrs[:data].merge(@attributes.fetch(:data, {}))

   :div, **container_attrs.merge(@attributes.except(:data)) do
     :div, "", **drawer_overlay_html_attributes
  end
end