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

Add isBrowser as a property of sheet so that it can be manually set. #377

Merged
merged 3 commits into from
Oct 4, 2017

Conversation

tkh44
Copy link
Member

@tkh44 tkh44 commented Oct 4, 2017

Why?
You can get get the size of the css output in storybook or any other demo.

const renderedCssSize = (Component = () => <div />) => {
  sheet.isBrowser = false;
  sheet.flush();
  const { css } = extractCritical(() =>
    ReactDOMServer.renderToString(
      <ThemeProvider theme={theme}>
        <Component />
      </ThemeProvider>,
    ),
  );
  sheet.isBrowser = true;
  return css.length;
};

Checklist:

  • Documentation N/A
  • Tests
  • Code complete

Why?
You can get get the size of the css output in storybook or any other demo.
```
const renderedCssSize = (Component = () => <div />) => {
  sheet.isBrowser = false;
  sheet.flush();
  const { css } = extractCritical(() =>
    ReactDOMServer.renderToString(
      <ThemeProvider theme={theme}>
        <Component />
      </ThemeProvider>,
    ),
  );
  sheet.isBrowser = true;
  return css.length;
};
```
@tkh44 tkh44 requested a review from emmatown October 4, 2017 03:03
@codecov
Copy link

codecov bot commented Oct 4, 2017

Codecov Report

Merging #377 into master will not change coverage.
The diff coverage is 100%.

Impacted Files Coverage Δ
packages/emotion/src/sheet.js 84.44% <100%> (ø) ⬆️

@tkh44 tkh44 merged commit 735c986 into master Oct 4, 2017
@tkh44 tkh44 deleted the make-isBrowser-configurable branch October 4, 2017 22:50
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

Successfully merging this pull request may close these issues.

2 participants