class UiBibz::Ui::Core::Notifications::Popover

Create a popover

This element is an extend of UiBibz::Ui::Core::Component.

Attributes

Options

You can add HTML attributes using the html_options. You can pass arguments in options attribute:

Signatures

UiBibz::Ui::Core::Notifications::Popover.new(content, options = nil, html_options = nil)

UiBibz::Ui::Core::Notifications::Popover.new(options = nil, html_options = nil) do
  content
end

Examples

UiBibz::Ui::Core::Notifications::Popover.new(class: 'my-toast').tap |t|
  t.header "My header toast", glyph: 'eye', time: 'now'
  t.body "My body toast"
end

Helper

popover = UiBibz::Ui::Core::Notifications::Popover.new(position: :left) do
   My content
end
ui_glyph("diamond", popover: popover)

# or

ui_glyph("diamond", {popover: true}, { title: "My content" })

# or

ui_glyph("diamond", popover: { title: "My content", position: :right})

Constants

DATA_ATTRIBUTES

Note that for security reasons the sanitize, sanitizeFn, and allowList options cannot be supplied using data attributes. getbootstrap.com/docs/5.0/components/popovers/#options

Public Class Methods

new(content = nil, options = nil, html_options = nil, &block) click to toggle source

See UiBibz::Ui::Core::Component.initialize

Calls superclass method UiBibz::Ui::Core::Component::new
# File lib/ui_bibz/ui/core/notifications/popover.rb, line 60
def initialize(content = nil, options = nil, html_options = nil, &block)
  super
  @content = @options[:content] if content.is_a?(Hash) && block.nil?
end

Public Instance Methods

render() click to toggle source

Render html tag

# File lib/ui_bibz/ui/core/notifications/popover.rb, line 66
def render
  base_attributes.merge(data_attributes)
end

Private Instance Methods

base_attributes() click to toggle source
# File lib/ui_bibz/ui/core/notifications/popover.rb, line 72
def base_attributes
  {
    'data-bs-toggle' => 'popover',
    'data-bs-content' => @content.html_safe
  }.tap do |h|
    h['data-bs-placement'] = options[:position] || options[:placement] if (options[:position] || options[:placement]).present?
  end
end
data_attribute_value(data_attribute) click to toggle source
# File lib/ui_bibz/ui/core/notifications/popover.rb, line 81
def data_attribute_value(data_attribute)
  options[data_attribute].is_a?(String) ? options[data_attribute].html_safe : options[data_attribute]
end