Skip to content

Commit

Permalink
[fix] Implement variant matching parity (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai authored May 29, 2024
1 parent 238404c commit e4bb1a2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/pigment-css-react/src/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import * as React from 'react';
import clsx from 'clsx';
import isPropValid from '@emotion/is-prop-valid';

function getVariantClasses(componentProps, variants) {
const { ownerState = {} } = componentProps;
function getVariantClasses({ ownerState = {}, ...componentProps }, variants) {
const variantClasses = variants
.filter(({ props: variantProps }) =>
typeof variantProps === 'function'
? variantProps({ ...componentProps, ...componentProps.ownerState })
? variantProps({ ...componentProps, ...ownerState, ownerState })
: Object.entries(variantProps).every(([propKey, propValue]) => {
return ownerState[propKey] === propValue || componentProps[propKey] === propValue;
}),
Expand Down

0 comments on commit e4bb1a2

Please sign in to comment.