Skip to content

Commit e4bb1a2

Browse files
authored
[fix] Implement variant matching parity (#111)
1 parent 238404c commit e4bb1a2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

packages/pigment-css-react/src/styled.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ import * as React from 'react';
33
import clsx from 'clsx';
44
import isPropValid from '@emotion/is-prop-valid';
55

6-
function getVariantClasses(componentProps, variants) {
7-
const { ownerState = {} } = componentProps;
6+
function getVariantClasses({ ownerState = {}, ...componentProps }, variants) {
87
const variantClasses = variants
98
.filter(({ props: variantProps }) =>
109
typeof variantProps === 'function'
11-
? variantProps({ ...componentProps, ...componentProps.ownerState })
10+
? variantProps({ ...componentProps, ...ownerState, ownerState })
1211
: Object.entries(variantProps).every(([propKey, propValue]) => {
1312
return ownerState[propKey] === propValue || componentProps[propKey] === propValue;
1413
}),

0 commit comments

Comments
 (0)