'How to change style property value conditionally using PostCSS

I am having a hard time understanding how conditional class property assignment works in PostCSS. I will try to explain my situation through an example. For the record, I am using React.

Let's say that I have a layout component called Group and I am expecting some props to be passed such as align, grow, direction, noWrap. If noWrap prop is passed, then I want to assign nowrap value to my flexWrap. If I was using css-in-js kind of approach, I would have done something like flexWrap: noWrap ? 'nowrap' : 'wrap' but of course, this is not possible with PostCSS.

I wonder if there is a way to accomplish this logic within PostCSS.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source