Skip to content

Commit

Permalink
fix(styes): add error handling for rem & em sass functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jendowns committed Dec 20, 2019
1 parent 8911fe8 commit e8cba9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 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,10 @@ $base-font-size: 16px !default;
/// @group global-typography
/// @deprecated (For v10) Use `carbon--rem()`
@function rem($px) {
@if unit($px) != 'px' {
@error "Argument `#{$px}` must be a value in pixels.";
}

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

Expand All @@ -33,6 +37,10 @@ $base-font-size: 16px !default;
/// @group global-typography
/// @deprecated (For v10) Use `carbon--em()`
@function em($px) {
@if unit($px) != 'px' {
@error "Argument `#{$px}` must be a value in pixels.";
}

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

Expand Down
8 changes: 8 additions & 0 deletions packages/layout/scss/_convert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ $carbon--base-font-size: 16px !default;
/// @access public
/// @group @carbon/layout
@function carbon--rem($px) {
@if unit($px) != 'px' {
@error "Argument `#{$px}` must be a value in pixels.";
}

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

Expand All @@ -26,5 +30,9 @@ $carbon--base-font-size: 16px !default;
/// @access public
/// @group @carbon/layout
@function carbon--em($px) {
@if unit($px) != 'px' {
@error "Argument `#{$px}` must be a value in pixels.";
}

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

0 comments on commit e8cba9f

Please sign in to comment.