Sha256: e1ddf8d57922cf922dcde6c8fd63c8e8c0ea67f52e71394fd7914b1496e4fa7e

Contents?: true

Size: 1.44 KB

Versions: 54

Compression:

Stored size: 1.44 KB

Contents

module Para
  module Markup
    class Modal < Para::Markup::Component
      def container(options = {}, &block)
        merge_class!(options, "modal")
        merge_class!(options, "fade") unless options.delete(:fade) == false
        merge_class!(options, "in") if options.delete(:displayed)

        options.reverse_merge!(
          tabindex: "-1", role: "dialog", "aria-hidden" => "true", "aria-labelledby" => (options[:id] || "modal")
        )

        content_tag(:div, options) do
          content_tag(:div, class: "modal-dialog") do
            content_tag(:div, class: "modal-content") do
              capture { block.call(self) }
            end
          end
        end
      end

      def header(options = {}, &block)
        merge_class!(options, "modal-header")

        content_tag(:div, options) do
          content_tag(:button, "&times;".html_safe, class: "close", type: "button",
            "data-dismiss" => "modal", "aria-hidden" => "true"
          ) +
          content_tag(:h4, class: "modal-title") do
            capture { block.call }
          end
        end
      end

      def body(options = {}, &block)
        merge_class!(options, "modal-body")

        content_tag(:div, options) do
          capture { block.call }
        end
      end

      def footer(options = {}, &block)
        merge_class!(options, "modal-footer")

        content_tag(:div, options) do
          capture { block.call }
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
para-0.11.4 lib/para/markup/modal.rb
para-0.11.3 lib/para/markup/modal.rb
para-0.11.2 lib/para/markup/modal.rb
para-0.11.1 lib/para/markup/modal.rb
para-0.11.0 lib/para/markup/modal.rb
para-0.10.0 lib/para/markup/modal.rb
para-0.9.4 lib/para/markup/modal.rb
para-0.9.3.3 lib/para/markup/modal.rb
para-0.9.3.2 lib/para/markup/modal.rb
para-0.9.3.1 lib/para/markup/modal.rb
para-0.9.2 lib/para/markup/modal.rb
para-0.9.0 lib/para/markup/modal.rb
para-0.8.15 lib/para/markup/modal.rb
para-0.8.14 lib/para/markup/modal.rb
para-0.8.13 lib/para/markup/modal.rb
para-0.8.12 lib/para/markup/modal.rb
para-0.8.11 lib/para/markup/modal.rb
para-0.8.10 lib/para/markup/modal.rb
para-0.8.9 lib/para/markup/modal.rb
para-0.8.8 lib/para/markup/modal.rb