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

Defaulting to "primary" variant overwrites multiple variants #78

Closed
cmaycumber opened this issue Mar 15, 2021 · 2 comments
Closed

Defaulting to "primary" variant overwrites multiple variants #78

cmaycumber opened this issue Mar 15, 2021 · 2 comments

Comments

@cmaycumber
Copy link
Contributor

cmaycumber commented Mar 15, 2021

Example

const theme = {
 button: {
  primary: {
   bg: 'green'
  },
  secondary: {
   bg: 'blue'
  }
 }
};

...

/* This style is not applied because primary being the default variant takes precedence because singular variants take 
precedence over multi variants */
<Button variants=['secondary'] />

Dripsy Code

In css/index.tsx

...
export function mapPropsToStyledComponent<P, T>(
  props: StyledProps<P>,
  options: ThemedOptions<T>
) {
  const {
    themeKey,
    defaultStyle,
    /* This needs to be removed or handled differently */
    defaultVariant = 'primary',
    defaultVariants = [],
  } = options
...
@nandorojo
Copy link
Owner

nandorojo commented Mar 15, 2021

That's interesting. What if we changed variants to primary by default, would that create the right behavior?

I think my hover support PR uses variants array to take precedence, but it isn't merged yet because of some unsolved bugs. I'll retry it after #74 is merged.

@cmaycumber
Copy link
Contributor Author

I think a combination of adding the primary variant as default in the variants array and making the variants array take precedence would solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants