Sha256: c5774026f06d5f44c8e7f14cb3a967591c149c944858a8f89199dbadc7a9c248

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

require 'railsstrap/classes/button'

module Railsstrap
  module Helpers
    # Displays a Bootstrap-styled button.
    # @see http://getbootstrap.com/css/#buttons
    # @return [String] the HTML to display a Bootstrap-styled button.
    # @overload button(caption, options = {})
    #   @param [#to_s] caption the caption to display in the button.
    #   @param [Hash] options the options for the button. Any option not
    #     listed below is passed as an HTML attribute to the `<button>` tag.
    #   @option options [#to_s] :variant (:default) the variant alternative
    #     to apply to the button. Can be `:danger`, `:info`, `:link`,
    #     `:primary`, `:success` or `:warning`.
    #   @option options [#to_s] :size the size of the button.
    #     Can be `:extra_small` (alias `:xs`), `:large` (alias `:lg`) or
    #     `:small` (alias `:sm`).
    #   @option options [#to_s] :layout if set to `:block`, span the button
    #     for the full width of the parent.
    #   @example Display a button styled as a link.
    #       button 'Click here', variant: :link
    # @overload button(options = {}, &block)
    #   @param [Hash] options the options for the button (see above).
    #   @yieldreturn [#to_s] the caption to display in the button.
    #   @example Display a button with an HTML caption.
    #       button do
    #         content_tag :strong, 'Click here'
    #       end
    def button(*args, &block)
      button = Railsstrap::Button.new(self, *args, &block)
      button.extract! :variant, :size, :layout

      button.append_class! :btn
      button.append_class! button.variant_class
      button.append_class! button.size_class
      button.append_class! button.layout_class
      button.content_tag :button
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
railsstrap-4.0.0.beta3 lib/railsstrap/helpers/button_helper.rb
railsstrap-4.0.0.beta2 lib/railsstrap/helpers/button_helper.rb