Sha256: f34c6794bf69d24a7c1ebf56be3d10a9e47ae2391862f5169edc6987b9df55db

Contents?: true

Size: 1.42 KB

Versions: 9

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

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::AlertHeader.new(content, options = nil, html_options = nil)
  #
  #   UiBibz::Ui::Core::Notifications::AlertHeader.new(options = nil, html_options = nil) do
  #     content
  #   end
  #
  # ==== Examples
  #
  #   UiBibz::Ui::Core::Notifications::AlertHeader.new.render
  #
  #   UiBibz::Ui::Core::Notifications::AlertHeader.new do
  #     'Exemple'
  #   end.render
  #
  class AlertHeader < UiBibz::Ui::Core::Component
    # See UiBibz::Ui::Core::Component.initialize

    def pre_render
      if options[:tap] == false
        html_content
      else
        content_tag :h4, html_content, html_options
      end
    end

    private

    def component_html_classes
      'alert-header'
    end

    def html_content
      output = [glyph_and_content_html]
      output << close_html if options[:closable]
      output.join.html_safe
    end

    def close_html
      content_tag :button, '', type: 'button', class: 'btn-close', 'data-dismiss' => 'alert', 'aria-label' => 'Close'
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ui_bibz-3.0.0.alpha12 lib/ui_bibz/ui/core/notifications/components/alert_header.rb
ui_bibz-3.0.0.alpha11 lib/ui_bibz/ui/core/notifications/components/alert_header.rb
ui_bibz-3.0.0.alpha10 lib/ui_bibz/ui/core/notifications/components/alert_header.rb
ui_bibz-3.0.0.alpha9 lib/ui_bibz/ui/core/notifications/components/alert_header.rb
ui_bibz-3.0.0.alpha8 lib/ui_bibz/ui/core/notifications/components/alert_header.rb
ui_bibz-3.0.0.alpha6 lib/ui_bibz/ui/core/notifications/components/alert_header.rb
ui_bibz-3.0.0.alpha5 lib/ui_bibz/ui/core/notifications/components/alert_header.rb
ui_bibz-3.0.0.alpha3 lib/ui_bibz/ui/core/notifications/components/alert_header.rb
ui_bibz-3.0.0.alpha2 lib/ui_bibz/ui/core/notifications/components/alert_header.rb