Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Created April 11, 2023 00:04
Show Gist options
  • Save LayZeeDK/87d7046f2721bd250b08c9676da997a3 to your computer and use it in GitHub Desktop.
Save LayZeeDK/87d7046f2721bd250b08c9676da997a3 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
/// Scales a color to be darker if it's light, or lighter if it's dark. Use this function to tint a color appropriate to its lightness.
///
/// @param {Color} $color - Color to scale.
/// @param {Percentage} $scale [5%] - Amount to scale up or down.
/// @param {Percentage} $threshold [40%] - Threshold of lightness to check against.
///
/// @returns {Color} A scaled color.
@function smart-scale($color, $scale: 5%, $threshold: 40%) {
@if lightness($color) > $threshold {
$scale: -$scale;
}
@return scale-color($color, $lightness: $scale);
}
$primary-color: #1779ba;
p {
color: smart-scale($primary-color);
}
p {
color: #1673b1;
}
{
"sass": {
"compiler": "dart-sass/1.32.12",
"extensions": {},
"syntax": "SCSS",
"outputStyle": "expanded"
},
"autoprefixer": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment