styled-components / webstorm-styled-components

styled-components highlighting support in IntelliJ editors
https://plugins.jetbrains.com/plugin/9997-styled-components
MIT License
375 stars 19 forks source link

any plans css support? #19

Closed satispunk closed 7 years ago

satispunk commented 7 years ago

css is not yet supported?

impot {css} from 'styled-components'

const styles = css`
  color: red
`
undeadcat commented 7 years ago

What result are you experiencing? It was intended to be supported. But I see now that your sample has invalid red code highlights. image

This is because it currently assumes the string to contain a complete declaration.

Could any of the styled-components experts, perhaps @daedlock, since you reviewed my PR when we added initial support clarify: is css`` intended to be used for whole css declarations, including selectors?

const styles2 = css`
div {
    color: red
}
another {
    margin:5px
}
`

or sets of properties?

const styles = css`
  color: red

IIRC correctly I've seen both kinds of usages? Depending on that there either should or should not be a prefix/suffix added to the injected text.

daedlock commented 7 years ago

Yes, AFAIK, css and injectGlobal selectors should contain complete declaration as . Please confirm @mxstbr

mxstbr commented 7 years ago

Not quite true. css is used like styled.x:

const styleFragment = css`
  color: blue;
`

const Button = styled.div`
  background: red;
  ${styleFragment}
`

That is the most widely used usage.

Note though that both can (but don't have to!) also contain full CSS declarations for nesting:

const styleFragment = css`
  color: blue;

  // Any div within a component that has this style fragment will be red
  div {
    color: red;
  }
`

const Button = styled.div`
  background: red;
  ${styleFragment}

  // Any span within this button will be blue
  span {
    background: blue;
  }
`

(excuse the nonsensical example)

undeadcat commented 7 years ago

Ok, thanks, I assumed it was expected to contain a complete declaration and was wrong. Created a PR to fix this