Skip to content

Instantly share code, notes, and snippets.

@Mativve
Created January 17, 2024 15:02
Show Gist options
  • Save Mativve/f613b8a01f06fa451e0b95103a9907e1 to your computer and use it in GitHub Desktop.
Save Mativve/f613b8a01f06fa451e0b95103a9907e1 to your computer and use it in GitHub Desktop.
Scrim Gradient with opacity
@mixin scrimGradient($startColor: $color-black, $direction: 'to bottom') {
$scrimCoordinates: (0: 1,
19: 0.738,
34: 0.541,
47: 0.382,
56.5: 0.278,
65: 0.194,
73: 0.126,
80.2: 0.075,
86.1: 0.042,
91: 0.021,
95.2: 0.008,
98.2: 0.002,
100: 0);
$hue: hue($startColor);
$saturation: saturation($startColor);
$lightness: lightness($startColor);
$opacity: alpha($startColor);
$stops: ();
@each $colorStop,
$alphaValue in $scrimCoordinates {
$stop: hsla($hue, $saturation, $lightness, ($opacity * $alphaValue)) percentage(math.div($colorStop, 100));
$stops: append($stops, $stop, comma);
}
background: linear-gradient(unquote($direction), $stops);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment