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

Instance Method Summary collapse

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.



14
15
16
17
18
19
20
21
22
23
# File 'lib/nfg_ui/components/utilities/resource_themeable.rb', line 14

def resource_theme_color(object = nil)
  case resource_theme_name(object)
  when 'Project'
    'primary'
  when 'Campaign'
    'primary'
  else
    'primary'
  end
end

#resource_theme_icon(object = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/nfg_ui/components/utilities/resource_themeable.rb', line 25

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
    'heart-o'
  end
end

#resource_theme_name(object = nil) ⇒ Object



52
53
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
# File 'lib/nfg_ui/components/utilities/resource_themeable.rb', line 52

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