#Really weird bug I can't reproduce in a fresh project

1 messages · Page 1 of 1 (latest)

humble whale
#

There must be something I am missing, or else this specific gleam file is haunted.

If I create the css using the function add_colour (I've boiled the functions down to the minimum possible functionality for ease)

the css doesn't apply and the background stays the default colour, if I hand write the same string though the css is applied and the background colour changes.

I've double checked that the issue isn't some weird characters that look the same but aren't, (I assume converting to a bit array and checking all the bits are the same should do it?)

But
if I leave the hand written string commented out the background changes colour.

However
if I then delete the comment the background colour stops applying again.

Do I need an exorcist or am I just missing something really obvious here?

turbid flint
#

the tailwind compiler extracts class names and generates the stylesheet based on the classes you use
you have to write the entire class name verbatim for it to work

humble whale
#

Odd, the other functions that I use to build css are fine though, it's just this one

turbid flint
#

if the class name is contained within a comment, the tailwind compiler still sees it, so that will still work

humble whale
#

Ah, so the tailwind in the other parts of my code might be "carrying" the functions

#

And then if I kept going with moving stuff out to functions they'd break eventually?

turbid flint
#

yeah so basically whenever you want to use a class, that class has to exist in its entirety within the source code, you can't do things like "bg-[" <> rgb <> "]" for example

#

you can do case color { Primary -> "bg-[#2f2f2f]" } though, that would work

humble whale
#

So as long as I don't break up the classes themselves all should be good

#

Thank you ❤️