Module: Smurf::StyleguideHelper

Defined in:
app/helpers/smurf/styleguide_helper.rb

Instance Method Summary collapse

Instance Method Details

#foreground_color(background_color) ⇒ Object

returns well readable, high-contrast foreground color (“black” or “white”) based on passed background_color



7
8
9
10
11
12
# File 'app/helpers/smurf/styleguide_helper.rb', line 7

def foreground_color(background_color)
  if color = Smurf::ColorVariableParser.parse_color(background_color)
    return "black"  if color.brightness > 0.5
  end
  return "white"
end