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

@global is not working #76

Open
caub opened this issue Dec 2, 2019 · 4 comments
Open

@global is not working #76

caub opened this issue Dec 2, 2019 · 4 comments

Comments

@caub
Copy link

caub commented Dec 2, 2019

demo: https://codesandbox.io/s/async-sky-5xyhv

body doesn't have a lightblue background as expected

import React from "react";
import ReactDOM from "react-dom";

import styled from 'styled-jss';

function App(props) {
  return (
    <div {...props}>
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
    </div>
  );
}


const StyledApp = styled(App)({
  border: '1px solid red',
  '@global': {
    body: {
      backgroundColor: 'lightblue'
    }
  }
})

const rootElement = document.getElementById("root");
ReactDOM.render(<StyledApp />, rootElement);

styled-jss: 2.2.3

@caub
Copy link
Author

caub commented Dec 2, 2019

@lttb Excuse me to ping you directly, as you're a maintainer, do you have an idea for this issue?

styled-jss uses jss-preset-default which itself uses jss-plugin-global https://github.com/cssinjs/jss/blob/master/packages/jss-preset-default/src/index.js#L25

So I wonder what makes things break, maybe updating dependencies will fix this issue

Thanks

@HenriBeck
Copy link
Member

Screenshot 2019-12-02 at 16 55 58

See the second css rule object. It creates a local selector with body as a children selector.

@caub
Copy link
Author

caub commented Dec 2, 2019

Ah yes indeed, thanks
is it expected or a bug?

@caub
Copy link
Author

caub commented Dec 22, 2019

@HenriBeck do you want me to try to push a fix or is it an intended behavior (I don't think so)?

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

2 participants