Sha256: 5b462605658fe292b122430f8b9aed1dfb9bcf6cab255ecece3721e5e511f0a0

Contents?: true

Size: 1.71 KB

Versions: 17

Compression:

Stored size: 1.71 KB

Contents

module UiBibz::Ui::Core::Notifications::Components

  # Create a alert body
  #
  # ==== Attributes
  #
  # * +content+ - Content of element
  # * +options+ - Options of element
  # * +html_options+ - Html Options of element
  #
  # ==== Options
  #
  # You can add HTML attributes using the +html_options+.
  # You can pass arguments in options attribute:
  #
  # ==== Signatures
  #
  #   UiBibz::Ui::Core::Notifications::ToastHeader.new(content, options = nil, html_options = nil)
  #
  #   UiBibz::Ui::Core::Notifications::ToastHeader.new(options = nil, html_options = nil) do
  #     content
  #   end
  #
  # ==== Examples
  #
  #   UiBibz::Ui::Core::Notifications::ToastHeader.new.render
  #
  #   UiBibz::Ui::Core::Notifications::ToastHeader.new do
  #     'Exemple'
  #   end.render
  #
  class ToastHeader < UiBibz::Ui::Core::Component

    # See UiBibz::Ui::Core::Component.initialize
    def initialize content = nil, options = nil, html_options = nil, &block
      super
    end

    def pre_render
      content_tag :div, html_options do
        concat UiBibz::Ui::Core::Icons::Glyph.new(options[:glyph], class: 'mr-2').render unless options[:glyph].nil?
        concat image_tag(options[:img], class: 'rounded mr-2') unless options[:img].nil?
        concat content_tag(:strong, content, class: 'mr-auto')
        concat content_tag(:small, options[:time], class: 'text-muted') unless options[:time].nil?
        concat close_button
      end
    end

  private

    def close_button
      content_tag :button, class: 'ml-2 mb-1 close', "data-dismiss": "toast", "aria-label": "Close" do
        content_tag(:span, "×", "aria-hidden": true).html_safe
      end
    end

    def component_html_classes
      "toast-header"
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ui_bibz-2.4.0 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.15 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.14 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.13 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.12 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.11 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.10 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.9 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.8 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.7 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.6 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.5 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.4 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.3 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.2 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.1 lib/ui_bibz/ui/core/notifications/components/toast_header.rb
ui_bibz-2.3.0 lib/ui_bibz/ui/core/notifications/components/toast_header.rb