-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Styled-components and custom css properties #5614
Copy link
Copy link
Closed
Labels
area:multiparserIssues with printing one language inside another, like CSS-in-JSIssues with printing one language inside another, like CSS-in-JSlang:css/scss/lessIssues affecting CSS, Less or SCSSIssues affecting CSS, Less or SCSSlang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!
Description
Prettier 1.15.3
Playground link
--parser babylon
--single-quote
--trailing-comma es5Input:
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;
`;Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:multiparserIssues with printing one language inside another, like CSS-in-JSIssues with printing one language inside another, like CSS-in-JSlang:css/scss/lessIssues affecting CSS, Less or SCSSIssues affecting CSS, Less or SCSSlang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!