Class: Hyrax::Forms::Admin::Appearance
- Inherits:
-
Object
- Object
- Hyrax::Forms::Admin::Appearance
- 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
-
.color_params ⇒ Object
A list of parameters that are related to custom colors.
-
.model_name ⇒ Object
This allows this object to route to the correct path.
-
.permitted_params ⇒ Object
Override this method if your form takes more than just the color_params.
Instance Method Summary collapse
-
#footer_link_color ⇒ Object
The color for links in the footer.
-
#header_background_color ⇒ Object
The color for the background of the header and footer bars.
-
#header_text_color ⇒ Object
The color for the text in the header bar.
-
#initialize(attributes = {}) ⇒ Appearance
constructor
A new instance of Appearance.
-
#link_color ⇒ Object
The color links.
-
#persisted? ⇒ Boolean
Required to back a form (for route determination).
-
#primary_button_active_background_color ⇒ Object
The color for the background of active “primary” buttons.
-
#primary_button_active_border_color ⇒ Object
The color for the border of active “primary” buttons.
-
#primary_button_background_color ⇒ Object
The background color for “primary” buttons.
-
#primary_button_border_color ⇒ Object
The border color for “primary” buttons.
-
#primary_button_focus_background_color ⇒ Object
The color for the background of focused “primary” buttons.
-
#primary_button_focus_border_color ⇒ Object
The color for the border of focused “primary” buttons.
-
#primary_button_hover_background_color ⇒ Object
The mouse over color for “primary” buttons.
-
#primary_button_hover_border_color ⇒ Object
The mouse over color for the border of “primary” buttons.
-
#to_key ⇒ Object
Required to back a form.
-
#update! ⇒ Object
Persist the form values.
Constructor Details
#initialize(attributes = {}) ⇒ Appearance
Returns a new instance of Appearance.
11 12 13 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 11 def initialize(attributes = {}) @attributes = attributes end |
Class Method Details
.color_params ⇒ Object
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_name ⇒ Object
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_params ⇒ Object
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
#footer_link_color ⇒ Object
The color for links in the footer
54 55 56 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 54 def block_for('footer_link_color', '#ffebcd') end |
#header_background_color ⇒ Object
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_color ⇒ Object
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 |
#link_color ⇒ Object
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)
34 35 36 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 34 def persisted? true end |
#primary_button_active_background_color ⇒ Object
The color for the background of active “primary” buttons
79 80 81 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 79 def darken_color(, 0.1) end |
#primary_button_active_border_color ⇒ Object
The color for the border of active “primary” buttons
84 85 86 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 84 def darken_color(, 0.12) end |
#primary_button_background_color ⇒ Object
The background color for “primary” buttons
59 60 61 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 59 def block_for('primary_button_background_color', '#286090') end |
#primary_button_border_color ⇒ Object
The border color for “primary” buttons
64 65 66 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 64 def @primary_button_border ||= darken_color(, 0.05) end |
#primary_button_focus_background_color ⇒ Object
The color for the background of focused “primary” buttons
89 90 91 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 89 def darken_color(, 0.1) end |
#primary_button_focus_border_color ⇒ Object
The color for the border of focused “primary” buttons
94 95 96 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 94 def darken_color(, 0.25) end |
#primary_button_hover_background_color ⇒ Object
The mouse over color for “primary” buttons
69 70 71 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 69 def darken_color(, 0.1) end |
#primary_button_hover_border_color ⇒ Object
The mouse over color for the border of “primary” buttons
74 75 76 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 74 def darken_color(, 0.12) end |
#to_key ⇒ Object
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 |