I have used many variables in my sass file for background color, font-size
I think you might be trying to solve the wrong problem. Managing the variables in javascript will just move the problem from point A to point B
What I imagine you're doing and its a natural mistake many people make:
$bg-color: rgb( 255, 0, 0 );
$bg-color-alt: rgb( 128, 0, 0 );
$link-color: rgb( 255, 0, 0 );
$link-color-hover: rgb( 128, 0, 0 );
You define your colors based on how you're using them within the design
What you should be doing is defining your palette and having the colors be relative within that.
$red-100: rgb( 255, 0, 0 ); // #f00
$red-200: rgb( from $red-100 calc( r / 2 ) g b ); // #800000
$red-300: rgb( from $red-200 calc( r / 2 ) g b ); // #400000
- prevents you from redundant definition of values because of how something is used (i.e. red is defined once, regardless of where you're using it)
- it saves you from meaningless variable names (i.e.
red, darkRed, darkerRed, darkestRed, darkerThanDarkestRed)
- makes it easier for other people to jump into your work (no one has to guess what you meant by
darkerRed)
- saves you from making a mistake with your palette since the colors are all relative
This methodology obviously doesn't only apply to colors, but fonts too.