Skip to content

Commit

Permalink
chore(core): add k-map-neg function
Browse files Browse the repository at this point in the history
  • Loading branch information
magdalenaan authored and Juveniel committed Mar 21, 2023
1 parent 11ca05a commit 2db5442
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
48 changes: 48 additions & 0 deletions packages/core/docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,54 @@ k-map-values($map) // => List
}
```

### `k-map-negate`

Returns negative values of a number or numbers in a list.


#### Syntax

```scss
k-map-negate($map) // => Map
```

#### Parameters


`<Map> $map`
: The map to get the values from.


#### Examples

```scss
// Usage
@debug k-map-negate( ( 0: 0, 1: 1px, 2: 2px ) ); // => ("-1": -1px, "-2": -2px)
```


#### Source

```scss
// Location https://github.com/telerik/kendo-themes/blob/develop/packages//scss/functions/_map.import.scss#L89-L105
@function k-map-negate($map) {
$_map-neg: ();

@if( k-meta-type-of($map) != map ) {
@error "expected type of #{$map} is map, was #{k-meta-type-of($map)}";
};
@each $key, $value in $map {
$_key-neg: "-" + $key;

@if( k-meta-type-of($value) == number and $value != 0) {
$_map-neg: k-map-set($_map-neg, $_key-neg, -1 * $value );
}
}

@return $_map-neg;
}
```

### `k-math-abs`

Returns the absolute value of a number.
Expand Down
24 changes: 24 additions & 0 deletions packages/core/scss/functions/_map.import.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,27 @@
@function k-map-values( $map ) {
@return map-values( $map );
}

/// Returns negative values of a number or numbers in a list.
/// @param {Map} $map - The map to get the values from.
/// @return {Map} - A comma separated list of the values in `$map`.
///
/// @example scss - Usage
/// @debug k-map-negate( ( 0: 0, 1: 1px, 2: 2px ) ); // => ("-1": -1px, "-2": -2px)
@function k-map-negate($map) {
$_map-neg: ();

@if( k-meta-type-of($map) != map ) {
@error "expected type of #{$map} is map, was #{k-meta-type-of($map)}";
};
@each $key, $value in $map {
$_key-neg: "-" + $key;

@if( k-meta-type-of($value) == number and $value != 0) {
$_map-neg: k-map-set($_map-neg, $_key-neg, -1 * $value );
}
}

@return $_map-neg;

}

0 comments on commit 2db5442

Please sign in to comment.