Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@emotion/hash": "^0.8.0",
"@emotion/unitless": "^0.7.5",
"classnames": "^2.3.1",
"csstype": "^3.0.10",
"csstype": "3.1.2",
"rc-util": "^5.35.0",
"stylis": "^4.0.13"
},
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useCompatibleInsertionEffect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { useInsertionEffect } = fullClone;
type UseCompatibleInsertionEffect = (
renderEffect: EffectCallback,
effect: (polyfill?: boolean) => ReturnType<EffectCallback>,
deps?: React.DependencyList,
deps: React.DependencyList,
) => void;

/**
Expand Down
20 changes: 8 additions & 12 deletions src/transformers/legacyLogicalProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,16 @@ function splitValues(
let brackets = 0;
return [
splitStyle.reduce<string[]>((list, item) => {
if (item.includes('(')) {
temp += item;
brackets += item.split('(').length - 1;
} else if (item.includes(')')) {
temp += item;
brackets -= item.split(')').length - 1;
if (brackets === 0) {
list.push(temp);
temp = '';
}
if (item.includes('(') || item.includes(')')) {
const left = item.split('(').length - 1;
const right = item.split(')').length - 1;
brackets += left - right;
}
if (brackets === 0) {
list.push(temp + item);
temp = '';
} else if (brackets > 0) {
temp += item;
} else {
list.push(item);
}
return list;
}, []),
Expand Down
21 changes: 21 additions & 0 deletions tests/transform.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,27 @@ describe('transform', () => {
const styleText = document.head.querySelector('style')?.innerHTML;
expect(styleText).toContain('33px!important');
});

it('split with calc() and var()', () => {
const { container } = render(
<Wrapper
css={{
'.box': {
marginBlock: 'calc(var(--a) + var(--b)) calc(2px + var(--c))',
marginInline: 'calc(2px + 1px)',
marginInlineEnd: '3px',
},
}}
/>,
);

expect(container.querySelector('.box')).toHaveStyle({
marginTop: 'calc(var(--a) + var(--b))',
marginBottom: 'calc(2px + var(--c))',
marginLeft: 'calc(2px + 1px)',
marginRight: '3px',
});
});
});

describe('px2rem', () => {
Expand Down