Skip to content
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

Support emotion css`` literal #30

Open
albinekb opened this issue Jun 3, 2019 · 4 comments
Open

Support emotion css`` literal #30

albinekb opened this issue Jun 3, 2019 · 4 comments

Comments

@albinekb
Copy link

albinekb commented Jun 3, 2019

Is your feature request related to a problem? Please describe.
It would be nice to support the css literal from emotion.sh

Describe the solution you'd like
Using syntax:

const styles = css`
	background: red;
`

Additional context
Similar to styled.div css works by creating a className for your styles.
Read more about emotion css here: https://emotion.sh/docs/css-prop

@Raathigesh Raathigesh added the ❔ Question Further information is requested label Jun 4, 2019
@Raathigesh
Copy link
Owner

I just tested this and it seems to work. What exactly are you seeing in the side-panel when you place the cursor in the template literal?

@albinekb
Copy link
Author

albinekb commented Jun 4, 2019

Ah! It does work, but not everywhere, only on styles declared at the root level of the file.

This component does not work:

const LabelValue = ({ label, value }) => (
  <div
    css={css`
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: flex-start;
      padding: 20px 30px;
      span {
        width: 150px;
      }
      b {
        font-weight: bold;
      }
    `}
  >
    <span>{label}</span>
    <b>{value}</b>
  </div>
)

This does work:

const labelValueStyles = css`
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: flex-start;
      padding: 20px 30px;
      span {
        width: 150px;
      }
      b {
        font-weight: bold;
      }
    `

const LabelValue = ({ label, value }) => (
  <div css={labelValueStyles}>
    <span>{label}</span>
    <b>{value}</b>
  </div>
)

@Raathigesh
Copy link
Owner

Thanks for the details. I'll have a look.

@Raathigesh Raathigesh removed the ❔ Question Further information is requested label Jun 4, 2019
@paustint
Copy link
Collaborator

paustint commented Jun 9, 2019

@Raathigesh - just for information, I tested this out while reviewing PR #32, and it looks like we might need some special handling based on the type of the parent element, as there is not an id with TaggedTemplateExpression elements.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants