styless icon indicating copy to clipboard operation
styless copied to clipboard

Guards Not Working With Strings

Open daniel-nagy opened this issue 5 years ago • 2 comments

& when (@variant = "secondary") {
  background-color: @btnSecondaryBgColor;
  border-color: @btnSecondaryBorderColor;
  color: @btnSecondaryColor;
}

This guard is always entered, even when props.variant is not equal to secondary.

daniel-nagy avatar Jan 13 '20 03:01 daniel-nagy

Thanks for reporting this issue, I believe we have limited support for guards. Could you add the complete example with the React component and I will try it.

Thanks,

jean343 avatar Jan 13 '20 03:01 jean343

A workaround is to use the styled syntax

${props => props.variant === "secondary" && css`
  background-color: @btnSecondaryBgColor;
  border-color: @btnSecondaryBorderColor;
  color: @btnSecondaryColor;
`}

jean343 avatar Jan 13 '20 21:01 jean343