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

[react] Remove sx transform logic and leverage Emotion unitless #149

Merged
merged 5 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions packages/pigment-css-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@emotion/react": "^11.11.4",
"@emotion/serialize": "^1.1.4",
"@emotion/styled": "^11.11.5",
"@emotion/unitless": "^0.8.1",
"@mui/system": "^6.0.0-alpha.6",
"@mui/utils": "^6.0.0-alpha.6",
"@wyw-in-js/processor-utils": "^0.5.3",
Expand Down
10 changes: 0 additions & 10 deletions packages/pigment-css-react/src/utils/cssFnValueToVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { parseExpression } from '@babel/parser';
import * as t from '@babel/types';
import type { Expression } from '@babel/types';
import { isUnitLess } from './isUnitLess';
import { cssFunctionTransformerPlugin } from './cssFunctionTransformerPlugin';
import type { Theme } from './extendTheme';

interface StyleObj {
Expand Down Expand Up @@ -92,15 +91,6 @@ function transformThemeKeysInFn(
}

const result = transformSync(functionString, {
plugins: [
[
cssFunctionTransformerPlugin,
{
styleKey,
options,
},
],
],
filename: filename ?? 'intermediate-fn.ts',
ast: true,
configFile: false,
Expand Down

This file was deleted.

53 changes: 1 addition & 52 deletions packages/pigment-css-react/src/utils/isUnitLess.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,4 @@
// Copied over from https://github.com/emotion-js/emotion/blob/main/packages/unitless/src/index.js
// since typings of @emotion/unitless are broken. PR to fix here - https://github.com/emotion-js/emotion/pull/3088
const unitlessKeys: { [key: string]: 1 } = {
animationIterationCount: 1,
siriwatknp marked this conversation as resolved.
Show resolved Hide resolved
aspectRatio: 1,
borderImageOutset: 1,
borderImageSlice: 1,
borderImageWidth: 1,
boxFlex: 1,
boxFlexGroup: 1,
boxOrdinalGroup: 1,
columnCount: 1,
columns: 1,
flex: 1,
flexGrow: 1,
flexPositive: 1,
flexShrink: 1,
flexNegative: 1,
flexOrder: 1,
gridRow: 1,
gridRowEnd: 1,
gridRowSpan: 1,
gridRowStart: 1,
gridColumn: 1,
gridColumnEnd: 1,
gridColumnSpan: 1,
gridColumnStart: 1,
msGridRow: 1,
msGridRowSpan: 1,
msGridColumn: 1,
msGridColumnSpan: 1,
fontWeight: 1,
lineHeight: 1,
opacity: 1,
order: 1,
orphans: 1,
tabSize: 1,
widows: 1,
zIndex: 1,
zoom: 1,
WebkitLineClamp: 1,

// SVG-related properties
fillOpacity: 1,
floodOpacity: 1,
stopOpacity: 1,
strokeDasharray: 1,
strokeDashoffset: 1,
strokeMiterlimit: 1,
strokeOpacity: 1,
strokeWidth: 1,
};
import unitlessKeys from '@emotion/unitless';

export function isUnitLess(cssKey: string) {
return unitlessKeys[cssKey] === 1 || cssKey.startsWith('--');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ function App(props) {
{
className: 'd1h14by3',
vars: {
'd1h14by3-0': [
props.tier.title === 'Professional' ? 'var(--mui-palette-grey-50)' : undefined,
false,
],
'd1h14by3-0': [props.tier.title === 'Professional' ? 'grey.50' : undefined, false],
},
},
{},
Expand Down
Loading
Loading