From b8af51e6b45486855bb6d7ba055b8c50b2b3dca2 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 29 Sep 2023 12:56:24 -0400 Subject: [PATCH] Make appearance constants overrideable This allows for the knapsack to override the constants by defining and using a method rather than a constant in the look-ups. --- app/forms/hyrax/forms/admin/appearance.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/forms/hyrax/forms/admin/appearance.rb b/app/forms/hyrax/forms/admin/appearance.rb index 7f20affae..ec64d6bb3 100644 --- a/app/forms/hyrax/forms/admin/appearance.rb +++ b/app/forms/hyrax/forms/admin/appearance.rb @@ -42,8 +42,6 @@ class Appearance 'facet_panel_text_color' => '#333333' }.freeze - DEFAULT_VALUES = DEFAULT_FONTS.merge(DEFAULT_COLORS).freeze - # @param [Hash] attributes the list of parameters from the form def initialize(attributes = {}) @attributes = attributes @@ -430,8 +428,12 @@ def convert_to_rgba(hex_color, alpha = 0.5) "rgba(#{rgb[0]}, #{rgb[1]}, #{rgb[2]}, #{alpha})" end + def default_values + @default_values ||= DEFAULT_FONTS.merge(DEFAULT_COLORS) + end + def block_for(name, dynamic_default = nil) - ContentBlock.block_for(name: name, fallback_value: DEFAULT_VALUES[name] || dynamic_default) + ContentBlock.block_for(name: name, fallback_value: default_values[name] || dynamic_default) end # Persist a key/value tuple as a ContentBlock