Quantcast
Channel: Using Styled-Map with PolishedJS - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Using Styled-Map with PolishedJS

$
0
0

I have the following Styled-Map object:

export const colorProps = styledMap({
  default: yellow,
  primary: blue,
  secondary: green,
})

I use it as follows in a Styled Component:

const MyComponent = styled.div`
  ...

  background-color: ${colorProps};
  ...
`

This then allows me to use my component as follows:

<MyComponent primary />
<MyComponent secondary />

And it will use the appropriate color value for the background-color.

So far, so good.

But now I would like to use polished to darken the background-color on hover -- something like this:

&:hover {
  background-color: ${darken(0.1, colorProps)};
}

But this does not work. It throws an error.

Error: Passed an incorrect argument to a color function, please pass a string representation of a color.

I am wondering, therefore, if anyone has any ideas on how I can use styled-map in conjunction with polished?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>