question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EmotionContext version mismatch can break `styled.div(css({...`

See original GitHub issue

Describe the bug

The theme references in the import { css } from 'theme-ui' function don’t work on version v0.5.0-alpha.0

It still works in the theme styles, variants, and sx prop.

To Reproduce

  1. Upgrade Theme UI to v0.5.0-alpha.0
  2. Upgrade Emotion to v11
  3. Rename the emotion package names in you codebase
  4. Use the css function from theme-ui in an emotion component
export const StyledHeader = styled.div(
  css({
    // doesn't work
    color: 'primary',
    bg: 'background',
    zIndex: 'nav',
    maxWidth: 'sidebar',
    borderRadius: 'small',

    // works
    px: 4,
  })
)

This code outputs

.StyledHeader {
  color: primary;
  background-color: background;
  z-index: nav;
  max-width: sidebar;
  border-radius: small;
  padding-left: 32px;
  padding-right: 32px;
}

Expected behavior Should output something like

.StyledHeader {
  color: var(--theme-ui-colors-primary, #000000);
  background-color: var(--theme-ui-colors-background, #ffffff);
  z-index: 10;
  max-width: 350px;
  border-radius: 4px;
  padding-left: 32px;
  padding-right: 32px;
}

Screenshots Shot_0 2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
atanasstercommented, Nov 24, 2020

I assumed it’s just keyframes, Global, and styled? I might have missed something.

I think you are right atm, not sure 100%, but who knows in he future. In any case I usually prefer transparent vs ease-of-use in the case of developers as users, assuming they can handle a few more steps. Maybe a good candidate for your polls 😃

1reaction
hasparuscommented, Nov 24, 2020

Ignoring it isn’t so bad. People usually believe it’s their fault, because they didn’t “install properly”, but I think it’s a design flaw on our part. It’s too easy to break in userland.

Another idea:

We’re importing @emotion/react package.json to pass their version as EMOTION_VERSION through context. We could print a huge warning that something went wrong if the version we import doesn’t match (by semver) the version we depend on. Then, after we’ve shown a “disclaimer”, the responsibility is on the user.

I’m not a huge fan of this solution, but it might be practical.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Usage of Theme UI with TypeScript #834 - GitHub
Both theme variable and theme prop are typed as Theme . TBH I have no idea what could cause this, maybe except a...
Read more >
emotional awareness scale: Topics by Science.gov
Our objective is to analyse the relationships that might exist between these states, the level of emotional awareness (capacity for the identification and ......
Read more >
unconscious bias discriminatory - WorldWideScience
This talk will introduce the concept of unconscious bias and also give ... The results suggest that image is the only element able...
Read more >
ACNP 56th Annual Meeting: Poster Session II, December 5 ...
can drive changes in affective behavior (i.e. increases anxiety- ... control in children with ADHD only vs. children with. ADHD+comorbidity vs.
Read more >
(PDF) Speaker Verification Using Short Utterances with DNN ...
This discrepancy could be due to (1) acoustic. mismatch between the WashU-UCLA corpus and the speaker. verification corpora, and (2) only ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found