Skip to content

Commit

Permalink
Make appearance constants overrideable
Browse files Browse the repository at this point in the history
This allows for the knapsack to override the constants by defining and
using a method rather than a constant in the look-ups.
  • Loading branch information
laritakr committed Sep 29, 2023
1 parent 7740cfd commit b8af51e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/forms/hyrax/forms/admin/appearance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b8af51e

Please sign in to comment.