Decisiv / styled-components-modifiers

A library to enable BEM flavored modifiers (and responsive modifiers) in styled components.
MIT License
297 stars 11 forks source link

Modifiers are sometimes ignored. #19

Closed andrewtpoe closed 5 years ago

andrewtpoe commented 5 years ago

EXPECTED BEHAVIOR

A modifier config should be able to be written like:

  success: () => css`
    background-color: green;
  ` 

When attempting to install this in a new project though, this appeared to not function correctly. This new project uses fresh versions of all applicable packages, including styled components, styled components modifiers, and lodash packages.

ACTUAL BEHAVIOR

The modifier is being completely ignored and it's styles are not applied to the component.

STEPS TO REPRODUCE

Please provide some simple steps to reproduce the issue.

SUGGESTED SOLUTION

Do you have any feedback on how this problem should be solved?

This line checks if the config is an object using the lodash isObject util. In this scenario, the config is an array containing the result of the css util. isObject returns true for arrays, but that gives undefined instead of the styles. We need better validation that the config is actually an object with a styles property.