Class: PhlexKit::Bubble

Inherits:
BaseComponent show all
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

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(variant: :default, align: :start, **attrs) ⇒ Bubble

Returns a new instance of Bubble.

Raises:

  • (KeyError)


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_templateObject



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