Class: UI::DrawerContentComponent

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

Overview

Drawer content component (ViewComponent) Main draggable panel with direction support

Examples:

<%= render UI::ContentComponent.new(direction: "bottom") do %>
  <!-- Drawer content -->
<% end %>

Instance Method Summary collapse

Methods included from DrawerContentBehavior

#drawer_content_base_classes, #drawer_content_classes, #drawer_content_data_attributes, #drawer_content_html_attributes, #merged_drawer_content_data_attributes

Constructor Details

#initialize(open: false, direction: "bottom", classes: "", attributes: {}) ⇒ DrawerContentComponent

Returns a new instance of DrawerContentComponent.

Parameters:

  • open (Boolean) (defaults to: false)

    whether the drawer is open

  • direction (String) (defaults to: "bottom")

    drawer position: “bottom”, “top”, “left”, “right”

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

    additional CSS classes

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

    additional HTML attributes



17
18
19
20
21
22
# File 'app/view_components/ui/drawer_content_component.rb', line 17

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

Instance Method Details

#callObject



24
25
26
27
28
29
30
31
# File 'app/view_components/ui/drawer_content_component.rb', line 24

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

   :div, class: "group/drawer-content", **attrs.merge(@attributes.except(:data)) do
    content
  end
end