forked from External/greenlight
GRN2-196: Fixed issues that scrutinizer is complaining about (#765)
* Refactored code to improve scrutinizer score * Bug fixes
This commit is contained in:
@ -22,22 +22,20 @@ module Themer
|
||||
# Lightens a color by 40%
|
||||
def color_lighten(color)
|
||||
# Uses the built in Sass Engine to lighten the color
|
||||
|
||||
dummy_scss = "h1 { color: $lighten; }"
|
||||
compiled = SassC::Engine.new("$lighten:lighten(#{color}, 40%);" + dummy_scss, syntax: :scss).render
|
||||
|
||||
string_locater = 'color: '
|
||||
color_start = compiled.index(string_locater) + string_locater.length
|
||||
|
||||
compiled[color_start..color_start + 6]
|
||||
generate_sass("lighten", color, "40%")
|
||||
end
|
||||
|
||||
# Darkens a color by 10%
|
||||
def color_darken(color)
|
||||
# Uses the built in Sass Engine to darken the color
|
||||
generate_sass("darken", color, "10%")
|
||||
end
|
||||
|
||||
dummy_scss = "h1 { color: $darken; }"
|
||||
compiled = SassC::Engine.new("$darken:darken(#{color}, 10%);" + dummy_scss, syntax: :scss).render
|
||||
private
|
||||
|
||||
def generate_sass(action, color, percentage)
|
||||
dummy_scss = "h1 { color: $#{action}; }"
|
||||
compiled = SassC::Engine.new("$#{action}:#{action}(#{color}, #{percentage});" + dummy_scss, syntax: :scss).render
|
||||
|
||||
string_locater = 'color: '
|
||||
color_start = compiled.index(string_locater) + string_locater.length
|
||||
|
Reference in New Issue
Block a user