Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] Missing spread for interpolations #26

Open
patibugaj opened this issue May 30, 2020 · 3 comments
Open

[v3] Missing spread for interpolations #26

patibugaj opened this issue May 30, 2020 · 3 comments

Comments

@patibugaj
Copy link

patibugaj commented May 30, 2020

I've noticed that template literal doesn't work properly with the breakpoint method.

My source code, that leads me to the problem:

 ${breakpoint('md')`
    &:hover {
      color: ${({ theme }) => theme.colors.green};
      background-color: ${({ theme }) => theme.colors.darkGrey_2};
    }  
  `};

As a result, the dynamic values are concatenated into one string.
Dev tools result:
image

Probably the issue is caused by missing spread operator on interpolations here:

)(breakpointA, breakpointB)(strings, interpolations);

@patibugaj patibugaj changed the title [v3] Missing spread for interpolation argument [v3] Missing spread for interpolations May 30, 2020
@dcorb
Copy link

dcorb commented Jun 9, 2020

It seems a similar bug, and similar fix (missing spread operator) happened before

9b0819c

@sprad
Copy link

sprad commented Jul 9, 2020

@patibugaj Not a great solution, but as a temporary workaround until the bug is fixed, you can define multiple breakpoint blocks at the same screen size for each of your dynamic template items. For example, the following code should work:

 ${breakpoint('md')`
    &:hover {
      color: ${({ theme }) => theme.colors.green};
    }  
`};

 ${breakpoint('md')`
    &:hover {
      background-color: ${({ theme }) => theme.colors.darkGrey_2};
    }  
`};

@leads
Copy link

leads commented Oct 4, 2022

Confirming this is still a bug.

I have switched to this approach: https://jsramblings.com/how-to-use-media-queries-with-styled-components/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants