cssinjs / styled-jss

Styled Components on top of JSS.
http://cssinjs.org/styled-jss
MIT License
217 stars 25 forks source link

@global is not working #76

Open caub opened 4 years ago

caub commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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

caub commented 4 years ago

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