Skip to content

Commit

Permalink
Make checkStyles a no-op in production
Browse files Browse the repository at this point in the history
  • Loading branch information
brendancarney authored and ryanflorence committed Sep 4, 2018
1 parent 47aff3e commit 9c5cc47
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions packages/utils/src/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
let checkedPkgs = {};

export let checkStyles = pkg => {
// only check once per package
if (checkedPkgs[pkg]) return;
checkedPkgs[pkg] = true;

if (
parseInt(
window.getComputedStyle(document.body).getPropertyValue(`--reach-${pkg}`),
10
) !== 1
) {
console.warn(
`@reach/${pkg} styles not found. If you are using a bundler like webpack or parcel include this in the entry file of your app before any of your own styles:
let checkStyles = () => {};

if (__DEV__) {
checkStyles = pkg => {
if (!__DEV__) return;
// only check once per package
if (checkedPkgs[pkg]) return;
checkedPkgs[pkg] = true;

if (
parseInt(
window
.getComputedStyle(document.body)
.getPropertyValue(`--reach-${pkg}`),
10
) !== 1
) {
console.warn(
`@reach/${pkg} styles not found. If you are using a bundler like webpack or parcel include this in the entry file of your app before any of your own styles:
import "@reach/${pkg}/styles.css";
Expand All @@ -22,9 +28,12 @@ export let checkStyles = pkg => {
For more information visit https://ui.reach.tech/styling.
`
);
}
};
);
}
};
}

export { checkStyles };

export let wrapEvent = (handler, cb) => event => {
handler && handler(event);
Expand Down

0 comments on commit 9c5cc47

Please sign in to comment.