Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@carbon/styles): change rem function to to-rem #14420

Merged
merged 5 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"postcss": "^8.4.14",
"postcss-flexbugs-fixes": "^5.0.2",
"rimraf": "^5.0.0",
"sass": "^1.51.0"
"sass": "^1.65.1"
},
"sideEffects": [
"index.scss",
Expand Down
14 changes: 7 additions & 7 deletions packages/styles/scss/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@

@use './config' as *;
@use './utilities/custom-property';
@use './utilities/convert' as *;
@use './utilities/convert';
@use './spacing' as *;

$layout-tokens: (
size: (
height: (
xs: rem(24px),
sm: rem(32px),
md: rem(40px),
lg: rem(48px),
xl: rem(64px),
2xl: rem(80px),
xs: convert.rem(24px),
sm: convert.rem(32px),
md: convert.rem(40px),
lg: convert.rem(48px),
xl: convert.rem(64px),
2xl: convert.rem(80px),
),
),
density: (
Expand Down
12 changes: 6 additions & 6 deletions packages/styles/scss/components/breadcrumb/_breadcrumb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@use '../../type' as *;
@use '../../layer' as *;
@use '../../utilities/component-reset';
@use '../../utilities/convert' as *;
@use '../../utilities/convert';
@use '../../utilities/skeleton' as *;

@mixin breadcrumb {
Expand Down Expand Up @@ -79,8 +79,8 @@
// Overflow Menu overrides
.#{$prefix}--breadcrumb-item .#{$prefix}--overflow-menu {
position: relative;
width: rem(20px);
height: rem(18px);
width: convert.rem(20px);
height: convert.rem(18px);

&:focus {
outline: 1px solid $focus;
Expand All @@ -94,7 +94,7 @@
&::after {
position: absolute;
bottom: 2px;
width: rem(12px);
width: convert.rem(12px);
height: 1px;
background: $link-primary-hover;
content: '';
Expand Down Expand Up @@ -133,7 +133,7 @@
outline: none;
}

$caret-size: rem(7px);
$caret-size: convert.rem(7px);
.#{$prefix}--breadcrumb-menu-options.#{$prefix}--overflow-menu-options::after {
top: -$caret-size;
left: $caret-size * 2;
Expand All @@ -150,7 +150,7 @@
.#{$prefix}--breadcrumb.#{$prefix}--skeleton .#{$prefix}--link {
@include skeleton;

width: rem(100px);
width: convert.rem(100px);
height: 1rem;
}

Expand Down
39 changes: 23 additions & 16 deletions packages/styles/scss/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@use '../../theme' as *;
@use '../../type' as *;
@use '../../layer' as *;
@use '../../utilities/convert' as *;
@use '../../utilities/convert';
@use '../../utilities/focus-outline';
@use '../../utilities/high-contrast-mode' as *;
@use '../../utilities/skeleton' as *;
Expand Down Expand Up @@ -113,7 +113,9 @@
$layer-active
);

padding-inline-end: calc(layout.density('padding-inline') - rem(1px));
padding-inline-end: calc(
layout.density('padding-inline') - convert.rem(1px)
);

.#{$prefix}--btn__icon {
position: static;
Expand Down Expand Up @@ -153,13 +155,13 @@
padding: 0;
// -1px to compensate for border width
padding-block-start: min(
calc((layout.size('height') - rem(16px)) / 2 - rem(1px)),
calc((layout.size('height') - convert.rem(16px)) / 2 - convert.rem(1px)),
var(--temp-padding-block-max)
);

> :first-child {
min-width: rem(16px);
margin-block-start: rem(1px);
min-width: convert.rem(16px);
margin-block-start: convert.rem(1px);
}

.#{$prefix}--btn__icon {
Expand Down Expand Up @@ -273,7 +275,9 @@
$button-danger-active
);

padding-inline-end: calc(layout.density('padding-inline') - rem(1px));
padding-inline-end: calc(
layout.density('padding-inline') - convert.rem(1px)
);

.#{$prefix}--btn__icon {
position: static;
Expand Down Expand Up @@ -304,7 +308,10 @@
@include type-style('body-compact-02');

padding-block: min(
calc((layout.size('height') - var(--temp-expressive-1lh)) / 2 - rem(1px)),
calc(
(layout.size('height') - var(--temp-expressive-1lh)) / 2 -
convert.rem(1px)
),
var(--temp-padding-block-max)
);
}
Expand All @@ -315,19 +322,19 @@
}

.#{$prefix}--btn.#{$prefix}--btn--expressive .#{$prefix}--btn__icon {
width: rem(20px);
height: rem(20px);
width: convert.rem(20px);
height: convert.rem(20px);
}

.#{$prefix}--btn-set .#{$prefix}--btn.#{$prefix}--btn--expressive {
max-width: rem(320px);
max-width: convert.rem(320px);
}

// Skeleton State
.#{$prefix}--btn.#{$prefix}--skeleton {
@include skeleton;

width: rem(150px);
width: convert.rem(150px);
}

// button set styles
Expand All @@ -342,10 +349,10 @@
.#{$prefix}--btn-set .#{$prefix}--btn {
width: 100%;
// 196px from design kit
max-width: rem(196px);
max-width: convert.rem(196px);

&:not(:focus) {
box-shadow: rem(-1px) 0 0 0 $button-separator;
box-shadow: convert.rem(-1px) 0 0 0 $button-separator;
}

&:first-of-type:not(:focus) {
Expand All @@ -358,23 +365,23 @@
}

.#{$prefix}--btn-set--stacked .#{$prefix}--btn:not(:focus) {
box-shadow: 0 rem(-1px) 0 0 $button-separator;
box-shadow: 0 convert.rem(-1px) 0 0 $button-separator;
}

.#{$prefix}--btn-set--stacked .#{$prefix}--btn:first-of-type:not(:focus) {
box-shadow: inherit;
}

.#{$prefix}--btn-set .#{$prefix}--btn.#{$prefix}--btn--disabled {
box-shadow: rem(-1px) 0 0 0 $icon-on-color-disabled;
box-shadow: convert.rem(-1px) 0 0 0 $icon-on-color-disabled;

&:first-of-type {
box-shadow: none;
}
}

.#{$prefix}--btn-set--stacked .#{$prefix}--btn.#{$prefix}--btn--disabled {
box-shadow: 0 rem(-1px) 0 0 $layer-selected-disabled;
box-shadow: 0 convert.rem(-1px) 0 0 $layer-selected-disabled;

&:first-of-type {
box-shadow: none;
Expand Down
22 changes: 12 additions & 10 deletions packages/styles/scss/components/button/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@use '../../theme' as *;
@use '../../type' as *;
@use '../../utilities/component-reset';
@use '../../utilities/convert' as *;
@use '../../utilities/convert';
@use '../../utilities/custom-property';
@use '../../utilities/layout';
@use 'tokens' as *;
Expand All @@ -38,7 +38,7 @@ $button-focus-color: custom-property.get-var('button-focus-color', $focus);
// -1px to compensate for border width
--temp-padding-block-max: calc(
(#{custom-property.get-var('layout-size-height-lg')} - var(--temp-1lh)) / 2 -
#{rem(1px)}
#{convert.rem(1px)}
);

@include component-reset.reset;
Expand All @@ -47,7 +47,7 @@ $button-focus-color: custom-property.get-var('button-focus-color', $focus);
position: relative;
display: inline-flex;
width: max-content;
max-width: rem(320px);
max-width: convert.rem(320px);
min-height: layout.size('height');
flex-shrink: 0;
justify-content: space-between;
Expand All @@ -58,13 +58,15 @@ $button-focus-color: custom-property.get-var('button-focus-color', $focus);
outline: none;
// -1px to compensate for border width
padding-block: min(
calc((layout.size('height') - var(--temp-1lh)) / 2 - rem(1px)),
calc((layout.size('height') - var(--temp-1lh)) / 2 - convert.rem(1px)),
var(--temp-padding-block-max)
);
padding-inline-end: calc(
layout.density('padding-inline') * 3 + rem(16px) - rem(1px)
layout.density('padding-inline') * 3 + convert.rem(16px) - convert.rem(1px)
);
padding-inline-start: calc(
layout.density('padding-inline') - convert.rem(1px)
);
padding-inline-start: calc(layout.density('padding-inline') - rem(1px));
text-align: left;
text-decoration: none;
transition: background $duration-fast-01 motion(entrance, productive),
Expand All @@ -90,14 +92,14 @@ $button-focus-color: custom-property.get-var('button-focus-color', $focus);
position: absolute;
// -1px to compensate for border width
top: min(
calc((layout.size('height') - rem(16px)) / 2 - rem(1px)),
calc((layout.size('height') - convert.rem(16px)) / 2 - convert.rem(1px)),
var(--temp-padding-block-max)
);
right: layout.density('padding-inline');
width: rem(16px);
height: rem(16px);
width: convert.rem(16px);
height: convert.rem(16px);
flex-shrink: 0;
margin-block-start: rem(1px);
margin-block-start: convert.rem(1px);
}
}

Expand Down
42 changes: 21 additions & 21 deletions packages/styles/scss/components/checkbox/_checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@use '../../theme' as *;
@use '../../type' as *;
@use '../../utilities/component-reset';
@use '../../utilities/convert' as *;
@use '../../utilities/convert';
@use '../../utilities/skeleton' as *;
@use '../../utilities/visually-hidden' as *;

Expand All @@ -28,7 +28,7 @@

// Spacing above collection of checkboxes
.#{$prefix}--form-item.#{$prefix}--checkbox-wrapper:first-of-type {
margin-top: rem(3px);
margin-top: convert.rem(3px);
}

// Shift collection of checkboxes up if label is present
Expand All @@ -39,7 +39,7 @@

// Spacing below collection of checkboxes
.#{$prefix}--form-item.#{$prefix}--checkbox-wrapper:last-of-type {
margin-bottom: rem(3px);
margin-bottom: convert.rem(3px);
}

// Visually, we'll hide the checkbox input and create our own styled version
Expand All @@ -60,16 +60,16 @@

position: relative;
display: flex;
min-height: rem(24px);
padding-top: rem(3px);
padding-left: rem(20px);
min-height: convert.rem(24px);
padding-top: convert.rem(3px);
padding-left: convert.rem(20px);
cursor: pointer;
user-select: none;
}

.#{$prefix}--checkbox-label-text {
// Add extra spacing when label is present
padding-left: rem(6px);
padding-left: convert.rem(6px);
}

// Required because `$css--reset: true` cannot currently apply to this `::before` and `::after`
Expand All @@ -85,17 +85,17 @@
// `top` since we don't want the checkbox to be centered vertically with the
// text overflows.
position: absolute;
top: rem(2px);
top: convert.rem(2px);
left: 0;

// According to the spec, we'll want the bounding box for our checkbox to
// be 16px. The border size will be what will be updated during the
// different checkbox states.
width: rem(16px);
height: rem(16px);
width: convert.rem(16px);
height: convert.rem(16px);
border: 1px solid $icon-primary;
// increase left margin for #6480
margin: rem(2px) rem(2px) rem(2px) rem(3px);
margin: convert.rem(2px) convert.rem(2px) convert.rem(2px) convert.rem(3px);

// Checkboxes with a background color look visually off against a parent container.
background-color: transparent;
Expand All @@ -106,13 +106,13 @@
// Create the appearance of the check in the `after` pseudo-element
.#{$prefix}--checkbox-label::after {
position: absolute;
top: rem(7.5px);
left: rem(7px);
width: rem(9px);
height: rem(5px);
top: convert.rem(7.5px);
left: convert.rem(7px);
width: convert.rem(9px);
height: convert.rem(5px);
border-bottom: 1.5px solid $icon-inverse;
border-left: 1.5px solid $icon-inverse;
margin-top: rem(-3px) #{'/*rtl:0rem*/'};
margin-top: convert.rem(-3px) #{'/*rtl:0rem*/'};
background: none;
content: '';
transform: scale(0) rotate(-45deg);
Expand Down Expand Up @@ -140,8 +140,8 @@

// Indeterminate symbol
.#{$prefix}--checkbox:indeterminate + .#{$prefix}--checkbox-label::after {
top: rem(11px);
width: rem(8px);
top: convert.rem(11px);
width: convert.rem(8px);
border-bottom: 2px solid $icon-inverse;
border-left: 0 solid $icon-inverse;
transform: scale(1) rotate(0deg);
Expand Down Expand Up @@ -227,7 +227,7 @@
}

.#{$prefix}--checkbox__invalid-icon {
margin: 0 rem(1px) 0 rem(3px);
margin: 0 convert.rem(1px) 0 convert.rem(3px);
fill: $support-error;
}

Expand Down Expand Up @@ -330,11 +330,11 @@
.#{$prefix}--checkbox-label-text.#{$prefix}--skeleton {
@include skeleton;

width: rem(100px);
width: convert.rem(100px);
height: $spacing-05;

// Add extra spacing when label is present
margin: rem(1px) 0 0 rem(6px);
margin: convert.rem(1px) 0 0 convert.rem(6px);
}

//-----------------------------------------------
Expand Down
Loading