Class: LightningUiKit::SheetComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- LightningUiKit::SheetComponent
- Defined in:
- app/components/lightning_ui_kit/sheet_component.rb
Constant Summary collapse
- SIDES =
%i[top right bottom left].freeze
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(id: nil, title: nil, description: nil, side: :right, **options) ⇒ SheetComponent
constructor
A new instance of SheetComponent.
- #overlay_closed_class ⇒ Object
- #panel_classes ⇒ Object
-
#panel_closed_class ⇒ Object
Class(es) applied to the panel while the sheet is closed (offscreen).
Constructor Details
#initialize(id: nil, title: nil, description: nil, side: :right, **options) ⇒ SheetComponent
Returns a new instance of SheetComponent.
8 9 10 11 12 13 14 |
# File 'app/components/lightning_ui_kit/sheet_component.rb', line 8 def initialize(id: nil, title: nil, description: nil, side: :right, **) @id = id @title = title @description = description @side = SIDES.include?(side) ? side : :right @options = end |
Instance Method Details
#data ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/components/lightning_ui_kit/sheet_component.rb', line 38 def data { controller: "lui-sheet", lui_sheet_panel_closed_class: panel_closed_class, lui_sheet_overlay_closed_class: }.merge(@options[:data] || {}) end |
#overlay_closed_class ⇒ Object
34 35 36 |
# File 'app/components/lightning_ui_kit/sheet_component.rb', line 34 def "lui:opacity-0" end |
#panel_classes ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/components/lightning_ui_kit/sheet_component.rb', line 16 def panel_classes merge_classes([ "lui:fixed lui:z-50 lui:flex lui:flex-col lui:gap-4 lui:bg-surface lui:p-6 lui:text-foreground lui:shadow-lg lui:transition-transform lui:duration-300 lui:ease-in-out", side_classes, @options[:class] ].compact.join(" ")) end |
#panel_closed_class ⇒ Object
Class(es) applied to the panel while the sheet is closed (offscreen).
25 26 27 28 29 30 31 32 |
# File 'app/components/lightning_ui_kit/sheet_component.rb', line 25 def panel_closed_class case @side when :left then "lui:-translate-x-full" when :top then "lui:-translate-y-full" when :bottom then "lui:translate-y-full" else "lui:translate-x-full" end end |