Class: UI::SheetContentComponent

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

Overview

Sheet content component (ViewComponent) Main content panel with side variants and slide animations

Examples:

<%= render UI::ContentComponent.new(side: "right") do %>
  <!-- Content -->
<% end %>

Constant Summary

Constants included from SheetContentBehavior

UI::SheetContentBehavior::SIDES

Instance Method Summary collapse

Methods included from SheetContentBehavior

#merged_sheet_content_data_attributes, #sheet_content_base_classes, #sheet_content_classes, #sheet_content_close_button_classes, #sheet_content_data_attributes, #sheet_content_html_attributes, #sheet_content_side_classes

Constructor Details

#initialize(side: "right", open: false, show_close: true, classes: "", **attributes) ⇒ SheetContentComponent

Returns a new instance of SheetContentComponent.

Parameters:

  • side (String) (defaults to: "right")

    Position: “top”, “right”, “bottom”, “left”

  • open (Boolean) (defaults to: false)

    whether the sheet is open

  • show_close (Boolean) (defaults to: true)

    whether to show built-in close button

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

    additional CSS classes

  • attributes (Hash)

    additional HTML attributes



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

def initialize(side: "right", open: false, show_close: true, classes: "", **attributes)
  @side = side
  @open = open
  @show_close = show_close
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



26
27
28
29
30
31
32
33
34
35
36
# File 'app/view_components/ui/sheet_content_component.rb', line 26

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

   :div, **attrs.merge(@attributes.except(:data)) do
    safe_join([
      content,
      close_button
    ].compact)
  end
end