Class: PhlexKit::BubbleContent

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/bubble/bubble_content.rb

Constant Summary collapse

AS_TAGS =

as: is dispatched dynamically — whitelist the sensible text containers so it can't reach arbitrary (including private) methods.

%i[div p blockquote].freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(as: :div, **attrs) ⇒ BubbleContent

Returns a new instance of BubbleContent.

Raises:

  • (ArgumentError)


6
7
8
9
10
# File 'app/components/phlex_kit/bubble/bubble_content.rb', line 6

def initialize(as: :div, **attrs)
  @as = as.to_sym
  raise ArgumentError, "unknown BubbleContent as: #{@as.inspect} (use one of #{AS_TAGS.join(", ")})" unless AS_TAGS.include?(@as)
  @attrs = attrs
end

Instance Method Details

#view_templateObject



11
12
13
# File 'app/components/phlex_kit/bubble/bubble_content.rb', line 11

def view_template(&)
  send(@as, **mix({ class: "pk-bubble-content", data: { slot: "bubble-content" } }, @attrs), &)
end