KittyGiraudel/ama

Convert a hex color variable to a string?

Closed this issue · 3 comments

Hey Hugo, I have a bizarre Sass issue I need some help with.

I'm making a fork of Pattern Lab and am trying to show the color hex values in the library. My current strategy is taking the hex value (in a variable), turning it into a string, and putting that string as a pseudo-element's content that's positioned in the library.

I've tried using the inspect() function to no luck, and frequent google searches led to no other ideas so far about turning a hex value into a string for a pseudo-element. Any ideas about how to accomplish this?

Hey Max.

You are on the right track. inspect(..) does return a string representation of the value. However, the content property expects a quoted string. You only have to use the quote(..) function to make it work.

.foo::after {
  content: quote(inspect($color))
}

Best. :)

Huzzah, it worked! Glad to finally have worked this into my project, thanks!
featured

Lovely. :)