Skip to content

Commit

Permalink
fix(styled-system): specify unit for CSS custom property negation (#908)
Browse files Browse the repository at this point in the history
* fix(styled-system): specify `0px` instead of `0` for CSS custom property negation in `calc()`

* chore: add changeset `tonic-ui-907.md`

* Update tonic-ui-907.md
  • Loading branch information
cheton authored Aug 10, 2024
1 parent ae07539 commit 272869f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/tonic-ui-907.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tonic-ui/styled-system": patch
---

fix(styled-system): specify unit for CSS custom property negation
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ exports[`Drawer should render correctly 1`] = `
.emotion-12:focus-visible {
outline-color: var(--tonic-colors-blue-60);
outline-offset: calc(0 - var(--tonic-space-1h));
outline-offset: calc(0px - var(--tonic-space-1h));
outline-style: solid;
outline-width: var(--tonic-sizes-1h);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ exports[`Menu should render correctly 1`] = `
.emotion-16:focus-visible {
outline-color: var(--tonic-colors-blue-60);
outline-offset: calc(0 - var(--tonic-space-1h));
outline-offset: calc(0px - var(--tonic-space-1h));
outline-style: solid;
outline-width: var(--tonic-sizes-1h);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ exports[`Modal should render correctly 1`] = `
.emotion-12:focus-visible {
outline-color: var(--tonic-colors-blue-60);
outline-offset: calc(0 - var(--tonic-space-1h));
outline-offset: calc(0px - var(--tonic-space-1h));
outline-style: solid;
outline-width: var(--tonic-sizes-1h);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ exports[`Tabs should render correctly 1`] = `
.emotion-4:focus-visible {
outline-color: var(--tonic-colors-blue-60);
outline-offset: calc(0 - var(--tonic-space-1h));
outline-offset: calc(0px - var(--tonic-space-1h));
outline-style: solid;
outline-width: var(--tonic-sizes-1h);
color: var(--tonic-colors-white-primary);
Expand Down Expand Up @@ -106,7 +106,7 @@ exports[`Tabs should render correctly 1`] = `
.emotion-6:focus-visible {
outline-color: var(--tonic-colors-blue-60);
outline-offset: calc(0 - var(--tonic-space-1h));
outline-offset: calc(0px - var(--tonic-space-1h));
outline-style: solid;
outline-width: var(--tonic-sizes-1h);
color: var(--tonic-colors-white-primary);
Expand Down Expand Up @@ -160,7 +160,7 @@ exports[`Tabs should render correctly 1`] = `
.emotion-8:focus-visible {
outline-color: var(--tonic-colors-blue-60);
outline-offset: calc(0 - var(--tonic-space-1h));
outline-offset: calc(0px - var(--tonic-space-1h));
outline-style: solid;
outline-width: var(--tonic-sizes-1h);
color: var(--tonic-colors-white-disabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports[`Tree should render correctly 1`] = `
.emotion-4:focus-visible {
outline-color: var(--tonic-colors-blue-60);
outline-offset: calc(0 - var(--tonic-space-1h));
outline-offset: calc(0px - var(--tonic-space-1h));
outline-style: solid;
outline-width: var(--tonic-sizes-1h);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/styled-system/src/config/__tests__/margin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ test('returns negative theme values using CSS variables', () => {
});
expect(style).toEqual({
margin: 'var(--tonic-space-0)',
marginLeft: 'calc(0 - var(--tonic-space-2))',
marginRight: 'calc(0 - var(--tonic-space-2))',
marginTop: 'calc(0 - var(--tonic-space-1))',
marginBottom: 'calc(0 - var(--tonic-space-1))',
marginLeft: 'calc(0px - var(--tonic-space-2))',
marginRight: 'calc(0px - var(--tonic-space-2))',
marginTop: 'calc(0px - var(--tonic-space-1))',
marginBottom: 'calc(0px - var(--tonic-space-1))',
});
});

Expand Down
8 changes: 4 additions & 4 deletions packages/styled-system/src/config/__tests__/position.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ test('returns negative theme values using CSS variables', () => {
left: -4,
});
expect(style).toEqual({
top: 'calc(0 - var(--tonic-space-1))',
right: 'calc(0 - var(--tonic-space-2))',
bottom: 'calc(0 - var(--tonic-space-3))',
left: 'calc(0 - var(--tonic-space-4))',
top: 'calc(0px - var(--tonic-space-1))',
right: 'calc(0px - var(--tonic-space-2))',
bottom: 'calc(0px - var(--tonic-space-3))',
left: 'calc(0px - var(--tonic-space-4))',
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/styled-system/src/utils/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const toNegativeValue = (scale, absoluteValue, options) => {
// Handle CSS variables for negative values
if (useCSSVariables && isSimpleCSSVariable(n)) {
// https://stackoverflow.com/questions/49469344/using-negative-css-custom-properties
return `calc(0 - ${n})`;
return `calc(0px - ${n})`;
}

// Handle numeric value
Expand Down

0 comments on commit 272869f

Please sign in to comment.