Coder Social home page Coder Social logo

Comments (15)

aaccurso avatar aaccurso commented on May 27, 2024 2

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.

aaccurso avatar aaccurso commented on May 27, 2024 2

You should be able to invoke the function returned when calling bp.up: ${bp.up('m')(css`/.../`)}

from webstorm-styled-components.

undeadcat avatar undeadcat commented on May 27, 2024 2

Added support for configuring custom methods in 1.0.7.
See README -> Configuration for details and please try it out.

from webstorm-styled-components.

microcipcip avatar microcipcip commented on May 27, 2024 1

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.

microcipcip avatar microcipcip commented on May 27, 2024 1

This dosen't work?

// Some component
const Example = styled.div`
  display: none;
  ${props => props.theme.desktop(css`
    display: block;
  `)}
`;

from webstorm-styled-components.

fpoumian avatar fpoumian commented on May 27, 2024

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.

aaccurso avatar aaccurso commented on May 27, 2024

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.

SilencerWeb avatar SilencerWeb commented on May 27, 2024

yeah, it would be a cool and useful feature, I'd like to see it in the next release

from webstorm-styled-components.

jlee1201 avatar jlee1201 commented on May 27, 2024

possibly related to #59 ?

from webstorm-styled-components.

jChris85 avatar jChris85 commented on May 27, 2024

Any updates on this? Also looking for a solution. Would be a nice feature.

from webstorm-styled-components.

microcipcip avatar microcipcip commented on May 27, 2024

@aaccurso can you provide an example of your helper? I am annoyed by this issue :(

from webstorm-styled-components.

microcipcip avatar microcipcip commented on May 27, 2024

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.

Ehesp avatar Ehesp commented on May 27, 2024

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.

Ehesp avatar Ehesp commented on May 27, 2024

Oh wait that does! I see how that is working now, wasn't clicking before 👍

from webstorm-styled-components.

microcipcip avatar microcipcip commented on May 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.