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

Compound variants are lost when extending multiple times #168

Closed
benjamincanac opened this issue Mar 11, 2024 · 2 comments · Fixed by #170
Closed

Compound variants are lost when extending multiple times #168

benjamincanac opened this issue Mar 11, 2024 · 2 comments · Fixed by #170
Labels
bug Something isn't working

Comments

@benjamincanac
Copy link

Describe the bug

When extending tv objects in cascade, the compoundVariants gets lost.

To Reproduce

import { tv } from 'tailwind-variants'

const themeButton = tv({
  base: 'font-medium',
  variants: {
    color: {
      primary: 'text-blue-500'
    },
    disabled: {
      true: 'opacity-50'
    }
  },
  compoundVariants: [{
    color: 'primary',
    disabled: true,
    class: 'bg-black'
  }],
  defaultVariants: {
    color: 'primary',
    disabled: true
  }
})

const appButton = tv({ extend: themeButton })
const button = tv({ extend: appButton })

console.log('appButton', appButton())
// -> font-medium text-blue-500 opacity-50 bg-black
console.log('button', button())
// -> font-medium text-blue-500 opacity-50

Expected behavior

The appButton and button function calls should have the same results.

Desktop (please complete the following information):

  • OS: Mac
  • Browser: Chrome
@benjamincanac benjamincanac added the bug Something isn't working label Mar 11, 2024
@jrgarciadev
Copy link
Member

@mskelton could you please take a look at this?

@mskelton
Copy link
Collaborator

@jrgarciadev PR opened to fix this #170

jrgarciadev pushed a commit that referenced this issue Mar 15, 2024
* fix: support multi-level extend for `compoundVariants`

Fixes #168

* chore: add `test:watch` script for testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants