Skip to content

Instantly share code, notes, and snippets.

@alp82
Created August 19, 2017 18:11
Show Gist options
  • Save alp82/94c3277292909db7db264bc287c9ff63 to your computer and use it in GitHub Desktop.
Save alp82/94c3277292909db7db264bc287c9ff63 to your computer and use it in GitHub Desktop.
Cosmos Proxy for Glamorous Theme
import createThemeProviderProxy from './glamorous-theme-provider-proxy';
import { mainTheme } from 'theme/theme';
export default () => {
return createThemeProviderProxy({
theme: mainTheme,
});
};
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