Sha256: f33420e921ab8bb6effb456c37c2f93a8b45c7528d3d73ef4059e488f6f83967

Contents?: true

Size: 1.6 KB

Versions: 37

Compression:

Stored size: 1.6 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::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 initialize content = nil, options = nil, html_options = nil, &block
      super
    end

    def pre_render
      if options[:tap]
        content_tag :h4, html_content, html_options
      else
        html_content
      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: 'close', "data-dismiss" => "alert", "aria-label" => "Close" do
        concat content_tag :span, "×", "aria-hidden" => true
        concat content_tag :span, "Close", class: "sr-only"
      end
    end

  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

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