matheus23 / elm-tailwind-modules

Generate Elm code for Tailwind Utilities and Components that purges using Elm's dead code elimination!
https://matheus23.github.io/elm-tailwind-modules/
117 stars 12 forks source link

Colors with functional notation produce redundant non-parameterized functions #21

Closed nidico closed 1 year ago

nidico commented 1 year ago

Similar issue as #18, but caused by another color syntax in tailwind config.

CSS colors can be defined in functional notation, e.g. hsl(30deg 100% 50%), see MDN for a variety of possible syntax definitions.

When this syntax is used, elm-tailwind-modules 0.5.0-alpha3 generates the appropriate colors in Tailwind/Theme.elm, but also generates (redundant) functions in Tailwind/Utilities.elm.

In the following example, functions like bg_by_hsl still exist in the generated Tailwind/Utilities.elm, despite color functions like by_hsl being generated in Tailwind/Theme.elm:

module.exports = {
  theme: {
    colors: {
      'by-name': 'rebeccapurple',
      'by-hex': '#00ff00',
      'by-rgb': 'rgb(214, 122, 127)',
      'by-hsl': 'hsl(30, 100%, 50%)',
      'by-hsl-deg': 'hsl(30deg 100% 50%)',    
      'by-hsla': 'hsla(30, 100%, 50%, .3)',
      'by-hwb': 'hwb(1.5708rad 20% 10% / 0.7)',
    },
  },
}
matheus23 commented 1 year ago

Thanks for this. Generally for anyone reading this: Test cases such as the one in this issue are great. I turned it into a failing test in #23, which will make it much easier to fix in the future.

For now I'll have to get back to work :)

matheus23 commented 1 year ago

I've published version 0.5.0-alpha5, which should fix the issue.

nidico commented 1 year ago

Fix confirmed.