Comments (15)
What I meant is that you can do things like:
import styled, { css } from 'styled-components';
const Container = styled.div`
color: red;
${media.desktop(css`color: blue;`)}
${props => props.hasPadding ? css`padding: 20px;` : null}
`
The css
keyword gives the hint to the editor to highlight the template literal.
Not sure if this is still working though, haven't used webstorm in a while.
from webstorm-styled-components.
You should be able to invoke the function returned when calling bp.up
: ${bp.up('m')(css`/.../`)}
from webstorm-styled-components.
Added support for configuring custom methods in 1.0.7.
See README -> Configuration for details and please try it out.
from webstorm-styled-components.
You are amazing....it works perfectly! I have also found another tip....if you paste the snippet in a string literal, Phpstorm will try to escape it, so for example this:
${bp.up('m')`
display: none;
`}
Will become this:
${bp.up('m')\`
justify-content: center;
\`}
To fix this behaviour, you have to use the Menu -> Edit -> Paste Simple
command, or usually Ctrl+Alt+Shift+V
.
from webstorm-styled-components.
This dosen't work?
// Some component
const Example = styled.div`
display: none;
${props => props.theme.desktop(css`
display: block;
`)}
`;
from webstorm-styled-components.
I was also trying to implement this pattern for Media Queries and I stumbled upon this issue. I would love for this plugin to support this type of "nested media queries".
from webstorm-styled-components.
This would be a really nice feature. Currently, in order to enable syntax highlight I have to implement helpers that receive a css
styled object rather than a template literal.
from webstorm-styled-components.
yeah, it would be a cool and useful feature, I'd like to see it in the next release
from webstorm-styled-components.
possibly related to #59 ?
from webstorm-styled-components.
Any updates on this? Also looking for a solution. Would be a nice feature.
from webstorm-styled-components.
@aaccurso can you provide an example of your helper? I am annoyed by this issue :(
from webstorm-styled-components.
Thanks a lot, I have tried right now, that works, but what if I have a function that needs arguments like this? :(
const Container= styled.div`
line-height: 1;
${bp.up('m')`
display: none;
`}
`
from webstorm-styled-components.
My use case is:
// Theme export
export const desktop = (...args) => css`
@media (min-width: 1024px) {
${css(...args)};
}
`;
// Some component
const Example = styled.div`
display: none;
${props => props.theme.desktop`
display: block;
`}
`;
Not sure how this is do-able with css
?
from webstorm-styled-components.
Oh wait that does! I see how that is working now, wasn't clicking before 👍
from webstorm-styled-components.
The css
trick had some bugs for me so I've released a package for enabling highlighting in Webstorm and PhpStorm: https://github.com/microcipcip/styled-components-media-query
from webstorm-styled-components.
Related Issues (20)
- Is there no highlight and prompt when used with tailwind?
- Is there no highlight and prompt when used with tailwind?
- [Feature Request] Show which HTML tag is used
- Problem with media queries HOT 1
- Wrong hex-color format and No auto line-break with Emmet HOT 1
- Indent size is ignored and only works on first line
- Support for xstyled/styled-components
- plugin doesn't work in intellij 2022.3.2 HOT 1
- Feature request: support vars as "value" strings, not just key-value css strings HOT 2
- Selector is never used HOT 1
- \t chapter in copy-pasted code HOT 4
- styled-components-breakpoints support
- [Bug][Typescript] Very slow props suggestions and no value suggestions when when using styled.div syntax
- Pls Fix Webstorm 2020.2 compatibility issue HOT 1
- Re-configure branch protection policy for this repo HOT 2
- String interpolation not being autocompleted
- Issues with parsing & signs HOT 3
- [Feature Request] Refactor to styled component HOT 2
- Webstorm 2020.3 - not working HOT 7
- Highlight var in template string
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webstorm-styled-components.