Skip to content

Commit

Permalink
fix(styles): add error handling for rem & em sass functions (#4931)
Browse files Browse the repository at this point in the history
  • Loading branch information
jendowns authored and joshblack committed Jan 6, 2020
1 parent 057fade commit 51558b6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/components/src/globals/scss/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ $base-font-size: 16px !default;
/// @group global-typography
/// @deprecated (For v10) Use `carbon--rem()`
@function rem($px) {
@if unit($px) != 'px' {
// TODO: update to @error in v11
@warn "Expected argument $px to be of type `px`, instead received: `#{unit($px)}`";
}

@return ($px / $base-font-size) * 1rem;
}

Expand All @@ -33,6 +38,11 @@ $base-font-size: 16px !default;
/// @group global-typography
/// @deprecated (For v10) Use `carbon--em()`
@function em($px) {
@if unit($px) != 'px' {
// TODO: update to @error in v11
@warn "Expected argument $px to be of type `px`, instead received: `#{unit($px)}`";
}

@return ($px / $base-font-size) * 1em;
}

Expand Down
10 changes: 10 additions & 0 deletions packages/layout/scss/_convert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ $carbon--base-font-size: 16px !default;
/// @access public
/// @group @carbon/layout
@function carbon--rem($px) {
@if unit($px) != 'px' {
// TODO: update to @error in v11
@warn "Expected argument $px to be of type `px`, instead received: `#{unit($px)}`";
}

@return ($px / $carbon--base-font-size) * 1rem;
}

Expand All @@ -26,5 +31,10 @@ $carbon--base-font-size: 16px !default;
/// @access public
/// @group @carbon/layout
@function carbon--em($px) {
@if unit($px) != 'px' {
// TODO: update to @error in v11
@warn "Expected argument $px to be of type `px`, instead received: `#{unit($px)}`";
}

@return ($px / $carbon--base-font-size) * 1em;
}

0 comments on commit 51558b6

Please sign in to comment.