rogden / tailwind-config-viewer

A local UI tool for visualizing your Tailwind CSS configuration file.
2.01k stars 111 forks source link

Support for variables from: root #11

Closed afuno closed 4 years ago

afuno commented 4 years ago

I noticed that now there is a problem if variables were declared, for example, in ':root'. Is there any solution for this problem now?

Снимок экрана 2020-08-28 в 00 31 06
rogden commented 4 years ago

This is an interesting use case. The config viewer doesn't load your compiled CSS file so it wouldn't have access to your CSS variables by default. One possible solution: I could add support for overrides/customization of the config viewer from your Tailwind config file. Example:

// in your tailwind.config.js file
module.exports = {
  theme: {
    // ... your theme config
    configViewer: {
      cssColorVars: {
        'var(--color-black)': '#000000',
        'var(--color-white)': '#ffffff',
        // ...other colors vars
      }
    }
  }
}

What do you think? Also, are you using CSS vars for theming? If so, this would only solve for your default/::root color vars.

rogden commented 4 years ago

@afuno I added the ability to replace values from your theme when used in the config viewer. This should solve your issue with the CSS variables. See: https://github.com/rogden/tailwind-config-viewer#themereplacements

afuno commented 4 years ago

@rogden Thanks. Everything is successful.

kissu commented 3 years ago

If we do have an .scss file containing

:root {
  --color-dark-500: hsl(0, 0%, 21%);
  --color-white: hsl(0, 0%, 100%);
  ...
 }

It means that we pretty much need to copy-pasta the style file to the tailwind config, one by one ? 😖

solidevolution commented 2 years ago

This should work without duplication in js because single source of truth are the css variables in :root

mokone91 commented 1 year ago

but how can i connect my 'tokens.css' to theme-viewer without parsing it to replacements?

2manoj1 commented 10 months ago

Have a look, How I did https://github.com/2manoj1/tailwind-default-config-viewer/blob/736b892120c919dbf4a9ed2a2115c9e4224ec510/tailwind.config.js#L5

https://github.com/2manoj1/tailwind-default-config-viewer/blob/main/utils/convert.js