Sha256: 7f55e34c03c6dee632006e93ec02cb38c105df79c7daf8e185c5676f0ac1fa16

Contents?: true

Size: 897 Bytes

Versions: 59

Compression:

Stored size: 897 Bytes

Contents

module Para
  module Markup
    class Alert < Para::Markup::Component
      def container(message, options = {}, &block)
        if block
          options = message
          message = capture { block.call }
        end

        type = options.delete(:type) || 'info'

        merge_class!(options, "alert")
        merge_class!(options, "alert-#{ type }")

        dismissable = !options.key?(:dismissable) || options.delete(:dismissable)

        merge_class!(options, "alert-dismissable") if dismissable

        content_tag :div, options do
          if dismissable
            close_button + message
          else
            message
          end
        end
      end

      private

      def close_button
        content_tag(:button, type: "button", class: "close", "data-dismiss" => "alert") do
          content_tag(:span, '&times;'.html_safe)
        end
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
para-0.12.4 lib/para/markup/alert.rb
para-0.12.3 lib/para/markup/alert.rb
para-0.12.2 lib/para/markup/alert.rb
para-0.12.1 lib/para/markup/alert.rb
para-0.12.0 lib/para/markup/alert.rb
para-0.11.4 lib/para/markup/alert.rb
para-0.11.3 lib/para/markup/alert.rb
para-0.11.2 lib/para/markup/alert.rb
para-0.11.1 lib/para/markup/alert.rb
para-0.11.0 lib/para/markup/alert.rb
para-0.10.0 lib/para/markup/alert.rb
para-0.9.4 lib/para/markup/alert.rb
para-0.9.3.3 lib/para/markup/alert.rb
para-0.9.3.2 lib/para/markup/alert.rb
para-0.9.3.1 lib/para/markup/alert.rb
para-0.9.2 lib/para/markup/alert.rb
para-0.9.0 lib/para/markup/alert.rb
para-0.8.15 lib/para/markup/alert.rb
para-0.8.14 lib/para/markup/alert.rb
para-0.8.13 lib/para/markup/alert.rb