Sha256: af0257ddb0d812bdd2ac95c6029165ba9de6ca5c9b3bd87c4af1fbfd43ed1f82

Contents?: true

Size: 1.77 KB

Versions: 7

Compression:

Stored size: 1.77 KB

Contents

require 'bh/classes/base'

module Bh
  module Classes
    class Button < Base
      # @return [#to_s] the context-related class to assign to the button.
      def context_class
        Button.contexts[@options[:context]]
      end

      # @return [#to_s] the size-related class to assign to the alert box.
      def size_class
        Button.sizes[@options[:size]]
      end

      # @return [#to_s] the layout-related class to assign to the alert box.
      def layout_class
        Button.layouts[@options[:layout]]
      end

    private

      # @return [Hash<Symbol, String>] the classes that Bootstrap requires to
      #   append to buttons for each possible context.
      def self.contexts
        HashWithIndifferentAccess.new(:'btn-default').tap do |klass|
          klass[:danger]  = :'btn-danger'
          klass[:info]    = :'btn-info'
          klass[:link]    = :'btn-link'
          klass[:primary] = :'btn-primary'
          klass[:success] = :'btn-success'
          klass[:warning] = :'btn-warning'
        end
      end

      # @return [Hash<Symbol, String>] the classes that Bootstrap requires to
      #   append to buttons for each possible size.
      def self.sizes
        HashWithIndifferentAccess.new.tap do |klass|
          klass[:extra_small] = :'btn-xs'
          klass[:large]       = :'btn-lg'
          klass[:lg]          = :'btn-lg'
          klass[:sm]          = :'btn-sm'
          klass[:small]       = :'btn-sm'
          klass[:xs]          = :'btn-xs'
        end
      end

      # @return [Hash<Symbol, String>] the classes that Bootstrap requires to
      #   append to buttons for each possible layout.
      def self.layouts
        HashWithIndifferentAccess.new.tap do |klass|
          klass[:block] = :'btn-block'
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bh-1.3.6 lib/bh/classes/button.rb
bh-1.3.5 lib/bh/classes/button.rb
bh-1.3.4 lib/bh/classes/button.rb
bh-1.3.3 lib/bh/classes/button.rb
bh-1.3.1 lib/bh/classes/button.rb
bh-1.3.0 lib/bh/classes/button.rb
bh-1.2.0 lib/bh/classes/button.rb