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

Css variable in styled-components breaks because of the extra space in a template string. #7207

Closed
shermendev opened this issue Dec 30, 2019 · 7 comments
Labels
area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:css/scss/less Issues affecting CSS, Less or SCSS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@shermendev
Copy link

Prettier 1.19.1
Playground link

--parser babel

Input:

styled.div`color: var(--${color});`

Output:

styled.div`
  color: var(-- ${color});
`;

Expected behavior:
var(--${color}) to be without a space after -- as it breaks the css.

Any way to work around or disable it?

@alexander-akait alexander-akait added type:bug Issues identifying ugly output, or a defect in the program area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:css/scss/less Issues affecting CSS, Less or SCSS labels Dec 30, 2019
@fisker
Copy link
Sponsor Member

fisker commented Jan 30, 2020

#6794 should be able to fix this

vitordino pushed a commit to vitordino/v3.vitordino.com that referenced this issue Mar 9, 2020
vitordino pushed a commit to vitordino/v3.vitordino.com that referenced this issue Mar 9, 2020
@thorn0
Copy link
Member

thorn0 commented Apr 23, 2020

fixed by #7883

@thorn0 thorn0 closed this as completed Apr 23, 2020
@glandre
Copy link

glandre commented Jun 30, 2020

Hi @thorn0 and @fisker, I am currently using 2.0.5 and this still happens...
What are the steps to fix this behaviour?

@thorn0
Copy link
Member

thorn0 commented Jul 1, 2020

@glandre The bug reported in this issue has been fixed. I'm not able to reproduce it with 2.0.5. If you can reproduce your problem on the Playground, please use the Report issue button there to open a new bug report.

@glandre
Copy link

glandre commented Jul 1, 2020

@thorn0, thank you for your reply. Maybe there's something else in my configuration that is getting in the way...

One point to notice is that I'm using TypeScript.

Take a look at this Codesandbox: https://codesandbox.io/s/elastic-colden-kvyzm?file=/src/App.tsx
It has prettier by default.

Notice the extra space after -radius-

Let me know if it's just some missing configuration, or if I should go ahead and open a new issue.

Thank you again for your help.

@thorn0
Copy link
Member

thorn0 commented Jul 2, 2020

@glandre That's a different bug, fixed by #8255 but not yet released.

@glandre
Copy link

glandre commented Jul 4, 2020

Great!
When is the next release to be expected?
thank you @thorn0!

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Oct 3, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:css/scss/less Issues affecting CSS, Less or SCSS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

5 participants