Easily apply both global and fixture specific background settings for react-cosmos
npm install --save-dev react-cosmos-background-proxy
// cosmos.proxies.js
import createBackgroundProxy from "react-cosmos-background-proxy";
export default [
createBackgroundProxy()
];
// __fixtures__/example.js
export default {
component: MyComponent,
// will apply this style to the <body> element of the fixture iFrame
background: {
backgroundColor: 'white'
}
};
// cosmos.proxies.js
import createBackgroundProxy from "react-cosmos-background-proxy";
export default [
createBackgroundProxy(() => {
// this will be invoked once when the playground is loaded
require('node_modules/some-css-framework/dist/styles.css');
})
];
Contributions are more than welcome! 🍻