Skip to main content
summaryrefslogtreecommitdiffstats
blob: b0c78c7029fd3f6003dc495dd12a8e254b699c62 (plain) (blame)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
////
/// @group components/functions
////

/* light, strong, medium */


/// Calculates a contrasting color relative to the passed parameters.
/// @param {number} $strength
/// @param {hex} $color
/// @param {bool} $desaturate
@function get_contrast ($strength, $color, $desaturate: true) {
	$new-color: $color;
    $new-color: darken($color, $strength);
    $strength-offset: 50; //in case of unexpected bright spots in dark themes

	@if lightness($new-color) <= 5 {
		
		@if $strength > $strength-offset {
			$new-color: darken($color, $strength - $strength-offset); 
			//@warn "doppeldunkel #{$new-color}-";
			}
		@else {			 
			$new-color: lighten($color, $strength); 
			} 
		}

	 @else if lightness($new-color) >= 95 {
	 	$new-color: darken($color, $strength);
	 	}			 

	
	@if $desaturate == true {
		$new-color: desaturate($new-color, 100%);
		}
	@return $new-color;	
	}
	

/// Mixes two colors.
/// @todo seem's useless. Could just call built-in "mix" function.
@function get_color_mix ($color, $mix, $strength) { 
	$new-color: mix($color, $mix, $strength); 
	@return $new-color;
	} 

/// Remove the unit of a length
/// @param {Number} $number - Number to remove unit from
/// @return {Number} - Unitless number
@function strip_unit($number) {
  @if type-of($number) == 'number' and not unitless($number) {
    @return $number / ($number * 0 + 1);
  }
  @return $number;
}


/// Tries to return an even number. 
/// Unfortunately, sass modulo never returns fractions, so this is a bit cumbersome.
@function make_even($number) {
	
/* 	TODO: */
/* 	v-layout-spacing muss ne gerade zahl sein, rest aber eigentlich "nur" auf ne glatte zahl gerundet.  */
/* 	genau unterscheiden, wo was gebraucht wird, sonst basst nix!  */
	
	/* make sure units are correct */
	$even-number: $number + 0px;
	
/* 	$number: strip_unit($number); */
	$num-ceil: ceil($number);
	$num-floor: floor($number);
	
	@if $num-ceil % 2 == 0px {
		$t1: $num-ceil % 2;
		$even-number: $num-ceil;
		} 
	@else if $num-floor % 2 == 0px {
		$t2: $num-ceil % 2;
		$even-number: $num-floor;
		}
	@else { /*assume that number is an odd integer - this might not go well*/
		$even-number: $number + 1px;	
		}
		
/* Line below shows up as exception; use to check values...	 */
/* 	@return ($even-number,$num-ceil, $num-floor, $t1, $t2) ; */
	 
	 
	@return $even-number;
	
	 }


/*
 * Luminance Formula
 * Y = 0.2126 R + 0.7152 G + 0.0722 B
 83	96	122
	
	@function is-dark-color($color) { 
  $luminance: color-luminance($color);
  @if $luminance < $v-luminance-threshold or (saturation($color) > 80% and ($luminance < $v-luminance-threshold + 20)) {
    @return true;
  } @else {
    @return false;
  }
 } */
 

Back to the top