vscode-styled-components icon indicating copy to clipboard operation
vscode-styled-components copied to clipboard

Highlighting doesn't work when wrapping the result of a function

Open ariamckinley opened this issue 7 years ago • 6 comments

This is an extremely obscure edge case, as I'm sure hardly anybody has had a need to do this. But I'm in the middle of writing a library and have a line which looks like this

const Bounds = styled(Stylable("div"))`
  box-sizing: border-box;
  display: flex;
`;

and the highlighting does not work. If I remove the ("div") it works.

I'm a bit busy atm (otherwise I'd fix it now), but tomorrow or sometime later this week I'll try and fix this issue. Just wanted to open an issue so that there's a documented record of it.

ariamckinley avatar Aug 26 '18 13:08 ariamckinley

Don't know if it's related, but also it does not work when specifying the props type (Typescript)

const Button = styled.a<{ first?: boolean }>`
  padding: 15px 50px;
  margin-right: ${p => p.first ? '50px' : '0'};
`;

Although, it works correctly when defining them inline for the function parameter:

interface IButtonProps {
  first?: boolean;
}

const Button = styled.a`
  padding: 15px 50px;
  margin-right: ${(p: IButtonProps) => p.first ? '50px' : '0'};
`;

patrikmolsson avatar Aug 29 '18 09:08 patrikmolsson

@patrikmolsson you should open a separate issue for that, unfortunately not related to this one.

ariamckinley avatar Aug 30 '18 02:08 ariamckinley

I see this issue when using a library like Poser with styled-components.

This code will not be seen as a styled component:

const AnimatedComponent = styled(posed.div({
  open: {},
  closed: {}
}))`
  width: 300px;
  ...
`

But the inverse does work:

const AnimatedComponent= posed(styled.div`
  width: 300px;
  ...
`)({
  open: {...},
  closed: {...}
});

radlantern avatar Dec 05 '18 02:12 radlantern

I confirm the same thing here, example :

capture d ecran 2018-12-05 a 12 29 16

Do you this can be fixed ? Would be amazing :) thanks

pixelize avatar Dec 05 '18 11:12 pixelize

@garetmckinley @radlantern Do you know how to activate emmet tab completion in VSCODE when you use CSS in the result of the function please ?

pixelize avatar Dec 05 '18 11:12 pixelize

I confirm the same thing here, example :

capture d ecran 2018-12-05 a 12 29 16

Do you this can be fixed ? Would be amazing :) thanks

screenshot 03-05-2019 22h13m08s I can reproduce this as well

maxijonson avatar Mar 06 '19 03:03 maxijonson