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

fix: theme override replace logic #17

Closed

Conversation

mauliksoni110
Copy link

@mauliksoni110 mauliksoni110 commented Dec 8, 2020

@rogden I think we will need to apply the override replacement logic before we use the resolveTailwindConfig.
So that it applies to all the borderColor, backgroundColor, etc

@rogden
Copy link
Owner

rogden commented Dec 8, 2020

Thanks for highlighting the issue and the PR! I need to rethink the approach to handle the theme replacements. With your fix, it will operate on the object returned from the tailwind.config file. This makes sense as it will be parsed for replacements before it is resolved by Tailwind and values such as colors are copied to backgroundColor, textColor etc. However, it will get complicated as config values can be nested under extends, at the top level of the theme object, and functions i.e. fill: theme => theme('colors'). My hunch is a to do a simple find/replace for the replacement string in the resolved JSON. Instead of:

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

The new format would be

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

And the logic will be updated to a simple string find/replace on the resolved JSON.

"lint": "vue-cli-service lint",
"test": "echo \"No test specified\"",
"version": "npm run build:docs && git add docs"
"version": "npm run build:docs && git add docs",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mauliksoni110 Hey. What was the issue/bug that this commit fixes?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rogden that was something I was trying to install the repo locally from Github.
I see that you have updated the logic in the latest release(s), thanks!
We can disregard this PR.

@rogden rogden closed this Dec 21, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants