Class: NfgUi::Components::Patterns::SlatActions

Inherits:
Base show all
Includes:
Utilities::Patches::IntegratedSlatAction
Defined in:
lib/nfg_ui/components/patterns/slat_actions.rb

Overview

Slat doc coming soon

Constant Summary

Constants included from Traits::Theme

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

Constants included from Traits

Traits::REGISTERED_TRAITS, Traits::TRAIT_MODULES

Instance Attribute Summary

Attributes inherited from Bootstrap::Components::Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Utilities::Patches::IntegratedSlatAction

#button, #confirm, #disable_with, #href, #method, #outlined, #remote, #render_integrated_slat_action, #theme

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 Utilities::Iconable

#icon

Methods included from Utilities::Traitable

#traits, #utility_initialize

Methods included from Utilities::Renderable

#render_if, #render_unless

Methods included from Utilities::Describable

#data, #describe

Methods inherited from Bootstrap::Components::Base

#data, #href, #html_options, #id, #initialize, #style

Constructor Details

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

Instance Method Details

#component_familyObject



20
21
22
# File 'lib/nfg_ui/components/patterns/slat_actions.rb', line 20

def component_family
  :slats
end

Signals whether or not this SlatActions will house a menu This is a critical condition. When false, a SlatAction is automatically integrated on your behalf.



27
28
29
# File 'lib/nfg_ui/components/patterns/slat_actions.rb', line 27

def menu
  options.fetch(:menu, true)
end

#renderObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/nfg_ui/components/patterns/slat_actions.rb', line 31

def render
  (:div, html_options) do
    if menu
      NfgUi::Components::Patterns::Dropdown.new({ }, view_context).render do
        capture do
          concat(NfgUi::Components::Elements::DropdownToggle.new({ **default_dropdown_toggle_options, body: dropdown_toggle_body }, view_context).render)
          concat(NfgUi::Components::Patterns::DropdownMenu.new({ traits: [:right] }, view_context).render {
            (block_given? ? yield : body)
          })
        end
      end
    else
      # Render the integrated slat action and pass in all of the
      # related slat action options that are present in this SlatActions `:options`
      render_integrated_slat_action
    end
  end
end