Class: PhlexKit::BubbleContent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::BubbleContent
- Defined in:
- app/components/phlex_kit/bubble/bubble_content.rb
Constant Summary collapse
- AS_TAGS =
as:is dispatched dynamically — whitelist the documented containers (incl. the interactive button/a contract bubble.css styles) so it can't reach arbitrary (including private) methods. %i[div p blockquote button a].freeze
Instance Method Summary collapse
-
#initialize(as: :div, **attrs) ⇒ BubbleContent
constructor
A new instance of BubbleContent.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(as: :div, **attrs) ⇒ BubbleContent
Returns a new instance of BubbleContent.
7 8 9 10 11 |
# File 'app/components/phlex_kit/bubble/bubble_content.rb', line 7 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_template ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/components/phlex_kit/bubble/bubble_content.rb', line 12 def view_template(&) base = { class: "pk-bubble-content", data: { slot: "bubble-content" } } # An interactive bubble inside a <form> must not be an implicit # type="submit" (same default PhlexKit::Button ships). base[:type] = :button if @as == :button && !attr_set?(:type) send(@as, **mix(base, @attrs), &) end |