Class: UI::DrawerComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::DrawerComponent
- Includes:
- DrawerBehavior
- Defined in:
- app/view_components/ui/drawer_component.rb
Overview
Drawer container component (ViewComponent) A mobile-first drawer with gesture-based drag-to-close
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(open: false, direction: "bottom", dismissible: true, modal: true, snap_points: nil, active_snap_point: nil, fade_from_index: nil, snap_to_sequential_point: false, handle_only: false, reposition_inputs: true, classes: "", id: nil, attributes: {}) ⇒ DrawerComponent
constructor
A new instance of DrawerComponent.
Methods included from DrawerBehavior
#drawer_base_classes, #drawer_classes, #drawer_data_attributes, #drawer_html_attributes, #merged_drawer_data_attributes
Constructor Details
#initialize(open: false, direction: "bottom", dismissible: true, modal: true, snap_points: nil, active_snap_point: nil, fade_from_index: nil, snap_to_sequential_point: false, handle_only: false, reposition_inputs: true, classes: "", id: nil, attributes: {}) ⇒ DrawerComponent
Returns a new instance of DrawerComponent.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/view_components/ui/drawer_component.rb', line 44 def initialize( open: false, direction: "bottom", dismissible: true, modal: true, snap_points: nil, active_snap_point: nil, fade_from_index: nil, snap_to_sequential_point: false, handle_only: false, reposition_inputs: true, classes: "", id: nil, attributes: {} ) @open = open @direction = direction @dismissible = dismissible @modal = modal @snap_points = snap_points @active_snap_point = active_snap_point @fade_from_index = fade_from_index @snap_to_sequential_point = snap_to_sequential_point @handle_only = handle_only @reposition_inputs = reposition_inputs @classes = classes @id = id @attributes = attributes end |
Instance Method Details
#call ⇒ Object
74 75 76 77 78 79 80 |
# File 'app/view_components/ui/drawer_component.rb', line 74 def call attrs = drawer_html_attributes attrs[:data] = attrs[:data].merge(@attributes.fetch(:data, {})) attrs[:id] = @id if @id content_tag :div, content, **attrs.merge(@attributes.except(:data)) end |