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



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/nfg_ui/components/patterns/slat_actions.rb', line 50

def render
  (:div, html_options) do
    if menu
      if slat_header
        (:h6, " ".html_safe, class: 'display-4')
      else
        NfgUi::Components::Patterns::Dropdown.new({ }, view_context).render do
          capture do
            concat(NfgUi::Components::Elements::DropdownToggle.new({ **default_dropdown_toggle_options, body: ('Actions' if wide)}, view_context).render)
            concat(NfgUi::Components::Patterns::DropdownMenu.new({ traits: [:right] }, view_context).render {
              (block_given? ? yield : body)
            })
          end
        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

#slat_headerObject

Signal if this slat_action is being used In the slat_header area of the Slats

If so, this then customizes the output of the SlatActions to ensure that the widths of the slat_header columns is accurate and matches the width of the slats below.



37
38
39
# File 'lib/nfg_ui/components/patterns/slat_actions.rb', line 37

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

#wideObject

Signals if this is a wide SlatActions. This is a stylistic update which is used in situations like shopping carts where you may only be providing a summary and have no actions or extra columns.

Note: Further documentation is needed on this



46
47
48
# File 'lib/nfg_ui/components/patterns/slat_actions.rb', line 46

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