@progress/kendo-theme-core 6.1.1-dev.3 → 6.1.1-dev.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.scss +868 -63
- package/dist/meta/sassdoc-data.json +6814 -0
- package/dist/meta/sassdoc-raw-data.json +6754 -0
- package/dist/meta/variables.json +78 -0
- package/dist/meta/variables.scss +10 -0
- package/package.json +2 -2
- package/scss/color-system/_palettes.scss +69 -0
- package/scss/color-system/_variables.scss +37 -0
- package/scss/functions/_color-contrast.import.scss +50 -11
- package/scss/functions/_color-manipulation.import.scss +59 -2
- package/scss/functions/_color.import.scss +105 -0
- package/scss/functions/_escape-string.import.scss +8 -1
- package/scss/functions/_lang.import.scss +11 -0
- package/scss/functions/_list.import.scss +80 -0
- package/scss/functions/_map.import.scss +48 -0
- package/scss/functions/_math.import.scss +131 -9
- package/scss/functions/_meta.import.scss +162 -0
- package/scss/functions/_string.import.scss +69 -1
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/// Returns the value of a variable if it is not null,
|
|
2
|
+
/// otherwise returns the fallback value.
|
|
3
|
+
/// @param {Any} $var - The variable to check.
|
|
4
|
+
/// @param {Any} $fallback - The fallback value.
|
|
5
|
+
/// @return {Any} - The value of the variable or the fallback value.
|
|
6
|
+
///
|
|
7
|
+
/// @example scss - Usage
|
|
8
|
+
/// $foo: null;
|
|
9
|
+
/// @debug k-if-var( $foo, "bar" ); // => "bar"
|
|
10
|
+
/// $foo: "baz";
|
|
11
|
+
/// @debug k-if-var( $foo, "bar" ); // => "baz"
|
|
1
12
|
@function k-if-var( $var, $fallback ) {
|
|
2
13
|
@return if( $var != null, $var, $fallback );
|
|
3
14
|
}
|
|
@@ -1,31 +1,90 @@
|
|
|
1
|
+
/// Returns a copy of `$list` with `$val` appended to the end.
|
|
2
|
+
/// @param {List} $list - The list to process.
|
|
3
|
+
/// @param {Any} $val - The value to append to `$list`.
|
|
4
|
+
/// @param {String} $separator - The separator to use between `$list` and `$val`.
|
|
5
|
+
/// @return {List} - A copy of `$list` with `$val` appended to the end.
|
|
6
|
+
///
|
|
7
|
+
/// @example scss - Usage
|
|
8
|
+
/// @debug k-list-append( ( "foo", "bar" ), "baz" ); // => "foo, bar, baz"
|
|
1
9
|
@function k-list-append( $list, $val, $separator: auto ) {
|
|
2
10
|
@return append( $list, $val, $separator );
|
|
3
11
|
}
|
|
4
12
|
|
|
13
|
+
/// Checks whether `$list` contains `$value`.
|
|
14
|
+
/// @param {List} $list - The list to check.
|
|
15
|
+
/// @param {Any} $value - The value to check for.
|
|
16
|
+
/// @return {Boolean} - Whether `$list` contains `$value`.
|
|
17
|
+
///
|
|
18
|
+
/// @example scss - Usage
|
|
19
|
+
/// @debug k-list-includes( ( "foo", "bar" ), "foo" ); // => true
|
|
20
|
+
/// @debug k-list-includes( ( "foo", "bar" ), "baz" ); // => false
|
|
5
21
|
@function k-list-includes( $list, $value ) {
|
|
6
22
|
@return k-list-index( $list, $value ) != null;
|
|
7
23
|
}
|
|
8
24
|
|
|
25
|
+
/// Returns the index of `$value` in `$list`.
|
|
26
|
+
/// @param {List} $list - The list to check.
|
|
27
|
+
/// @param {Any} $value - The value to check for.
|
|
28
|
+
/// @return {Number} - The index of `$value` in `$list`.
|
|
29
|
+
///
|
|
30
|
+
/// @example scss - Usage
|
|
31
|
+
/// @debug k-list-index( ( "foo", "bar" ), "foo" ); // => 1
|
|
9
32
|
@function k-list-index( $list, $value ) {
|
|
10
33
|
@return index( $list, $value );
|
|
11
34
|
}
|
|
12
35
|
|
|
36
|
+
/// Returns whether `$list` is bracketed.
|
|
37
|
+
/// @param {List} $list - The list to check.
|
|
38
|
+
/// @return {Boolean} - Whether `$list` is bracketed.
|
|
39
|
+
///
|
|
40
|
+
/// @example scss - Usage
|
|
41
|
+
/// @debug k-list-is-bracketed( ( "foo", "bar" ) ); // => false
|
|
42
|
+
/// @debug k-list-is-bracketed( [ "foo", "bar" ] ); // => true
|
|
13
43
|
@function k-list-is-bracketed( $list ) {
|
|
14
44
|
@return is-bracketed( $list );
|
|
15
45
|
}
|
|
16
46
|
|
|
47
|
+
/// Joins two lists together.
|
|
48
|
+
/// @param {List} $list1 - The first list to join.
|
|
49
|
+
/// @param {List} $list2 - The second list to join.
|
|
50
|
+
/// @param {String} $separator - The separator to use between `$list1` and `$list2`.
|
|
51
|
+
/// @param {Boolean} $bracketed - Whether the result should be bracketed.
|
|
52
|
+
/// @return {List} - The joined list.
|
|
53
|
+
///
|
|
54
|
+
/// @example scss - Usage
|
|
55
|
+
/// @debug k-list-join( ( "foo", "bar" ), ( "baz", "qux" ) ); // => "foo, bar, baz, qux"
|
|
56
|
+
/// @debug k-list-join( ( "foo", "bar" ), ( "baz", "qux" ), " " ); // => "foo bar baz qux"
|
|
17
57
|
@function k-list-join( $list1, $list2, $separator: auto, $bracketed: auto ) {
|
|
18
58
|
@return join( $list1, $list2, $separator, $bracketed );
|
|
19
59
|
}
|
|
20
60
|
|
|
61
|
+
/// Returns the length of `$list`.
|
|
62
|
+
/// @param {List} $list - The list to check.
|
|
63
|
+
/// @return {Number} - The length of `$list`.
|
|
64
|
+
///
|
|
65
|
+
/// @example scss - Usage
|
|
66
|
+
/// @debug k-list-length( ( "foo", "bar" ) ); // => 2
|
|
21
67
|
@function k-list-length( $list ) {
|
|
22
68
|
@return length( $list );
|
|
23
69
|
}
|
|
24
70
|
|
|
71
|
+
/// Returns the nth item in `$list`.
|
|
72
|
+
/// @param {List} $list - The list to check.
|
|
73
|
+
/// @param {Number} $n - The index of the item to return.
|
|
74
|
+
/// @return {Any} - The nth item in `$list`.
|
|
75
|
+
///
|
|
76
|
+
/// @example scss - Usage
|
|
77
|
+
/// @debug k-list-nth( ( "foo", "bar" ), 1 ); // => "foo"
|
|
25
78
|
@function k-list-nth( $list, $n ) {
|
|
26
79
|
@return nth( $list, $n );
|
|
27
80
|
}
|
|
28
81
|
|
|
82
|
+
/// Reverse the order of items in `$list`.
|
|
83
|
+
/// @param {List} $list - The list to reverse.
|
|
84
|
+
/// @return {List} - The reversed list.
|
|
85
|
+
///
|
|
86
|
+
/// @example scss - Usage
|
|
87
|
+
/// @debug k-list-reverse( ( "foo", "bar" ) ); // => "bar, foo"
|
|
29
88
|
@function k-list-reverse( $list: null ) {
|
|
30
89
|
$result: ();
|
|
31
90
|
|
|
@@ -44,14 +103,35 @@
|
|
|
44
103
|
@return $result;
|
|
45
104
|
}
|
|
46
105
|
|
|
106
|
+
/// Returns the separator of `$list`.
|
|
107
|
+
/// @param {List} $list - The list to check.
|
|
108
|
+
/// @return {String} - The separator of `$list`.
|
|
109
|
+
///
|
|
110
|
+
/// @example scss - Usage
|
|
111
|
+
/// @debug k-list-separator( ( "foo", "bar" ) ); // => ","
|
|
47
112
|
@function k-list-separator( $list ) {
|
|
48
113
|
@return list-separator( $list );
|
|
49
114
|
}
|
|
50
115
|
|
|
116
|
+
/// Returns a copy of `$list` with `$val` inserted at `$n`.
|
|
117
|
+
/// @param {List} $list - The list to process.
|
|
118
|
+
/// @param {Number} $n - The index at which to insert `$val`.
|
|
119
|
+
/// @param {Any} $val - The value to insert.
|
|
120
|
+
/// @return {List} - A copy of `$list` with `$val` inserted at `$n`.
|
|
121
|
+
///
|
|
122
|
+
/// @example scss - Usage
|
|
123
|
+
/// @debug k-list-set-nth( ( "foo", "bar" ), 1, "baz" ); // => "baz, bar"
|
|
51
124
|
@function k-list-set-nth( $list, $n, $value ) {
|
|
52
125
|
@return set-nth( $list, $n, $value );
|
|
53
126
|
}
|
|
54
127
|
|
|
128
|
+
/// Combines two lists into a single list of two-item lists.
|
|
129
|
+
/// @param {List} $list1 - The first list to combine.
|
|
130
|
+
/// @param {List} $list2 - The second list to combine.
|
|
131
|
+
/// @return {List} - A list of two-item lists.
|
|
132
|
+
///
|
|
133
|
+
/// @example scss - Usage
|
|
134
|
+
/// @debug k-list-zip( ( "foo", "bar" ), ( "baz", "qux" ) ); // => ((foo, baz), (bar, qux))
|
|
55
135
|
@function k-list-zip( $lists... ) {
|
|
56
136
|
@return zip( $lists... );
|
|
57
137
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/// Returns the value at `$key` in `$map`.
|
|
2
|
+
/// @param {Map} $map - The map to get the value from.
|
|
3
|
+
/// @param {Any} $key - The key to get the value for.
|
|
4
|
+
///
|
|
5
|
+
/// @example scss - Usage
|
|
6
|
+
/// @debug k-map-get( ( "foo": "bar" ), "foo" ); // => "bar"
|
|
1
7
|
@function k-map-get( $map, $keys... ) {
|
|
2
8
|
@each $key in $keys {
|
|
3
9
|
$map: map-get( $map, $key );
|
|
@@ -5,14 +11,35 @@
|
|
|
5
11
|
@return $map;
|
|
6
12
|
}
|
|
7
13
|
|
|
14
|
+
/// Returns whether `$map` has a value at `$key`.
|
|
15
|
+
/// @param {Map} $map - The map to check.
|
|
16
|
+
/// @param {Any} $key - The key to check.
|
|
17
|
+
/// @return {Boolean} - Whether `$map` has a value at `$key`.
|
|
18
|
+
///
|
|
19
|
+
/// @example scss - Usage
|
|
20
|
+
/// @debug k-map-has( ( "foo": "bar" ), "foo" ); // => true
|
|
21
|
+
/// @debug k-map-has( ( "foo": "bar" ), "bar" ); // => false
|
|
8
22
|
@function k-map-has-key( $map, $key ) {
|
|
9
23
|
@return map-has-key( $map, $key );
|
|
10
24
|
}
|
|
11
25
|
|
|
26
|
+
/// Returns a comma separated list of the keys in `$map`.
|
|
27
|
+
/// @param {Map} $map - The map to get the keys from.
|
|
28
|
+
/// @return {List} - A comma separated list of the keys in `$map`.
|
|
29
|
+
///
|
|
30
|
+
/// @example scss - Usage
|
|
31
|
+
/// @debug k-map-keys( ( "foo": "bar", "baz": "qux" ) ); // => "foo, baz"
|
|
12
32
|
@function k-map-keys( $map ) {
|
|
13
33
|
@return map-keys( $map );
|
|
14
34
|
}
|
|
15
35
|
|
|
36
|
+
/// Returns a map with the keys and values from `$map` and `$args`.
|
|
37
|
+
/// @param {Map} $map - The map to merge.
|
|
38
|
+
/// @param {Map} $args - The map to merge into `$map`.
|
|
39
|
+
/// @return {Map} - A map with the keys and values from `$map` and `$args`.
|
|
40
|
+
///
|
|
41
|
+
/// @example scss - Usage
|
|
42
|
+
/// @debug k-map-merge( ( "foo": "bar" ), ( "baz": "qux" ) ); // => ( "foo": "bar", "baz": "qux" )
|
|
16
43
|
@function k-map-merge( $map, $args... ) {
|
|
17
44
|
@each $arg in $args {
|
|
18
45
|
$map: map-merge( $map, $arg );
|
|
@@ -20,14 +47,35 @@
|
|
|
20
47
|
@return $map;
|
|
21
48
|
}
|
|
22
49
|
|
|
50
|
+
/// Returns a map with the keys and values from `$map` except for `$keys`.
|
|
51
|
+
/// @param {Map} $map - The map to remove keys from.
|
|
52
|
+
/// @param {Any} $keys - The keys to remove from `$map`.
|
|
53
|
+
/// @return {Map} - A map with the keys and values from `$map` except for `$keys`.
|
|
54
|
+
///
|
|
55
|
+
/// @example scss - Usage
|
|
56
|
+
/// @debug k-map-remove( ( "foo": "bar", "baz": "qux" ), "foo" ); // => ( "baz": "qux" )
|
|
23
57
|
@function k-map-remove( $map, $keys... ) {
|
|
24
58
|
@return map-remove( $map, $keys... );
|
|
25
59
|
}
|
|
26
60
|
|
|
61
|
+
/// Sets a single key and value in `$map`.
|
|
62
|
+
/// @param {Map} $map - The map to set the value in.
|
|
63
|
+
/// @param {Any} $key - The key to set the value for.
|
|
64
|
+
/// @param {Any} $value - The value to set.
|
|
65
|
+
/// @return {Map} - A map with the key and value set.
|
|
66
|
+
///
|
|
67
|
+
/// @example scss - Usage
|
|
68
|
+
/// @debug k-map-set( ( "foo": "bar" ), "baz", "qux" ); // => ( "foo": "bar", "baz": "qux" )
|
|
27
69
|
@function k-map-set( $map, $key, $value ) {
|
|
28
70
|
@return k-map-merge( $map, ( $key: $value ) );
|
|
29
71
|
}
|
|
30
72
|
|
|
73
|
+
/// Returns a comma separated list of the values in `$map`.
|
|
74
|
+
/// @param {Map} $map - The map to get the values from.
|
|
75
|
+
/// @return {List} - A comma separated list of the values in `$map`.
|
|
76
|
+
///
|
|
77
|
+
/// @example scss - Usage
|
|
78
|
+
/// @debug k-map-values( ( "foo": "bar", "baz": "qux" ) ); // => "bar, qux"
|
|
31
79
|
@function k-map-values( $map ) {
|
|
32
80
|
@return map-values( $map );
|
|
33
81
|
}
|
|
@@ -1,47 +1,147 @@
|
|
|
1
|
+
/// Returns the absolute value of a number.
|
|
2
|
+
/// @param {Number} $number - The number to get the absolute value of.
|
|
3
|
+
/// @return {Number} - The absolute value of `$number`.
|
|
4
|
+
///
|
|
5
|
+
/// @example scss - Usage
|
|
6
|
+
/// @debug k-math-abs( -10 ); // => 10
|
|
1
7
|
@function k-math-abs( $number ) {
|
|
2
8
|
@return abs( $number );
|
|
3
9
|
}
|
|
4
10
|
|
|
11
|
+
/// Returns the smallest integer greater than or equal to a number.
|
|
12
|
+
/// @param {Number} $number - The number to get the ceiling of.
|
|
13
|
+
/// @return {Number} - The ceiling of `$number`.
|
|
14
|
+
///
|
|
15
|
+
/// @example scss - Usage
|
|
16
|
+
/// @debug k-math-ceil( 10.1 ); // => 11
|
|
5
17
|
@function k-math-ceil( $number ) {
|
|
6
18
|
@return ceil( $number );
|
|
7
19
|
}
|
|
8
20
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
21
|
+
/// Returns the largest integer less than or equal to a number.
|
|
22
|
+
/// @param {Number} $number - The number to get the floor of.
|
|
23
|
+
/// @return {Number} - The floor of `$number`.
|
|
24
|
+
///
|
|
25
|
+
/// @example scss - Usage
|
|
26
|
+
/// @debug k-math-floor( 10.9 ); // => 10
|
|
27
|
+
@function k-math-floor( $number ) {
|
|
28
|
+
@return floor( $number );
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Restricts `$number` to the range between `$min` and `$max`. If `$number` is
|
|
32
|
+
/// less than `$min`, `$min` is returned. If `$number` is greater than `$max`,
|
|
33
|
+
/// `$max` is returned. Otherwise, `$number` is returned.
|
|
34
|
+
/// @param {Number} $number - The number to clamp.
|
|
35
|
+
/// @param {Number} $min - The minimum value.
|
|
36
|
+
/// @param {Number} $max - The maximum value.
|
|
37
|
+
/// @return {Number} - The clamped number.
|
|
38
|
+
///
|
|
39
|
+
/// @example scss - Usage
|
|
40
|
+
/// @debug k-math-clamp( 10, 0, 5 ); // => 5
|
|
41
|
+
@function k-math-clamp( $number, $min, $max ) {
|
|
42
|
+
@return k-math-max( $min, k-math-min( $max, $number ) );
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/// Returns whether two numbers have compatible units.
|
|
46
|
+
/// @param {Number} $a - The first number.
|
|
47
|
+
/// @param {Number} $b - The second number.
|
|
48
|
+
/// @return {Boolean} - Whether the numbers have compatible units.
|
|
49
|
+
///
|
|
50
|
+
/// @example scss - Usage
|
|
51
|
+
/// @debug k-math-compatible( 10px, 10px ); // => true
|
|
52
|
+
/// @debug k-math-compatible( 10px, 10em ); // => false
|
|
13
53
|
@function k-math-compatible( $a, $b ) {
|
|
14
54
|
@return comparable( $a, $b );
|
|
15
55
|
}
|
|
16
56
|
|
|
57
|
+
/// Returns the quotient of two numbers.
|
|
58
|
+
/// @param {Number} $a - The dividend.
|
|
59
|
+
/// @param {Number} $b - The divisor.
|
|
60
|
+
/// @return {Number} - The quotient of `$a` and `$b`.
|
|
61
|
+
///
|
|
62
|
+
/// @example scss - Usage
|
|
63
|
+
/// @debug k-math-div( 10, 2 ); // => 5
|
|
64
|
+
/// @debug k-math-div( 10px, 2 ); // => 5px
|
|
17
65
|
@function k-math-div( $a, $b ) {
|
|
18
66
|
@return ( $a / $b );
|
|
19
67
|
}
|
|
20
68
|
|
|
69
|
+
/// Returns whether `$number` has no units.
|
|
70
|
+
/// @param {Number} $number - The number to check.
|
|
71
|
+
/// @return {Boolean} - Whether `$number` has no units.
|
|
72
|
+
///
|
|
73
|
+
/// @example scss - Usage
|
|
74
|
+
/// @debug k-math-is-unitless( 10 ); // => true
|
|
75
|
+
/// @debug k-math-is-unitless( 10px ); // => false
|
|
21
76
|
@function k-math-is-unitless( $number ) {
|
|
22
77
|
@return unitless( $number );
|
|
23
78
|
}
|
|
24
79
|
|
|
80
|
+
/// Returns the larger of two numbers.
|
|
81
|
+
/// @param {Number} $a - The first number.
|
|
82
|
+
/// @param {Number} $b - The second number.
|
|
83
|
+
/// @return {Number} - The larger of `$a` and `$b`.
|
|
84
|
+
///
|
|
85
|
+
/// @example scss - Usage
|
|
86
|
+
/// @debug k-math-max( 10, 20 ); // => 20
|
|
87
|
+
/// @debug k-math-max( 10px, 20px ); // => 20px
|
|
25
88
|
@function k-math-max( $a, $b ) {
|
|
26
89
|
@return max( $a, $b );
|
|
27
90
|
}
|
|
28
91
|
|
|
92
|
+
/// Returns the smaller of two numbers.
|
|
93
|
+
/// @param {Number} $a - The first number.
|
|
94
|
+
/// @param {Number} $b - The second number.
|
|
95
|
+
/// @return {Number} - The smaller of `$a` and `$b`.
|
|
96
|
+
///
|
|
97
|
+
/// @example scss - Usage
|
|
98
|
+
/// @debug k-math-min( 10, 20 ); // => 10
|
|
99
|
+
/// @debug k-math-min( 10px, 20px ); // => 10px
|
|
29
100
|
@function k-math-min( $a, $b ) {
|
|
30
101
|
@return min( $a, $b );
|
|
31
102
|
}
|
|
32
103
|
|
|
104
|
+
/// Returns the remainder of two numbers.
|
|
105
|
+
/// @param {Number} $a - The dividend.
|
|
106
|
+
/// @param {Number} $b - The divisor.
|
|
107
|
+
/// @return {Number} - The remainder of `$a` and `$b`.
|
|
108
|
+
///
|
|
109
|
+
/// @example scss - Usage
|
|
110
|
+
/// @debug k-math-mod( 10, 3 ); // => 1
|
|
111
|
+
/// @debug k-math-mod( 10px, 3 ); // => 1px
|
|
33
112
|
@function k-math-mod( $a, $b ) {
|
|
34
113
|
@return ( $a % $b );
|
|
35
114
|
}
|
|
36
115
|
|
|
116
|
+
/// Returns the product of two numbers.
|
|
117
|
+
/// @param {Number} $a - The first number.
|
|
118
|
+
/// @param {Number} $b - The second number.
|
|
119
|
+
/// @return {Number} - The product of `$a` and `$b`.
|
|
120
|
+
///
|
|
121
|
+
/// @example scss - Usage
|
|
122
|
+
/// @debug k-math-mul( 10, 2 ); // => 20
|
|
123
|
+
/// @debug k-math-mul( 10px, 2 ); // => 20px
|
|
37
124
|
@function k-math-mul( $a, $b ) {
|
|
38
125
|
@return ( $a * $b );
|
|
39
126
|
}
|
|
40
127
|
|
|
128
|
+
/// Converts a unitless number to a percentage.
|
|
129
|
+
/// @param {Number} $number - The number to convert.
|
|
130
|
+
/// @return {Number} - The percentage.
|
|
131
|
+
///
|
|
132
|
+
/// @example scss - Usage
|
|
133
|
+
/// @debug k-math-percentage( 0.5 ); // => 50%
|
|
41
134
|
@function k-math-percentage( $number ) {
|
|
42
|
-
@return ( $number
|
|
135
|
+
@return percentage( $number );
|
|
43
136
|
}
|
|
44
137
|
|
|
138
|
+
/// Returns the result of raising `$x` to the power of `$n`.
|
|
139
|
+
/// @param {Number} $x - The base.
|
|
140
|
+
/// @param {Number} $n - The exponent.
|
|
141
|
+
/// @return {Number} - The result of raising `$x` to the power of `$n`.
|
|
142
|
+
///
|
|
143
|
+
/// @example scss - Usage
|
|
144
|
+
/// @debug k-math-pow( 2, 3 ); // => 8
|
|
45
145
|
@function k-math-pow( $x, $n ) {
|
|
46
146
|
$ret: 1;
|
|
47
147
|
|
|
@@ -63,10 +163,12 @@
|
|
|
63
163
|
|
|
64
164
|
}
|
|
65
165
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
166
|
+
/// Returns a random number between 0 and 1.
|
|
167
|
+
/// @param {Number} $limit - The upper limit of the random number.
|
|
168
|
+
/// @return {Number} - A random number between 0 and 1.
|
|
169
|
+
///
|
|
170
|
+
/// @example scss - Usage
|
|
171
|
+
/// @debug k-math-random(); // => 0.123456789
|
|
70
172
|
@function k-math-random( $limit: null ) {
|
|
71
173
|
@if ( $limit == null ) {
|
|
72
174
|
@return random();
|
|
@@ -75,6 +177,14 @@
|
|
|
75
177
|
@return random( $limit );
|
|
76
178
|
}
|
|
77
179
|
|
|
180
|
+
/// Returns the result of rounding `$number` to the nearest integer
|
|
181
|
+
/// using the specified `$precision`.
|
|
182
|
+
/// @param {Number} $number - The number to round.
|
|
183
|
+
/// @param {Number} $precision - The number of decimal places to round to.
|
|
184
|
+
/// @return {Number} - The rounded number.
|
|
185
|
+
///
|
|
186
|
+
/// @example scss - Usage
|
|
187
|
+
/// @debug k-math-round( 10.123456789, 3 ); // => 10.123
|
|
78
188
|
@function k-math-round( $number, $precision: 0 ) {
|
|
79
189
|
|
|
80
190
|
@if ( $precision == 0 ) {
|
|
@@ -86,10 +196,22 @@
|
|
|
86
196
|
@return k-math-div( round( $number * $pow ), $pow );
|
|
87
197
|
}
|
|
88
198
|
|
|
199
|
+
/// Returns a string representation of `$number`'s unit.
|
|
200
|
+
/// @param {Number} $number - The number to get the unit of.
|
|
201
|
+
/// @return {String} - The unit of `$number`.
|
|
202
|
+
///
|
|
203
|
+
/// @example scss - Usage
|
|
204
|
+
/// @debug k-math-unit( 10px ); // => px
|
|
89
205
|
@function k-math-unit( $number ) {
|
|
90
206
|
@return unit( $number );
|
|
91
207
|
}
|
|
92
208
|
|
|
209
|
+
/// Remove the unit from a number.
|
|
210
|
+
/// @param {Number} $number - The number to remove the unit from.
|
|
211
|
+
/// @return {Number} - The unitless number.
|
|
212
|
+
///
|
|
213
|
+
/// @example scss - Usage
|
|
214
|
+
/// @debug k-math-strip-unit( 10px ); // => 10
|
|
93
215
|
@function k-math-strip-unit($number) {
|
|
94
216
|
@if ( k-meta-type-of( $number ) == "number" ) and not k-math-is-unitless( $number ) {
|
|
95
217
|
@return k-math-div( $number, 1 * k-math-unit( $number) );
|
|
@@ -1,77 +1,239 @@
|
|
|
1
1
|
// Adapted from https://css-tricks.com/snippets/sass/advanced-type-checking/
|
|
2
2
|
|
|
3
|
+
/// A wrapper around the `call()` function.
|
|
4
|
+
/// Calls the function `$function` with the arguments `$args`.
|
|
5
|
+
/// @param {Function} $function - The function to call.
|
|
6
|
+
/// @param {List} $args - The arguments to pass to `$function`.
|
|
7
|
+
/// @return {Any} - The result of calling `$function` with `$args`.
|
|
8
|
+
///
|
|
9
|
+
/// @example scss - Usage
|
|
10
|
+
/// @debug k-meta-call( k-meta-get-function( "k-string-replace" ), "foo bar", "bar", "baz" ); // => "foo baz"
|
|
3
11
|
@function k-meta-call( $function, $args... ) {
|
|
4
12
|
@return call( $function, $args... );
|
|
5
13
|
}
|
|
6
14
|
|
|
15
|
+
/// A wrapper around the `function-exists()` function.
|
|
16
|
+
/// Returns whether a function with the name `$name` exists.
|
|
17
|
+
/// @param {String} $name - The name of the function to check.
|
|
18
|
+
/// @return {Boolean} - Whether a function with the name `$name` exists.
|
|
19
|
+
///
|
|
20
|
+
/// @example scss - Usage
|
|
21
|
+
/// @debug k-meta-function-exists( "k-string-replace" ); // => true
|
|
7
22
|
@function k-meta-function-exists( $name ) {
|
|
8
23
|
@return function-exists( $name );
|
|
9
24
|
}
|
|
10
25
|
|
|
26
|
+
/// A wrapper around the `get-function()` function.
|
|
27
|
+
/// Returns the function with the name `$name`.
|
|
28
|
+
/// @param {String} $name - The name of the function to get.
|
|
29
|
+
/// @param {Boolean} $css - Whether to return the CSS representation of the function.
|
|
30
|
+
/// @param {Module} $module - The module to get the function from.
|
|
31
|
+
/// @return {Function} - The function with the name `$name`.
|
|
32
|
+
///
|
|
33
|
+
/// @example scss - Usage
|
|
34
|
+
/// @debug k-meta-get-function( "k-string-replace" ); // => Function
|
|
11
35
|
@function k-meta-get-function( $name, $args... ) {
|
|
12
36
|
@return get-function( $name, $args... );
|
|
13
37
|
}
|
|
14
38
|
|
|
39
|
+
/// A wrapper around the `inspect()` function.
|
|
40
|
+
/// Returns a string representation of `$value`.
|
|
41
|
+
/// @param {Any} $value - The value to inspect.
|
|
42
|
+
/// @return {String} - A string representation of `$value`.
|
|
43
|
+
///
|
|
44
|
+
/// @example scss - Usage
|
|
45
|
+
/// @debug k-meta-inspect( "foo bar" ); // => "foo bar"
|
|
15
46
|
@function k-meta-inspect( $value ) {
|
|
16
47
|
@return inspect( $value );
|
|
17
48
|
}
|
|
18
49
|
|
|
50
|
+
/// A wrapper around the `keywords()` function.
|
|
51
|
+
/// Returns a map of the keywords in `$args`.
|
|
52
|
+
/// @param {List} $args - The arguments to process.
|
|
53
|
+
/// @return {Map} - A map of the keywords in `$args`.
|
|
54
|
+
///
|
|
55
|
+
/// @example scss - Usage
|
|
56
|
+
/// @debug k-meta-keywords( ( "foo" "bar" "baz" "qux" ) ); // => ( "foo": "bar", "baz": "qux" )
|
|
19
57
|
@function k-meta-keywords( $args ) {
|
|
20
58
|
@return keywords( $args );
|
|
21
59
|
}
|
|
22
60
|
|
|
61
|
+
/// A wrapper around the `type-of()` function.
|
|
62
|
+
/// Returns the type of `$value`.
|
|
63
|
+
/// @param {Any} $value - The value to get the type of.
|
|
64
|
+
/// @return {String} - The type of `$value`.
|
|
65
|
+
///
|
|
66
|
+
/// @example scss - Usage
|
|
67
|
+
/// @debug k-meta-type-of( "foo bar" ); // => "string"
|
|
23
68
|
@function k-meta-type-of( $value ) {
|
|
24
69
|
@return type-of( $value );
|
|
25
70
|
}
|
|
26
71
|
|
|
72
|
+
/// A wrapper around the `variable-exists()` function.
|
|
73
|
+
/// Returns whether a variable with the name `$name` exists.
|
|
74
|
+
/// @param {String} $name - The name of the variable to check.
|
|
75
|
+
/// @return {Boolean} - Whether a variable with the name `$name` exists.
|
|
76
|
+
///
|
|
77
|
+
/// @example scss - Usage
|
|
78
|
+
/// @debug k-meta-variable-exists( "foo" ); // => true
|
|
27
79
|
@function k-meta-variable-exists( $name ) {
|
|
28
80
|
@return variable-exists( $name );
|
|
29
81
|
}
|
|
30
82
|
|
|
83
|
+
/// Checks whether `$value` is a <number> CSS data type.
|
|
84
|
+
/// @param {Any} $value - The value to check.
|
|
85
|
+
/// @return {Boolean} - Whether `$value` is a number.
|
|
86
|
+
///
|
|
87
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/number
|
|
88
|
+
///
|
|
89
|
+
/// @example scss - Usage
|
|
90
|
+
/// @debug k-meta-is-number( 1 ); // => true
|
|
91
|
+
/// @debug k-meta-is-number( "foo" ); // => false
|
|
31
92
|
@function k-meta-is-number( $value ) {
|
|
32
93
|
@return k-meta-type-of( $value ) == "number";
|
|
33
94
|
}
|
|
34
95
|
|
|
96
|
+
/// Checks whether `$value` is a <integer> CSS data type.
|
|
97
|
+
/// @param {Any} $value - The value to check.
|
|
98
|
+
/// @return {Boolean} - Whether `$value` is a integer.
|
|
99
|
+
///
|
|
100
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/integer
|
|
101
|
+
///
|
|
102
|
+
/// @example scss - Usage
|
|
103
|
+
/// @debug k-meta-is-integer( 1 ); // => true
|
|
104
|
+
/// @debug k-meta-is-integer( 1.5 ); // => false
|
|
35
105
|
@function k-meta-is-integer( $value ) {
|
|
36
106
|
@return k-meta-is-number( $value ) and k-math-round( $value ) == $value;
|
|
37
107
|
}
|
|
38
108
|
|
|
109
|
+
/// Checks whether `$value` is a <time> CSS data type.
|
|
110
|
+
/// @param {Any} $value - The value to check.
|
|
111
|
+
/// @return {Boolean} - Whether `$value` is a time.
|
|
112
|
+
///
|
|
113
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/time
|
|
114
|
+
///
|
|
115
|
+
/// @example scss - Usage
|
|
116
|
+
/// @debug k-meta-is-time( 1s ); // => true
|
|
117
|
+
/// @debug k-meta-is-time( 1 ); // => false
|
|
39
118
|
@function k-meta-is-time( $value ) {
|
|
40
119
|
@return k-meta-is-number( $value ) and k-string-index( "ms" "s", k-math-unit( $value ) ) != null;
|
|
41
120
|
}
|
|
42
121
|
|
|
122
|
+
/// Checks whether `$value` is a valid duration period.
|
|
123
|
+
/// @param {Any} $value - The value to check.
|
|
124
|
+
/// @return {Boolean} - Whether `$value` is a duration.
|
|
125
|
+
///
|
|
126
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/time
|
|
127
|
+
///
|
|
128
|
+
/// @example scss - Usage
|
|
129
|
+
/// @debug k-meta-is-duration( 1s ); // => true
|
|
130
|
+
/// @debug k-meta-is-duration( 1 ); // => false
|
|
43
131
|
@function k-meta-is-duration( $value ) {
|
|
44
132
|
@return k-meta-is-time( $value );
|
|
45
133
|
}
|
|
46
134
|
|
|
135
|
+
/// Checks whether `$value` is a <angle> CSS data type.
|
|
136
|
+
/// @param {Any} $value - The value to check.
|
|
137
|
+
/// @return {Boolean} - Whether `$value` is a angle.
|
|
138
|
+
///
|
|
139
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/angle
|
|
140
|
+
///
|
|
141
|
+
/// @example scss - Usage
|
|
142
|
+
/// @debug k-meta-is-angle( 1deg ); // => true
|
|
143
|
+
/// @debug k-meta-is-angle( 1 ); // => false
|
|
47
144
|
@function k-meta-is-angle( $value ) {
|
|
48
145
|
@return k-meta-is-number( $value ) and k-string-index( "deg" "rad" "grad" "turn", k-math-unit( $value ) ) != null;
|
|
49
146
|
}
|
|
50
147
|
|
|
148
|
+
/// Checks whether `$value` is a <frequency> CSS data type.
|
|
149
|
+
/// @param {Any} $value - The value to check.
|
|
150
|
+
/// @return {Boolean} - Whether `$value` is a frequency.
|
|
151
|
+
///
|
|
152
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/frequency
|
|
153
|
+
///
|
|
154
|
+
/// @example scss - Usage
|
|
155
|
+
/// @debug k-meta-is-frequency( 1Hz ); // => true
|
|
156
|
+
/// @debug k-meta-is-frequency( 1 ); // => false
|
|
51
157
|
@function k-meta-is-frequency( $value ) {
|
|
52
158
|
@return k-meta-is-number( $value ) and k-string-index( "Hz" "kHz", k-math-unit( $value ) ) != null;
|
|
53
159
|
}
|
|
54
160
|
|
|
161
|
+
/// Checks whether `$value` is a relative <length> CSS data type.
|
|
162
|
+
/// @param {Any} $value - The value to check.
|
|
163
|
+
/// @return {Boolean} - Whether `$value` is a relative length.
|
|
164
|
+
///
|
|
165
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/length#relative_length_units_based_on_font
|
|
166
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/length#relative_length_units_based_on_viewport
|
|
167
|
+
///
|
|
168
|
+
/// @example scss - Usage
|
|
169
|
+
/// @debug k-meta-is-relative-length( 1em ); // => true
|
|
170
|
+
/// @debug k-meta-is-relative-length( 1ch ); // => true
|
|
171
|
+
/// @debug k-meta-is-relative-length( 1 ); // => false
|
|
55
172
|
@function k-meta-is-relative-length( $value ) {
|
|
56
173
|
@return k-meta-is-number( $value ) and k-string-index( "em" "ex" "ch" "rem" "vw" "vh" "vmin" "vmax", k-math-unit( $value ) ) != null;
|
|
57
174
|
}
|
|
58
175
|
|
|
176
|
+
/// Checks whether `$value` is an absolute <length> CSS data type.
|
|
177
|
+
/// @param {Any} $value - The value to check.
|
|
178
|
+
/// @return {Boolean} - Whether `$value` is an absolute length.
|
|
179
|
+
///
|
|
180
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/length#absolute_length_units
|
|
181
|
+
///
|
|
182
|
+
/// @example scss - Usage
|
|
183
|
+
/// @debug k-meta-is-absolute-length( 1cm ); // => true
|
|
184
|
+
/// @debug k-meta-is-absolute-length( 1 ); // => false
|
|
59
185
|
@function k-meta-is-absolute-length( $value ) {
|
|
60
186
|
@return k-meta-is-number( $value ) and k-string-index( "cm" "mm" "in" "px" "pt" "pc", k-math-unit( $value ) ) != null;
|
|
61
187
|
}
|
|
62
188
|
|
|
189
|
+
/// Checks whether `$value` is a <percentage> CSS data type.
|
|
190
|
+
/// @param {Any} $value - The value to check.
|
|
191
|
+
/// @return {Boolean} - Whether `$value` is a percentage.
|
|
192
|
+
///
|
|
193
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/percentage
|
|
194
|
+
///
|
|
195
|
+
/// @example scss - Usage
|
|
196
|
+
/// @debug k-meta-is-percentage( 1% ); // => true
|
|
197
|
+
/// @debug k-meta-is-percentage( 1 ); // => false
|
|
63
198
|
@function k-meta-is-percentage( $value ) {
|
|
64
199
|
@return k-meta-is-number( $value ) and k-math-unit( $value ) == "%";
|
|
65
200
|
}
|
|
66
201
|
|
|
202
|
+
/// Checks whether `$value` is a <length> CSS data type.
|
|
203
|
+
/// @param {Any} $value - The value to check.
|
|
204
|
+
/// @return {Boolean} - Whether `$value` is a length.
|
|
205
|
+
///
|
|
206
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/length
|
|
207
|
+
///
|
|
208
|
+
/// @example scss - Usage
|
|
209
|
+
/// @debug k-meta-is-length( 1em ); // => true
|
|
210
|
+
/// @debug k-meta-is-length( 1cm ); // => true
|
|
211
|
+
/// @debug k-meta-is-length( 1 ); // => false
|
|
67
212
|
@function k-meta-is-length( $value ) {
|
|
68
213
|
@return k-meta-is-relative-length( $value ) or k-meta-is-absolute-length( $value );
|
|
69
214
|
}
|
|
70
215
|
|
|
216
|
+
/// Checks whether `$value` is a <resolution> CSS data type.
|
|
217
|
+
/// @param {Any} $value - The value to check.
|
|
218
|
+
/// @return {Boolean} - Whether `$value` is a resolution.
|
|
219
|
+
///
|
|
220
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/resolution
|
|
221
|
+
///
|
|
222
|
+
/// @example scss - Usage
|
|
223
|
+
/// @debug k-meta-is-resolution( 1dpi ); // => true
|
|
224
|
+
/// @debug k-meta-is-resolution( 1 ); // => false
|
|
71
225
|
@function k-meta-is-resolution( $value ) {
|
|
72
226
|
@return k-meta-is-number( $value ) and k-string-index( "dpi" "dpcm" "dppx", k-math-unit( $value ) ) != null;
|
|
73
227
|
}
|
|
74
228
|
|
|
229
|
+
/// Checks whether `$value` is a <position> CSS data type.
|
|
230
|
+
/// @param {Any} $value - The value to check.
|
|
231
|
+
/// @return {Boolean} - Whether `$value` is a position.
|
|
232
|
+
///
|
|
233
|
+
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/position
|
|
234
|
+
///
|
|
235
|
+
/// @example scss - Usage
|
|
236
|
+
/// @debug k-meta-is-position( center ); // => true
|
|
75
237
|
@function k-meta-is-position( $value ) {
|
|
76
238
|
@return k-meta-is-length( $value ) or k-meta-is-percentage( $value ) or k-string-index( "top" "right" "bottom" "left" "center", $value ) != null;
|
|
77
239
|
}
|