Skip to content

Commit d276a16

Browse files
authored
fix(styles): use list.nth, match.floor and math.unit (#18819)
1 parent 8cc7994 commit d276a16

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

packages/grid/scss/_breakpoint.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/// @group @carbon/layout
2020
@function -key-by-index($map, $index) {
2121
$keys: map.keys($map);
22-
@return nth($keys, $index);
22+
@return list.nth($keys, $index);
2323
}
2424

2525
/// Get the value of the next breakpoint, or null for the last breakpoint

packages/grid/scss/_flex-grid.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
/// @group @carbon/layout
282282
@function -key-by-index($map, $index) {
283283
$keys: map.keys($map);
284-
@return nth($keys, $index);
284+
@return list.nth($keys, $index);
285285
}
286286

287287
/// Generate the CSS for a grid for the given breakpoints and gutters

packages/layout/scss/_convert.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $base-font-size: 16px !default;
2020
/// @access public
2121
/// @group @carbon/layout
2222
@function to-rem($px) {
23-
@if unit($px) != 'px' {
23+
@if math.unit($px) != 'px' {
2424
@error "Expected argument $px to be of type `px`, instead received: `#{unit($px)}`";
2525
}
2626

@@ -35,7 +35,7 @@ $base-font-size: 16px !default;
3535
/// @deprecated
3636
/// @group @carbon/layout
3737
@function rem($px) {
38-
@if unit($px) != 'px' {
38+
@if math.unit($px) != 'px' {
3939
@error "Expected argument $px to be of type `px`, instead received: `#{unit($px)}`";
4040
}
4141

@@ -48,7 +48,7 @@ $base-font-size: 16px !default;
4848
/// @access public
4949
/// @group @carbon/layout
5050
@function em($px) {
51-
@if unit($px) != 'px' {
51+
@if math.unit($px) != 'px' {
5252
@error "Expected argument $px to be of type `px`, instead received: `#{unit($px)}`";
5353
}
5454

packages/layout/scss/_utilities.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/// @group @carbon/layout
2929
@function key-by-index($map, $index) {
3030
$keys: map.keys($map);
31-
@return nth($keys, $index);
31+
@return list.nth($keys, $index);
3232
}
3333

3434
/// Pass in a map, and get the last one in the list back

packages/type/scss/_scale.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
@use '@carbon/layout';
99
@use 'sass:list';
10+
@use 'sass:math';
1011

1112
/// Compute the type size for the given type scale step
1213
/// @param {Number} $step
@@ -18,7 +19,7 @@
1819
@return 12px;
1920
}
2021
// Yn = Yn-1 + {INT[(n-2)/4] + 1} * 2
21-
@return get-type-size($step - 1) + (floor(($step - 2) * 0.25) + 1) * 2;
22+
@return get-type-size($step - 1) + (math.floor(($step - 2) * 0.25) + 1) * 2;
2223
}
2324

2425
/// Type scale follows a custom formula for determining each step size and supports sizes from 12px to 92px
@@ -36,7 +37,7 @@ $type-scale: ();
3637
/// @access public
3738
/// @group @carbon/type
3839
@function type-scale($step) {
39-
@return nth($type-scale, $step);
40+
@return list.nth($type-scale, $step);
4041
}
4142

4243
/// Set the font-size value of a selector with the value at the given `$step`

0 commit comments

Comments
 (0)