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

Styled-components and custom css properties #5614

Closed
fcaldera opened this issue Dec 9, 2018 · 1 comment
Closed

Styled-components and custom css properties #5614

fcaldera opened this issue Dec 9, 2018 · 1 comment
Labels
area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:css/scss/less Issues affecting CSS, Less or SCSS lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. priority:high Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent! type:bug Issues identifying ugly output, or a defect in the program

Comments

@fcaldera
Copy link

fcaldera commented Dec 9, 2018

Prettier 1.15.3
Playground link

--parser babylon
--single-quote
--trailing-comma es5

Input:

import React from 'react';
import styled from 'styled-components';
import Card from './Card';

const StyledPurchaseCard = styled(Card)`
  min-width: 200px;
  background-color: var(--${props => props.color});
  color: #fff;
`;

Output:

import React from 'react';
import styled from 'styled-components';
import Card from './Card';

const StyledPurchaseCard = styled(Card)`
  min-width: 200px;
  background-color: var(-- ${props => props.color});
  color: #fff;
`;

Expected behavior:
Prettier should not add a space between the custom property name prefix -- and the template literal placeholder ${props => props.color}. It causes an invalid property value and the style is not applied.

import React from 'react';
import styled from 'styled-components';
import Card from './Card';

const StyledPurchaseCard = styled(Card)`
  min-width: 200px;
  background-color: var(--${props => props.color});
  color: #fff;
`;
@j-f1 j-f1 added area:multiparser Issues with printing one language inside another, like CSS-in-JS lang:css/scss/less Issues affecting CSS, Less or SCSS lang:javascript Issues affecting JS priority:high Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent! type:bug Issues identifying ugly output, or a defect in the program labels Dec 9, 2018
@thorn0
Copy link
Member

thorn0 commented Apr 23, 2020

fixed by #7883

@thorn0 thorn0 closed this as completed Apr 23, 2020
@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 Jul 23, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 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 lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. priority:high Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent! type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

3 participants