Sha256: c4fc077d98cd922098764b9c07e09727a411db87f090947f8311079b42fca16f

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

module Storefront
  # Encapsulates common browser hacks
  module ComponentHelper
    def component_image_tag
      capture_haml do
        haml_tag :span
        haml_concat image_tag()
      end
    end
    
    def popup_button(label, path, message, subtitle, submit = nil, kind = :group)
      link_to "<span>#{label}</span>", path, :class => "delete", "data-message" => message, "data-subtitle" => subtitle, "data-model" => kind.to_s, "data-submit" => submit.to_s
    end
    
    def component_button(*args, &block)
      options = args.extract_options!
      button_options = options.delete(:button_options) || {}
      
      if block_given?
        content = capture(&block)
      else
        label = args.shift
        path  = args.shift
        content = link_to(label, path, button_options)
      end
      
      capture_haml do
        haml_tag :button, options.merge(:class => ["button", options[:class]].compact.uniq.join(" ")) do
          haml_concat content
          haml_tag :span
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
storefront-0.2.1 lib/storefront/helpers/component_helper.rb
storefront-0.2.0 lib/storefront/helpers/component_helper.rb