Skip to content

Commit

Permalink
Fix SASS deprecations (#1337)
Browse files Browse the repository at this point in the history
## 📝 Changes

SASS introduced a [breaking
change](https://sass-lang.com/documentation/breaking-changes/mixed-decls/)
with nested selectors to be more in line with native CSS. This was
causing a lot of noise in our scripts.

This PR updates our SASS to remove the problematic code. Most of the
time the declartions in SCSS could simply be moved to the top of the
block. With complicated nesting (i.e. `_responsive-props.scss`) we have
to utilize `& { }`.

We'll need to be mindful of this SCSS change in new work—it may warrant
a Stylelint rule if it becomes problematic.

## ✅ Checklist

- [x] Code is complete and in accordance with our style guide
- [x] Changeset is added
  • Loading branch information
stephenjwatkins committed Aug 28, 2024
1 parent 69ee83b commit b7021d7
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-rocks-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@easypost/easy-ui": patch
---

fix: SASS deprecations
2 changes: 1 addition & 1 deletion easy-ui-react/src/Button/Button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
}

.variantFilled {
@include Button.variantFilled;
padding: design-token("space.1.5") design-token("space.2");
@include Button.variantFilled;
}

.variantOutlined {
Expand Down
2 changes: 1 addition & 1 deletion easy-ui-react/src/Card/Card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ button.container:not([disabled]) {
}

.area {
@include responsive-prop("card-area", "padding", padding);
background: component-token("card-area", "background");
display: flex;
flex-direction: column;
min-height: 100%;
@include responsive-prop("card-area", "padding", padding);
> * {
flex: 1 0 auto;
}
Expand Down
2 changes: 1 addition & 1 deletion easy-ui-react/src/DataGrid/Cell.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
}

.focused {
@include native-focus-ring;
outline-offset: -1px;
@include native-focus-ring;
}

.expanded {
Expand Down
2 changes: 1 addition & 1 deletion easy-ui-react/src/DataGrid/ColumnHeader.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
}

.focused {
@include native-focus-ring;
outline-offset: -1px;
@include native-focus-ring;
}

.first {
Expand Down
6 changes: 3 additions & 3 deletions easy-ui-react/src/DropdownButton/DropdownButton.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
@use "../Button/mixins" as Button;

.DropdownButton {
@include Button.base;
@include font-style("button");
gap: design-token("space.1.5");
@include Button.base;
}

.colorPrimary {
Expand Down Expand Up @@ -36,16 +36,16 @@
}

.variantOutlined {
@include Button.variantOutlined;
padding: calc(
#{design-token("space.1.5")} - #{design-token("shape.border_width.1")}
)
calc(#{design-token("space.2")} - #{design-token("shape.border_width.1")});
@include Button.variantOutlined;
}

.variantFilled {
@include Button.variantFilled;
padding: design-token("space.1.5") design-token("space.2");
@include Button.variantFilled;
}

.pipeSeparator {
Expand Down
5 changes: 2 additions & 3 deletions easy-ui-react/src/HorizontalGrid/HorizontalGrid.module.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
@use "../styles/common" as *;

.HorizontalGrid {
display: component-token("horizontal-grid", "display");
align-items: component-token("horizontal-grid", "align-items");
@include responsive-prop(
"horizontal-grid",
"grid-template-columns",
grid-template-columns
);
@include responsive-prop("horizontal-grid", "gap", "gap");

display: component-token("horizontal-grid", "display");
align-items: component-token("horizontal-grid", "align-items");
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@use "../styles/common" as *;

.HorizontalStack {
@include responsive-prop("horizontal-stack", "gap", gap);

display: component-token("horizontal-stack", "display");
flex-wrap: component-token("horizontal-stack", "wrap");
align-items: component-token("horizontal-stack", "block-align");
Expand All @@ -12,4 +10,5 @@
// due to the way flexbox behaves with text truncation
// https://css-tricks.com/flexbox-truncated-text
min-width: 0;
@include responsive-prop("horizontal-stack", "gap", gap);
}
14 changes: 8 additions & 6 deletions easy-ui-react/src/Icon/Icon.module.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
@use "../styles/common" as *;

.Icon {
@include component-token("icon", "color", currentColor);
@include responsive-props("icon", "size") using ($var) {
width: $var;
height: $var;
}

display: flex;
align-items: center;
justify-content: center;

max-height: 100%;
max-width: 100%;

@include component-token("icon", "color", currentColor);
@include responsive-props("icon", "size") using ($var) {
& {
width: $var;
height: $var;
}
}

svg {
fill: component-token("icon", "color");
}
Expand Down
4 changes: 2 additions & 2 deletions easy-ui-react/src/IconButton/IconButton.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
}

.variantOutlined {
@include Button.variantOutlined;
padding: calc(
#{design-token("space.1.5")} - #{design-token("shape.border_width.1")}
);
@include Button.variantOutlined;
}

.variantFilled {
@include Button.variantFilled;
padding: design-token("space.1.5");
@include Button.variantFilled;
}
4 changes: 2 additions & 2 deletions easy-ui-react/src/Menu/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
theme-token("color.neutral.300")
);

@include responsive-prop("menu", "width", width);

background: component-token("menu", "color.background");
border: design-token("shape.border_width.1") solid
component-token("menu", "color.border");
Expand All @@ -44,6 +42,8 @@
display: flex;
flex-direction: column;
min-width: component-token("menu", "min-width");

@include responsive-prop("menu", "width", width);
}

@mixin menu {
Expand Down
4 changes: 2 additions & 2 deletions easy-ui-react/src/RadioGroup/RadioGroupItem.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
}

.label {
@include overlay-input;
display: inline-flex;
@include overlay-input;
}

.radioOuter,
Expand All @@ -32,9 +32,9 @@
component-token("radio-group-item", "color");

.focusVisible & {
@include native-focus-ring;
// without an offset the outline conflicts with the radio outline
outline-offset: 1px;
@include native-focus-ring;
}
}

Expand Down
2 changes: 1 addition & 1 deletion easy-ui-react/src/Select/Select.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
}

.selectField {
@include Input.input;
display: flex;
align-items: center;
@include Input.input;

&:hover {
@include Input.hovered;
Expand Down
2 changes: 1 addition & 1 deletion easy-ui-react/src/Toggle/Toggle.module.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@use "../styles/common" as *;

.Toggle {
@include overlay-input;
display: inline-flex;
align-items: center;
gap: design-token("space.1.5");
@include overlay-input;
}

.text,
Expand Down
2 changes: 1 addition & 1 deletion easy-ui-react/src/VerticalStack/VerticalStack.module.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@use "../styles/common" as *;

.VerticalStack {
@include responsive-prop("vertical-stack", "gap", "gap");
display: component-token("vertical-stack", "display");
flex-direction: component-token("vertical-stack", "order");
align-items: component-token("vertical-stack", "inline-align");
justify-content: component-token("vertical-stack", "align");
@include responsive-prop("vertical-stack", "gap", "gap");
}

.listReset {
Expand Down
8 changes: 6 additions & 2 deletions easy-ui-react/src/styles/_responsive-props.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@

// For each of our breakpoints, initialize an initial value (literally)
@each $bp-alias in $bp-aliases {
--ezui-c-#{$cleanedComponentName}-#{$cleanedComponentProp}-#{$bp-alias}: initial;
& {
--ezui-c-#{$cleanedComponentName}-#{$cleanedComponentProp}-#{$bp-alias}: initial;
}
}

// For each of our breakpoints, create a media query block and assign a
Expand Down Expand Up @@ -81,6 +83,8 @@
// Shorthand for applying a CSS variable template to a single CSS prop
@mixin responsive-prop($componentName, $componentProp, $declarationProp) {
@include responsive-props($componentName, $componentProp) using ($var) {
#{$declarationProp}: $var;
& {
#{$declarationProp}: $var;
}
}
}

0 comments on commit b7021d7

Please sign in to comment.