compiled icon indicating copy to clipboard operation
compiled copied to clipboard

Nested template literals with conditional expressions don't work if the CSS property is defined within the expression

Open pancaspe87 opened this issue 3 years ago • 0 comments

An error is thrown when having nested template literals with conditional expressions where the CSS property is defined within the expression

Given

 ${(props) =>
    props.isPrimary
      ? `
         color: green;
         ${({ isBolded }) => (isBolded ? 'font-weight: bold' :'font-weight: thin')};
       `
     : 'color: red'};

This will throw an error.

Given

 ${(props) =>
    props.isPrimary
      ? `
         color: green;
         font-weight: ${({ isBolded }) => (isBolded ? ' bold' :'thin')};
       `
     : 'color: red'};

This works, but it currently generates a CSS variable instead of classes. Having css variables instead of classes is a known issue and currently under investigation.

Expected outcome Both cases should work and should generate CSS classes

Screenshots image

pancaspe87 avatar Feb 14 '22 01:02 pancaspe87