Module: NfgUi::Components::Traits::Icon
- Includes:
- Utilities::Traits::TraitUtilities
- Included in:
- Foundations::Icon
- Defined in:
- lib/nfg_ui/components/traits/icon.rb
Overview
Access to pre-designed Icon traits
Constant Summary collapse
- TRAITS =
%i[loader tip].freeze
Instance Method Summary collapse
- #loader_trait ⇒ Object
-
#tip_trait ⇒ Object
The defacto “(?)” tip icon Usage: ui.nfg :icon, :tip, tooltip: ‘The tip’.
Instance Method Details
#loader_trait ⇒ Object
12 13 14 |
# File 'lib/nfg_ui/components/traits/icon.rb', line 12 def loader_trait [:icon] = 'spinner spin fw' end |
#tip_trait ⇒ Object
The defacto “(?)” tip icon Usage: ui.nfg :icon, :tip, tooltip: ‘The tip’
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nfg_ui/components/traits/icon.rb', line 19 def tip_trait maybe_update_option(:icon, value: NfgUi::DEFAULT_TIP_ICON) maybe_update_option(:theme, value: NfgUi::DEFAULT_TIP_THEME) if [:text].present? # We are unable to use #maybe_update_option method due to how traits # are calculated when sub components are # rendered within sub components (example: nav_link being rendered within a nav_item)... # # This will leave options[:right] alone unless # there is a value stored in the component's options[:right] # # Example where options[:right] is left alone: # ui.nfg(:icon, :tip, right: false, text: 'Tip icon is on the left') # # Example where options[:right] gets updated: # ui.nfg(:icon, :tip, text: 'Tip icon is on the right') [:right] = true if [:right].nil? [:class] += ' fa-fw' end end |