Module: NfgUi::Components::Utilities::Patches::IntegratedSlatAction
- Includes:
- Traits::Theme, Iconable
- Included in:
- Patterns::SlatActions
- Defined in:
- lib/nfg_ui/components/utilities/patches/integrated_slat_action.rb
Overview
Terminology: SlatAction - is the equivalent of a dropdown menu item SlatActions - is the parent / wrapping component of the SlatAction(s)
and… Integrated Slat Action essentially replaces a dropdown toggle & dropdown menu with either a text link or a button component.
Usage: When you are creating a slat that does not need a menu but has a singular action link For example: when the only option you have on a slat is to delete that item.
This module allows you to pass in options that will automatically generate a slat action for you … without having to manually add a slat_action to your code.
Example usage:
ui.nfg :slat_actions, menu: false, icon: ‘trash’, body: ‘Delete’, href: ‘#nogo’
The above will automatically generate a slat action so you do not need to add a slat action in the slat_actions (note: plural slat_actions)
This is a monkeypatch while we re-evaluate the Slat component suite so as not to break existing code implementation on our apps.
Constant Summary
Constants included from Traits::Theme
Traits::Theme::COLOR_TRAITS, Traits::Theme::TRAITS
Instance Method Summary collapse
-
#button ⇒ Object
This sets whether or not the SlatAction is a button.
-
#confirm ⇒ Object
Passes in the rails confirm option to the slat action component.
-
#disable_with ⇒ Object
Passes the :disable_with option, when present, to the integrated slat action component – this adds the rails disable_with Rails example: link_to ‘Delete’, …, disable_with: ‘Deleting…’.
-
#href ⇒ Object
Sets a fallback for href so that integrated action items are still correctly styled.
-
#method ⇒ Object
Passes in the rails confirm option to the slat action component.
-
#outlined ⇒ Object
Allow for outline settings to be added Assumes true if ‘button: true` per design system style guide expectations.
-
#remote ⇒ Object
Passes in the rails :remote option to the slat action component Rails example: link_to ‘Get Started’, remote: true.
-
#render_integrated_slat_action ⇒ Object
Render the component!.
-
#theme ⇒ Object
Passes the standard ‘:theme` option to the integrated Slat Action.
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 Iconable
Instance Method Details
#button ⇒ Object
This sets whether or not the SlatAction is a button. If it’s not a button, the integrated slat action is rendered via a content_tag as a normal link.
If it is a button, the integrated slat action is rendered as a button component (NfgUi::Components::Elements::Button)
44 45 46 |
# File 'lib/nfg_ui/components/utilities/patches/integrated_slat_action.rb', line 44 def .fetch(:button, false) end |
#confirm ⇒ Object
Passes in the rails confirm option to the slat action component. Rails example: link_to ‘Delete’, …, confirm: ‘Are you sure?’
50 51 52 |
# File 'lib/nfg_ui/components/utilities/patches/integrated_slat_action.rb', line 50 def confirm .fetch(:confirm, nil) end |
#disable_with ⇒ Object
Passes the :disable_with option, when present, to the integrated slat action component – this adds the rails disable_with Rails example: link_to ‘Delete’, …, disable_with: ‘Deleting…’
57 58 59 |
# File 'lib/nfg_ui/components/utilities/patches/integrated_slat_action.rb', line 57 def disable_with .fetch(:disable_with, nil) end |
#href ⇒ Object
Sets a fallback for href so that integrated action items are still correctly styled
64 65 66 |
# File 'lib/nfg_ui/components/utilities/patches/integrated_slat_action.rb', line 64 def href super || '#' end |
#method ⇒ Object
Passes in the rails confirm option to the slat action component. Rails example: link_to ‘Update’, …, method: :patch
70 71 72 |
# File 'lib/nfg_ui/components/utilities/patches/integrated_slat_action.rb', line 70 def method .fetch(:method, nil) end |
#outlined ⇒ Object
Allow for outline settings to be added Assumes true if ‘button: true` per design system style guide expectations.
77 78 79 |
# File 'lib/nfg_ui/components/utilities/patches/integrated_slat_action.rb', line 77 def outlined [:outlined] || end |
#remote ⇒ Object
Passes in the rails :remote option to the slat action component Rails example: link_to ‘Get Started’, remote: true
83 84 85 |
# File 'lib/nfg_ui/components/utilities/patches/integrated_slat_action.rb', line 83 def remote .fetch(:remote, nil) end |
#render_integrated_slat_action ⇒ Object
Render the component!
88 89 90 |
# File 'lib/nfg_ui/components/utilities/patches/integrated_slat_action.rb', line 88 def render_integrated_slat_action ? : render_link end |
#theme ⇒ Object
Passes the standard ‘:theme` option to the integrated Slat Action
When the slat action component is a ‘button` (`button: true`): The integrated slat action will default to the `:secondary` theme per the design system style guide.
The default ‘:secondary` theme can be manually overridden by passing in a `:theme` trait or `:theme` option to the parent SlatActions component.
100 101 102 |
# File 'lib/nfg_ui/components/utilities/patches/integrated_slat_action.rb', line 100 def theme .fetch(:theme, nil) end |