Class: Hyrax::Forms::Admin::Appearance

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Defined in:
app/forms/hyrax/forms/admin/appearance.rb

Overview

An object to model and persist the form data for the appearance customization menu

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Appearance

Returns a new instance of Appearance.

Parameters:

  • attributes (Hash) (defaults to: {})

    the list of parameters from the form



11
12
13
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 11

def initialize(attributes = {})
  @attributes = attributes
end

Class Method Details

.color_paramsObject

A list of parameters that are related to custom colors



106
107
108
109
110
111
112
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 106

def self.color_params
  [:header_background_color,
   :header_text_color,
   :link_color,
   :footer_link_color,
   :primary_button_background_color]
end

.model_nameObject

This allows this object to route to the correct path



19
20
21
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 19

def self.model_name
  ActiveModel::Name.new(self, Hyrax, "Hyrax::Admin::Appearance")
end

.permitted_paramsObject

Override this method if your form takes more than just the color_params



24
25
26
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 24

def self.permitted_params
  color_params
end

Instance Method Details

The color for links in the footer



54
55
56
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 54

def footer_link_color
  block_for('footer_link_color', '#ffebcd')
end

#header_background_colorObject

The color for the background of the header and footer bars



39
40
41
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 39

def header_background_color
  block_for('header_background_color', '#3c3c3c')
end

#header_text_colorObject

The color for the text in the header bar



44
45
46
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 44

def header_text_color
  block_for('header_text_color', '#dcdcdc')
end

The color links



49
50
51
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 49

def link_color
  block_for('link_color', '#2e74b2')
end

#persisted?Boolean

Required to back a form (for route determination)

Returns:

  • (Boolean)


34
35
36
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 34

def persisted?
  true
end

#primary_button_active_background_colorObject

The color for the background of active “primary” buttons



79
80
81
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 79

def primary_button_active_background_color
  darken_color(primary_button_background_color, 0.1)
end

#primary_button_active_border_colorObject

The color for the border of active “primary” buttons



84
85
86
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 84

def primary_button_active_border_color
  darken_color(primary_button_border_color, 0.12)
end

#primary_button_background_colorObject

The background color for “primary” buttons



59
60
61
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 59

def primary_button_background_color
  block_for('primary_button_background_color', '#286090')
end

#primary_button_border_colorObject

The border color for “primary” buttons



64
65
66
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 64

def primary_button_border_color
  @primary_button_border ||= darken_color(primary_button_background_color, 0.05)
end

#primary_button_focus_background_colorObject

The color for the background of focused “primary” buttons



89
90
91
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 89

def primary_button_focus_background_color
  darken_color(primary_button_background_color, 0.1)
end

#primary_button_focus_border_colorObject

The color for the border of focused “primary” buttons



94
95
96
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 94

def primary_button_focus_border_color
  darken_color(primary_button_border_color, 0.25)
end

#primary_button_hover_background_colorObject

The mouse over color for “primary” buttons



69
70
71
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 69

def primary_button_hover_background_color
  darken_color(primary_button_background_color, 0.1)
end

#primary_button_hover_border_colorObject

The mouse over color for the border of “primary” buttons



74
75
76
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 74

def primary_button_hover_border_color
  darken_color(primary_button_border_color, 0.12)
end

#to_keyObject

Required to back a form



29
30
31
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 29

def to_key
  []
end

#update!Object

Persist the form values



99
100
101
102
103
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 99

def update!
  self.class.color_params.each do |field|
    update_block(field, attributes[field]) if attributes[field]
  end
end