Module: MaterialDesign::ButtonHelper

Defined in:
app/helpers/material_design/button_helper.rb

Instance Method Summary collapse

Instance Method Details

#md_button_tag(name = nil, content_or_options = nil, html_options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/material_design/button_helper.rb', line 19

def md_button_tag(name = nil, content_or_options = nil, html_options = {})
  variant = html_options[:variant] || "filled"
  color = html_options[:color] || "primary"
  icon = html_options[:icon]
  html_options[:class] = "button--container button__#{variant}--#{color}"

  button_tag(content_or_options, html_options.except(:variant, :color)) do
    (:div, class: "layer-state layer-state__#{variant}") do
      (:div, class: "button--content") do
        concat(render("material_design/icons/icon", locals: { icon: icon, size: 18 })) if icon
        concat(name)
      end
    end
  end
end

#md_button_to(name = nil, options = nil, html_options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/material_design/button_helper.rb', line 3

def md_button_to(name = nil, options = nil, html_options = {})
  variant = html_options[:variant] || "filled"
  color = html_options[:color] || "primary"
  icon = html_options[:icon]
  html_options[:class] = "button--container button__#{variant}--#{color}"

  button_to(options, html_options.except(:variant, :color, :icon)) do
    (:div, class: "layer-state layer-state__#{variant}") do
      (:div, class: "button--content") do
        concat(render("material_design/icons/icon", locals: { icon: icon, size: 18 })) if icon
        concat(name)
      end
    end
  end
end