Module: NfgUi::Components::Utilities::ResourceThemeable
- Included in:
- Patterns::PageHeader, ResourceThemesHelper
- Defined in:
- lib/nfg_ui/components/utilities/resource_themeable.rb
Overview
The library of dedicated theme resources in Evo & DMS
Constant Summary collapse
- FALLBACK_ICON =
'heart-o'
- DEFAULT_THEME_COLOR =
'primary'
Instance Method Summary collapse
-
#resource_theme_color(object = nil) ⇒ Object
This method represents an existential question for the UX team at NFG.
- #resource_theme_icon(object = nil) ⇒ Object
- #resource_theme_name(object = nil) ⇒ Object
Instance Method Details
#resource_theme_color(object = nil) ⇒ Object
This method represents an existential question for the UX team at NFG
For now, we are defaulting everything to primary However, the structure is in place to facilitate resource specific theming ala Donor Management.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nfg_ui/components/utilities/resource_themeable.rb', line 16 def resource_theme_color(object = nil) case resource_theme_name(object) when 'Project' DEFAULT_THEME_COLOR when 'Campaign' DEFAULT_THEME_COLOR else DEFAULT_THEME_COLOR end end |
#resource_theme_icon(object = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/nfg_ui/components/utilities/resource_themeable.rb', line 27 def resource_theme_icon(object = nil) case resource_theme_name(object) when 'Newsletter' 'at' when 'Report' 'bar-chart' when 'Campaign', 'Project', 'Cause', 'Event' 'bullhorn' when 'Entity' 'cog' when 'PaymentGatewayProfile' 'credit-card' when 'Donation', 'Order' 'dollar' when 'CustomContent', 'SiteContent' 'file-text-o' when 'Donor', 'Admin' 'user' when 'Integration' 'exchange' when 'RecurringDonation' 'refresh' else FALLBACK_ICON end end |
#resource_theme_name(object = nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/nfg_ui/components/utilities/resource_themeable.rb', line 54 def resource_theme_name(object = nil) # If an object is included: if object.present? if object.is_a?(String) object elsif object.is_a?(Class) object.name elsif object.is_a?(Symbol) object.to_s.classify else object.class.name end # If this method was called from a view as a normal helper method, # check for controller_name elsif defined?(controller_name) formatted_controller_name(controller_name) # If this method was called from within a design system component # then seek the defined view_context elsif defined?(view_context) formatted_controller_name(view_context.controller_name) # If nothing responds, return an empty string else '' end end |