Class: PhlexKit::Bubble
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Bubble
- Defined in:
- app/components/phlex_kit/bubble/bubble.rb
Overview
Chat message bubble. Ported from ruby_ui's RubyUI::Bubble. The variant colours the child BubbleContent via a data-slot selector; align: :end flips it to the trailing edge. Compose Bubble > BubbleContent (+ BubbleReactions).
Constant Summary collapse
- VARIANTS =
%i[default secondary muted tinted outline ghost destructive].freeze
Instance Method Summary collapse
-
#initialize(variant: :default, align: :start, **attrs) ⇒ Bubble
constructor
A new instance of Bubble.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(variant: :default, align: :start, **attrs) ⇒ Bubble
Returns a new instance of Bubble.
7 8 9 10 11 12 |
# File 'app/components/phlex_kit/bubble/bubble.rb', line 7 def initialize(variant: :default, align: :start, **attrs) @variant = variant.to_sym raise KeyError, "unknown Bubble variant #{@variant}" unless VARIANTS.include?(@variant) @align = align.to_sym @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
13 14 15 |
# File 'app/components/phlex_kit/bubble/bubble.rb', line 13 def view_template(&) div(**mix({ class: "pk-bubble", data: { slot: "bubble", variant: @variant, align: @align } }, @attrs), &) end |