Skip to content

Problems with syntax highlight when using css #23

Open
@present-g

Description

@present-g

When using css, the syntax highlighting breaks.

Example code:

const StylesWithCss = css`
  margin: 0;
  background: red;

  & > * {
    /* valid highlight */
    margin: 10px;
  }
`;

const StylesWithTopLevel = styled.div<{ $margin?: string; $isActive: boolean | undefined }>(
  ({ $margin, $isActive }) => css`
    display: flex;
    flex-direction: column;
    margin: ${$margin};
    width: 100%;
    overflow: hidden;
    position: relative;

    ${$isActive
      ? css`
          margin: 0;
          background: red;
        `
      : ''}
  `
);

const StylesWithCondition = styled.div<{ $isActive: boolean | undefined }>`
  /* valid highlight */
  overflow-x: auto;
  scroll-snap-type: x mandatory;

  ${({ $isActive }) =>
    $isActive
      ? css`
          overflow-x: unset;
          scroll-snap-type: unset;
        `
      : ''}
`;

Screenshot from VSCode:

Screenshot from VSCode

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @present-g

        Issue actions

          Problems with syntax highlight when using `css` · Issue #23 · styled-components/typescript-styled-plugin