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

themeReplacements options not working correctly #18

Closed
rogden opened this issue Dec 8, 2020 · 0 comments
Closed

themeReplacements options not working correctly #18

rogden opened this issue Dec 8, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@rogden
Copy link
Owner

rogden commented Dec 8, 2020

see: #17

The current implementation of the themeReplacements option doesn't work unless you specify the expanded key/value pair. For instance:

module.exports = {
  theme: {
    colors: {
      black: 'var(--color-black)'
    },
    configViewer: {
      themeReplacements: {
        colors: {
          black: '#000000'
        }
      }
    }
  }
}

won't result in the black color having the value of #000000 in the config viewer since we are displaying backgroundColor, textColor and borderColor and the replacement happens after the config is resolved.

In order for this to work correctly you would need to specify the following:

module.exports = {
  theme: {
    colors: {
      black: 'var(--color-black)'
    },
    configViewer: {
      themeReplacements: {
        backgroundColor: {
          black: '#000000'
        },
        borderColor: {
          black: '#000000'
        },
        textColor: {
          black: '#000000'
        }
      }
    }
  }
}

Given that the most common scenario for themeReplacements is to replace css variables that are used for values in your tailwind.config file, the following would be a better implementation:

module.exports = {
  theme: {
    colors: {
      black: 'var(--color-black)'
    },
    configViewer: {
      themeReplacements: {
        'var(--color-black)': '#000000'
      }
    }
  }
}

Then a simple find/replace on the resolved config JSON string will handle the replacements.

Unfortunately this will be a small breaking change.

@rogden rogden added the bug Something isn't working label Dec 8, 2020
@rogden rogden self-assigned this Dec 8, 2020
rogden added a commit that referenced this issue Dec 13, 2020
@rogden rogden closed this as completed Dec 13, 2020
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

No branches or pull requests

1 participant