class NfgUi::Components::Elements::Button
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.
Public Instance Methods
close()
click to toggle source
TODO
# File lib/nfg_ui/components/elements/button.rb, line 32 def close # convert :close trait to # close: :alert end
data()
click to toggle source
Calls superclass method
NfgUi::Components::Utilities::Methodable#data
# File lib/nfg_ui/components/elements/button.rb, line 27 def data dismiss ? super.merge!(dismiss: dismiss) : super end
dismiss()
click to toggle source
# File lib/nfg_ui/components/elements/button.rb, line 41 def dismiss options.fetch(:dismiss, nil) end
method()
click to toggle source
# File lib/nfg_ui/components/elements/button.rb, line 37 def method options.fetch(:method, nil) end
render() { || ... }
click to toggle source
# File lib/nfg_ui/components/elements/button.rb, line 45 def render @body = yield if block_given? if tooltip && disabled content_tag(:span, disabled_component_tooltip_wrapper_html_options) do content_tag(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 content_tag(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
Private Instance Methods
base_element()
click to toggle source
# File lib/nfg_ui/components/elements/button.rb, line 89 def base_element as end
dismiss_component?()
click to toggle source
# File lib/nfg_ui/components/elements/button.rb, line 93 def dismiss_component? dismiss == :alert || dismiss == :modal end
left_icon_component()
click to toggle source
# File lib/nfg_ui/components/elements/button.rb, line 72 def left_icon_component NfgUi::Components::Foundations::Icon.new({ traits: [left_icon], class: NfgUi::Components::Foundations::Icon::LEFT_ICON_SPACER_CSS_CLASS }, view_context).render end
non_html_attribute_options()
click to toggle source
Calls superclass method
NfgUi::Components::Utilities::Renderable#non_html_attribute_options
# File lib/nfg_ui/components/elements/button.rb, line 97 def non_html_attribute_options super.push(:dismiss) end
right_icon_class()
click to toggle source
# File lib/nfg_ui/components/elements/button.rb, line 85 def right_icon_class NfgUi::Components::Foundations::Icon::RIGHT_ICON_SPACER_CSS_CLASS if body.present? end
right_icon_component()
click to toggle source
# File lib/nfg_ui/components/elements/button.rb, line 79 def right_icon_component NfgUi::Components::Foundations::Icon.new({ traits: [icon, :right], class: right_icon_class }, view_context).render end