Created
August 19, 2017 18:11
-
-
Save alp82/94c3277292909db7db264bc287c9ff63 to your computer and use it in GitHub Desktop.
Cosmos Proxy for Glamorous Theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createThemeProviderProxy from './glamorous-theme-provider-proxy'; | |
import { mainTheme } from 'theme/theme'; | |
export default () => { | |
return createThemeProviderProxy({ | |
theme: mainTheme, | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import proxyPropTypes from 'react-cosmos-utils/lib/proxy-prop-types'; | |
import { ThemeProvider } from 'glamorous'; | |
import { mainTheme } from 'theme/theme'; | |
const defaults = { | |
theme: mainTheme, | |
}; | |
export default function createThemeProviderProxy(options) { | |
const { theme } = { ...defaults, ...options }; | |
class ThemeProviderProxy extends React.Component { | |
render() { | |
const { nextProxy, fixture } = this.props; | |
return React.createElement(ThemeProvider, | |
{ theme }, | |
React.createElement(nextProxy.value, { | |
...this.props, | |
nextProxy: nextProxy.next(), | |
fixture, | |
})); | |
} | |
} | |
ThemeProviderProxy.propTypes = proxyPropTypes; | |
return ThemeProviderProxy; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment