Class: LightningUiKit::PopoverComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- LightningUiKit::PopoverComponent
- Defined in:
- app/components/lightning_ui_kit/popover_component.rb
Constant Summary collapse
- POSITIONS =
%w[ top bottom left right top-start top-end bottom-start bottom-end left-start left-end right-start right-end ].freeze
Instance Method Summary collapse
- #content_classes ⇒ Object
- #data ⇒ Object
-
#initialize(position: :bottom, offset: 8, **options) ⇒ PopoverComponent
constructor
A new instance of PopoverComponent.
Constructor Details
#initialize(position: :bottom, offset: 8, **options) ⇒ PopoverComponent
Returns a new instance of PopoverComponent.
11 12 13 14 15 |
# File 'app/components/lightning_ui_kit/popover_component.rb', line 11 def initialize(position: :bottom, offset: 8, **) @position = POSITIONS.include?(position.to_s) ? position.to_s : "bottom" @offset = offset @options = end |
Instance Method Details
#content_classes ⇒ Object
17 18 19 20 21 22 |
# File 'app/components/lightning_ui_kit/popover_component.rb', line 17 def content_classes merge_classes([ "lui:hidden lui:z-50 lui:w-72 lui:rounded-md lui:border lui:border-border lui:bg-surface lui:p-4 lui:text-foreground lui:shadow-md lui:outline-none", @options[:class] ].compact.join(" ")) end |
#data ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/components/lightning_ui_kit/popover_component.rb', line 24 def data { controller: "lui-popover", lui_popover_position_value: @position, lui_popover_offset_value: @offset, action: "keydown.esc@window->lui-popover#hide click@window->lui-popover#hideOnClickOutside" }.merge(@options[:data] || {}) end |