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: 75f341c5e0c5b4c9535001b20cb35fdd452e9f28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// ===================================================================
// contrast color
// ===================================================================

@charset "utf-8";

@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(abs($color-brightness - $light-color-brightness) > abs($color-brightness - $dark-color-brightness), $light, $dark);
	}
}

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