-
Notifications
You must be signed in to change notification settings - Fork 81
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: withComponent().extend doesn't match grammar #400
Comments
I won't be able to fix this. I already make too many assumptions such as a classname such as Flex followed by
or the suggestion I made here |
I'd have thought just looking for
would be a sensible enough assumption. But fair enough if you don't like this idea. (Also I have no idea how difficult it is to mess with these grammars other than whenever I look at them my brain starts melting, so I do fully appreciate if the "simple suggestion" above isn't so simple!) |
Yes but .extend could be a method (tagged template) for another library. Styled-components doesn't have exclusive access to this. so maybe
This isn't SC but I have no way of knowing that by just using regex parsing grammars. Even in a single file AST this may not be possible if styled was imported from another file. At the moment, I give SC the benefit of the doubt and parse the above as CSS but If another library were to use |
Oh I totally get that, but I guess it's just a case of going with what's the most likely/popular. Which, I guess, as you say, you are already doing (for now). Any chance of hooking into:
? That'd match the use-case presented here, and is actually more SC-specific than simply looking for |
Let me think about it. I'm a bit reluctant as it's non-standard JS. I originally supported SC V1 as I like CSS-in-JS but V2 added complexity to the API that isn't really suited to Regex grammar API's |
Just pushed a commit. If you want to try apm install from this repo then it should work. |
Yup that works. Thanks. I do understand your reluctance to support the more esoteric syntax but this looks good to me. |
When
.extend
with a template literal is chained afterwithComponent()
, the grammar fails to match the template literal as Styled Components CSS.Given the following Styled Components JS:
The following is produced for the One Dark theme:
More annoying than the lack of syntax highlighting is autocomplete for CSS properties and values inside the template literal.
The text was updated successfully, but these errors were encountered: