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.
10 11 12 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 10 def initialize(attributes = {}) @attributes = attributes end |
Class Method Details
.color_params ⇒ Object
A list of parameters that are related to custom colors
105 106 107 108 109 110 111 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 105 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
18 19 20 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 18 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
23 24 25 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 23 def self.permitted_params color_params end |
Instance Method Details
#footer_link_color ⇒ Object
The color for links in the footer
53 54 55 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 53 def block_for('footer_link_color', '#ffebcd') end |
#header_background_color ⇒ Object
The color for the background of the header and footer bars
38 39 40 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 38 def header_background_color block_for('header_background_color', '#3c3c3c') end |
#header_text_color ⇒ Object
The color for the text in the header bar
43 44 45 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 43 def header_text_color block_for('header_text_color', '#dcdcdc') end |
#link_color ⇒ Object
The color links
48 49 50 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 48 def link_color block_for('link_color', '#2e74b2') end |
#persisted? ⇒ Boolean
Required to back a form (for route determination)
33 34 35 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 33 def persisted? true end |
#primary_button_active_background_color ⇒ Object
The color for the background of active “primary” buttons
78 79 80 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 78 def darken_color(, 0.1) end |
#primary_button_active_border_color ⇒ Object
The color for the border of active “primary” buttons
83 84 85 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 83 def darken_color(, 0.12) end |
#primary_button_background_color ⇒ Object
The background color for “primary” buttons
58 59 60 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 58 def block_for('primary_button_background_color', '#286090') end |
#primary_button_border_color ⇒ Object
The border color for “primary” buttons
63 64 65 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 63 def @primary_button_border ||= darken_color(, 0.05) end |
#primary_button_focus_background_color ⇒ Object
The color for the background of focused “primary” buttons
88 89 90 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 88 def darken_color(, 0.1) end |
#primary_button_focus_border_color ⇒ Object
The color for the border of focused “primary” buttons
93 94 95 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 93 def darken_color(, 0.25) end |
#primary_button_hover_background_color ⇒ Object
The mouse over color for “primary” buttons
68 69 70 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 68 def darken_color(, 0.1) end |
#primary_button_hover_border_color ⇒ Object
The mouse over color for the border of “primary” buttons
73 74 75 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 73 def darken_color(, 0.12) end |
#to_key ⇒ Object
Required to back a form
28 29 30 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 28 def to_key [] end |
#update! ⇒ Object
Persist the form values
98 99 100 101 102 |
# File 'app/forms/hyrax/forms/admin/appearance.rb', line 98 def update! self.class.color_params.each do |field| update_block(field, attributes[field]) if attributes[field] end end |