Class: UI::SheetContent

Inherits:
Phlex::HTML
  • Object
show all
Includes:
SheetContentBehavior
Defined in:
app/components/ui/sheet_content.rb

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: nil, **attributes) ⇒ SheetContent

Returns a new instance of SheetContent.

Parameters:

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

    Position of the sheet: “top”, “right”, “bottom”, “left”

  • open (Boolean) (defaults to: false)

    Whether the sheet is open

  • show_close (Boolean) (defaults to: true)

    Whether to show the built-in close button

  • classes (String) (defaults to: nil)

    Additional CSS classes



10
11
12
13
14
15
16
# File 'app/components/ui/sheet_content.rb', line 10

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

Instance Method Details

#view_template(&block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/components/ui/sheet_content.rb', line 18

def view_template(&block)
  div(**sheet_content_html_attributes) do
    yield if block_given?

    # Built-in close button (like shadcn)
    if @show_close
      button(
        class: sheet_content_close_button_classes,
        data: {action: "click->ui--dialog#close"}
      ) do
        render_x_icon
        span(class: "sr-only") { "Close" }
      end
    end
  end
end