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

Highlighting breaks after props and css`` function usage #425

Open
andre-lergier opened this issue May 4, 2023 · 3 comments
Open

Highlighting breaks after props and css`` function usage #425

andre-lergier opened this issue May 4, 2023 · 3 comments
Labels

Comments

@andre-lergier
Copy link

After the usage of styling within css function (ThemedCssFunction) the syntax highlighting breaks.

Here an example with a simple Text component for a Typescript Next.js application.

Correct Highlighting:
image

Highlighting after prop based css`` styling:
image

Here's the code to copy:

import styled, { css } from 'styled-components';

export interface TextProps {
  children: React.ReactNode;
  as?: 'p' | 'span';
  dark?: boolean;
}

export const StyledText = styled.p<TextProps>`
  line-height: 1.7;

  &:last-of-type {
    margin-bottom: 0;
  }

  ${({ dark }) =>
    dark &&
    css`
      color: black;
    `}
`;

export function Text({ children, as = 'p', dark = false }: TextProps) {
  return (
    <div>
      <StyledText as={as} dark={dark}>
        {children}
        <span>Test</span>
      </StyledText>
    </div>
  );
}

If I use an inline syntax, the highlighting still works.
In situations where you have multiple css rules to apply based on a prop I prefer using the css`` block.
image


Environment:

  • OS: macOS Ventura 13.3.1
  • VSCode Version: 1.77.3
  • Extension Version: 5.3.10
  • Typescript Version: 5.0.4
@Vladyslav-Yamko
Copy link

Has it been fixed or found work around (except deleting css before quotes)?

@GuskiS
Copy link

GuskiS commented Jul 6, 2023

Doing something like this:

  ${({ dark }) =>
    dark &&
    css`
      color: black;
    `}
    /* comment fixes highlight below */

@carlos-algms
Copy link

Not only for css but any instance that contains TypeScript props will break all the highlighting.
image
And this goes all the way to the end of the file.

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

No branches or pull requests

4 participants