Class: FlyoutComponent

Inherits:
Component show all
Defined in:
app/components/flyout_component.rb

Overview

Flyout — slide-out panel from screen edge.

Usage:

Flyout(direction: :right) { |c|
  c.header { text "Settings" }
  c.content { text "Flyout body" }
  c.actions {
    Button(variant: :primary) { text "Save" }
  }
}

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/components/flyout_component.rb', line 22

def to_s
  classes = class_names(
    "ui",
    direction,
    "flyout"
  )

  data = { controller: "fui-flyout" }
  data[:fui_flyout_closable_value] = "false" unless closable

  close_el = closable ? tag.i(class: "close icon") : nil
  header_el = @slots[:header] ? tag.div(class: "header") { @slots[:header] } : nil
  content_el = @slots[:content] ? tag.div(class: "content") { @slots[:content] } : nil
  actions_el = @slots[:actions] ? tag.div(class: "actions") { @slots[:actions] } : nil

  tag.div(class: classes, data: data) {
    safe_join([ close_el, header_el, content_el, @content.presence, actions_el ])
  }
end