Class: Bootstrap4RailsComponents::Bootstrap::Components::Button

Inherits:
Base
  • Object
show all
Includes:
Utilities::Activatable, Utilities::CollapseToggleable, Utilities::Disableable, Utilities::Modalable, Utilities::Remotable, Utilities::Sizable, Utilities::Themeable, Utilities::Tooltipable, Utilities::Wrappable
Defined in:
lib/bootstrap4_rails_components/bootstrap/components/button.rb

Overview

Bootstrap Button Component getbootstrap.com/docs/4.1/components/buttons/

Instance Attribute Summary

Attributes included from Utilities::Wrappable

#as

Attributes included from Utilities::Disableable

#as

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Utilities::Wrappable

#utility_initialize

Methods included from Utilities::Tooltipable

#data, #disabled_component_tooltip_wrapper_html_options, #html_options, #tooltip

Methods included from Utilities::Disableable

#disabled

Methods included from Utilities::Themeable

#outlined, #theme

Methods included from Utilities::Modalable

#data, #modal

Methods included from Utilities::Sizable

#size

Methods included from Utilities::Remotable

#data, #remote

Methods included from Utilities::CollapseToggleable

#data

Methods included from Utilities::Collapsible

#collapse, #collapsed, #collapsible

Methods included from Utilities::Activatable

#active

Methods inherited from Base

#component_family, #component_initialize, #data, #html_options, #id, #initialize, #style, #utility_initialize

Constructor Details

This class inherits a constructor from Bootstrap4RailsComponents::Bootstrap::Components::Base

Instance Method Details

#blockObject



33
34
35
# File 'lib/bootstrap4_rails_components/bootstrap/components/button.rb', line 33

def block
  options.fetch(:block, false)
end

#hrefObject



37
38
39
40
# File 'lib/bootstrap4_rails_components/bootstrap/components/button.rb', line 37

def href
  return if as != :a
  collapse ? collapse : (options[:href] || '#')
end

#remove_component_css_classesObject



42
43
44
# File 'lib/bootstrap4_rails_components/bootstrap/components/button.rb', line 42

def remove_component_css_classes
  options.fetch(:remove_component_css_classes, false)
end

#renderObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bootstrap4_rails_components/bootstrap/components/button.rb', line 19

def render
  if tooltip && disabled
    (:span, disabled_component_tooltip_wrapper_html_options) do
      (as, html_options) do
        (block_given? ? yield : body)
      end
    end
  else
    (as, html_options) do
      (block_given? ? yield : body)
    end
  end
end