Class: NfgUi::Components::Elements::Button

Overview

Button doesn’t have any customizations unique to the design system yet As such, the NFG UI Button is simply a bootstrap Button behind the scenes. Traits will eventually be connected here.

Constant Summary

Constants included from Traits::Remote

Traits::Remote::TRAITS

Constants included from Traits::Disable

Traits::Disable::TRAITS

Constants included from Traits::Theme

Traits::Theme::COLOR_TRAITS, Traits::Theme::TRAITS

Constants included from Traits::Size

Traits::Size::TRAITS

Constants included from Traits::DisableWith

Traits::DisableWith::TRAITS

Constants included from Traits::Button

Traits::Button::TRAITS

Constants included from Traits::Active

Traits::Active::TRAITS

Constants included from Traits

Traits::REGISTERED_TRAITS, Traits::TRAIT_MODULES

Instance Attribute Summary

Attributes included from Bootstrap::Utilities::Wrappable

#as

Attributes included from Bootstrap::Utilities::Disableable

#as

Attributes inherited from Bootstrap::Components::Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Traits::Remote

#remote_trait

Methods included from Traits::Disable

#disabled_trait

Methods included from Traits::Theme

#danger_trait, #dark_trait, #info_trait, #light_trait, #outlined_trait, #primary_trait, #secondary_trait, #success_trait, #warning_trait, #white_trait

Methods included from Traits::Size

#lg_trait, #md_trait, #sm_trait, #xl_trait

Methods included from Traits::DisableWith

#disable_with_trait

Methods included from Traits::Button

#block_trait, #close_trait, #link_trait, #outlined_trait, #remote_trait, #submit_trait

Methods included from Traits::Active

#active_trait

Methods included from Utilities::Renderable

#render_if, #render_unless

Methods included from Utilities::Describable

#describe

Methods included from Utilities::Traitable

#traits, #utility_initialize

Methods included from Utilities::LeftIconable

#left_icon

Methods included from Utilities::Iconable

#icon

Methods included from Utilities::DisableWithable

#disable_with

Methods included from Utilities::Confirmable

#confirm

Methods inherited from Bootstrap::Components::Button

#block, #href, #remove_component_css_classes

Methods included from Bootstrap::Utilities::Wrappable

#utility_initialize

Methods included from Bootstrap::Utilities::Tooltipable

#disabled_component_tooltip_wrapper_html_options, #html_options, #tooltip

Methods included from Bootstrap::Utilities::Disableable

#disabled

Methods included from Bootstrap::Utilities::Themeable

#outlined, #theme

Methods included from Bootstrap::Utilities::Modalable

#modal

Methods included from Bootstrap::Utilities::Sizable

#size

Methods included from Bootstrap::Utilities::Remotable

#remote

Methods included from Bootstrap::Utilities::Collapsible

#collapse, #collapsed, #collapsible

Methods included from Bootstrap::Utilities::Activatable

#active

Methods inherited from Bootstrap::Components::Base

#component_family, #href, #html_options, #id, #initialize, #style

Constructor Details

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

Instance Method Details

#closeObject

TODO



32
33
34
35
# File 'lib/nfg_ui/components/elements/button.rb', line 32

def close
  # convert :close trait to
  # close: :alert
end

#dataObject



27
28
29
# File 'lib/nfg_ui/components/elements/button.rb', line 27

def data
  dismiss ? super.merge!(dismiss: dismiss) : super
end

#dismissObject



41
42
43
# File 'lib/nfg_ui/components/elements/button.rb', line 41

def dismiss
  options.fetch(:dismiss, nil)
end

#methodObject



37
38
39
# File 'lib/nfg_ui/components/elements/button.rb', line 37

def method
  options.fetch(:method, nil)
end

#renderObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/nfg_ui/components/elements/button.rb', line 45

def render
  @body = yield if block_given?

  if tooltip && disabled
    (:span, disabled_component_tooltip_wrapper_html_options) do
      (as, html_options) do
        capture do
          concat(left_icon_component) if left_icon
          concat(body)
          concat(right_icon_component) if icon
        end
      end
    end

  else
    (as, html_options) do
      capture do
        concat(left_icon_component) if left_icon
        concat(body)
        concat(right_icon_component) if icon
      end
    end
  end
end