Welcome to mirror list, hosted at ThFree Co, Russian Federation.

_contrast-color.scss « function « scss « src - github.com/thingsym/hugo-theme-techdoc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 685d0d52b3c446a25c246abf02fa6728c89dc4cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@charset "utf-8";

// Built-In Modules
@use 'sass:math';
@use 'sass:color';

// ===================================================================
// contrast color
// ===================================================================

@function contrast-color($color: null, $dark: #000, $light: #fff) {
	@if $color == null {
		@return null;
	}
	@else {
		$color-brightness: brightness($color);
		$light-color-brightness: brightness($light);
		$dark-color-brightness: brightness($dark);

		@return if(math.abs($color-brightness - $light-color-brightness) > math.abs($color-brightness - $dark-color-brightness), $light, $dark);
	}
}

@function brightness($color: null) {
	@return math.div((color.red($color) * 299) + (color.green($color) * 587) + (color.blue($color) * 114), 1000);
}