Class: UI::DrawerHandleComponent

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

Overview

Drawer handle component (ViewComponent) Visual affordance for drag gesture (shown on bottom/top drawers only)

Examples:

<%= render UI::HandleComponent.new %>

Instance Method Summary collapse

Methods included from DrawerHandleBehavior

#drawer_handle_classes, #drawer_handle_container_base_classes, #drawer_handle_data_attributes, #drawer_handle_html_attributes

Constructor Details

#initialize(classes: "", attributes: {}) ⇒ DrawerHandleComponent

Returns a new instance of DrawerHandleComponent.

Parameters:

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

    additional CSS classes

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

    additional HTML attributes



13
14
15
16
# File 'app/view_components/ui/drawer_handle_component.rb', line 13

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

Instance Method Details

#callObject



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

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

   :div, "", **attrs.merge(@attributes.except(:data))
end