{"name":"emotion-theming","version":"10.0.0-really-unsafe-please-do-not-use.2","description":"A CSS-in-JS theming solution, inspired by styled-components","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"types/index.d.ts","scripts":{"test:typescript":"dtslint types"},"repository":{"type":"git","url":"https://github.com/emotion-js/emotion/tree/master/packages/emotion-theming"},"keywords":["react","theme","theming","emotion","cssinjs","css-in-js"],"author":{"name":"styled-components team"},"contributors":[{"name":"Evan Scott","email":"probablyup@gmail.com","url":"https://github.com/probablyup"}],"license":"MIT","bugs":{"url":"https://github.com/emotion-js/emotion/issues"},"homepage":"https://emotion.sh","devDependencies":{"@types/react":"16.0.16","dtslint":"^0.3.0"},"dependencies":{"@emotion/weak-memoize":"^10.0.0-really-unsafe-please-do-not-use.2","hoist-non-react-statics":"^2.3.1"},"peerDependencies":{"@emotion/core":"0.x.x","react":"15.x || 16.x"},"umd:main":"./dist/emotion.umd.min.js","publishConfig":{"tag":"next"},"browser":{"./dist/index.cjs.js":"./dist/index.browser.cjs.js","./dist/index.esm.js":"./dist/index.browser.esm.js"},"gitHead":"0da0de50f6f2c19e46bca7662d1a954d48db1264","_resolved":"","_integrity":"","_from":"file:emotion-theming-10.0.0-really-unsafe-please-do-not-use.2.tgz","readme":"# emotion-theming\n\n> A CSS-in-JS theming solution for React\n\n_`emotion-theming` is a theming library inspired by [styled-components](https://github.com/styled-components/styled-components)_\n\n## Table of Contents\n\n* [Install](#install)\n* [Usage](#usage)\n* [API](#api)\n  * [ThemeProvider](#themeprovider)\n  * [withTheme](#withthemecomponent)\n* [Credits](#credits)\n* [License](#license)\n\n## Install\n\n```bash\n# add --save if using npm@4 or lower\nnpm i emotion-theming\n\n# or\nyarn add emotion-theming\n```\n\n## Usage\n\n### TODO: Add example with the css prop\n\nTheming is accomplished by placing the `ThemeProvider` component, at the top of the React component tree and wrapping descendants with the `withTheme` higher-order component (HOC). This HOC seamlessly acquires the current theme and injects it as a \"prop\" into your own component.\n\nThe theme prop is automatically injected into components created with `styled`.\n\nHere is a complete example for a typical React + Emotion app (information about each piece of the theming API is listed afterward):\n\n```jsx\n/** child.js */\nimport React from 'react'\nimport styled from 'react-emotion'\n\nconst Container = styled.div`\n  background: whitesmoke;\n  height: 100vh;\n`\n\nconst Headline = styled.h1`\n  color: ${props => props.theme.color};\n  font: 20px/1.5 sans-serif;\n`\n\nexport default class Page extends React.Component {\n  render() {\n    return (\n      <Container>\n        <Headline>I'm red!</Headline>\n      </Container>\n    )\n  }\n}\n\n/** parent.js */\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport { ThemeProvider } from 'emotion-theming'\n\nimport Page from './child.js'\n\nconst theme = {\n  color: 'red'\n}\n\nclass App extends React.Component {\n  render() {\n    return (\n      <ThemeProvider theme={theme}>\n        <Page />\n      </ThemeProvider>\n    )\n  }\n}\n\n// this assumes the HTML page template has a <main> element already inside <body>\nReactDOM.render(<App />, document.querySelector('main'))\n```\n\n`<ThemeProvider>` acts as a conductor in the component hierarchy and themed components receive the `theme` for whatever purposes are necessary, be it styling or perhaps toggling a piece of functionality.\n\n## API\n\n### ThemeProvider: React.ComponentType\n\nA React component that passes the theme object down the component tree via [context](https://reactjs.org/docs/context.html). Additional `<ThemeProvider>` wrappers may be added deeper in the hierarchy to override the original theme. The theme object will be merged into its ancestor as if by [`Object.assign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign). If a function is passed instead of an object it will be called with the ancestor theme and the result will be the new theme.\n\n_Accepts:_\n\n* **`children`: ReactComponent** - A single React component.\n* **`theme`: Object|Function** - An object or function that provides an object.\n\n```jsx\nimport React from 'react'\nimport styled from 'react-emotion'\nimport { ThemeProvider, withTheme } from 'emotion-theming'\n\n// object-style theme\n\nconst theme = {\n  backgroundColor: 'green',\n  color: 'red'\n}\n\n// function-style theme; note that if multiple <ThemeProvider> are used,\n// the parent theme will be passed as a function argument\n\nconst adjustedTheme = ancestorTheme => ({ ...ancestorTheme, color: 'blue' })\n\nclass Container extends React.Component {\n  render() {\n    return (\n      <ThemeProvider theme={theme}>\n        <ThemeProvider theme={adjustedTheme}>\n          <Text>Boom shaka laka!</Text>\n        </ThemeProvider>\n      </ThemeProvider>\n    )\n  }\n}\n\nconst Text = styled.div`\n  background-color: ${props => props.theme.backgroundColor}; // will be green\n  color: ${props => props.theme.color}; // will be blue\n`\n```\n\n### withTheme(component: React.ComponentType): React.ComponentType\n\nA higher-order component that provides the current theme as a prop to the wrapped child and listens for changes. If the theme is updated, the child component will be re-rendered accordingly.\n\n```jsx\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { withTheme } from 'emotion-theming'\n\nclass TellMeTheColor extends React.Component {\n  render() {\n    return <div>The color is {this.props.theme.color}.</div>\n  }\n}\n\nTellMeTheColor.propTypes = {\n  theme: PropTypes.shape({\n    color: PropTypes.string\n  })\n}\n\nconst TellMeTheColorWithTheme = withTheme(TellMeTheColor)\n```\n\n## Credits\n\nThanks goes to the [styled-components team](https://github.com/styled-components/styled-components) and [their contributors](https://github.com/styled-components/styled-components/graphs/contributors) who originally wrote this.\n\n## License\n\nMIT 2017-present\n","readmeFilename":"README.md","_id":"emotion-theming@10.0.0-really-unsafe-please-do-not-use.2","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"mitchellhamilton","email":"mitchell@mitchellhamilton.me"},"dist":{"integrity":"sha512-xgcvCmw5xKi4MQQqnRzxDqPeAlKkZl9oQRVAIeHcGeY4JIPY/KKwu4/wgLf0kBNxxHyP8sxpO6sLd8LhrcL5OA==","shasum":"d33b3e73f7b2fec28efab0103f6cb0c99b9ea026","tarball":"http://registry-npm.ywwl.com/emotion-theming/download/emotion-theming-10.0.0-really-unsafe-please-do-not-use.2.tgz","fileCount":19,"unpackedSize":35647,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbra//CRA9TVsSAnZWagAAHxcP/3+ds2kDFGuVelcFA0UJ\nURrdSCisx6Ky6R0oCFZL6IQ7FQwLvJFngIQzjMoghg1Jm3QVlf8zkVSVekfs\nFijd/FjR25hKCcmJBMPhm1xs8b1Ixj4TTvLCLV83fr5XCX9srqFtYUjUREi9\nP14uOa+KE7w7ZPeXnu1omgOjzZQ/N42mNYNkOqj4T4+4MAmaYwVCZouqbPlp\nr2MKkJS9Y4EqW5Yqn9f98Vft/TIRh9hOE0kRVqght9+QgNIY/IJ83OgEOoeW\n7jxXyB0UeIoK1dMxnn7mNddVyJidorEoIrGydOAE7ErSJX6kARyyXkBJxTVq\npDKbW/snBKu0mu/FKHtqlxk9qyvmzcPKeaYJsW6XDxVxDbKNWjrwOeXIKXi+\n08XxnGc61Q+J6SFODPTOddlak4SUXlvNkLrAqtsA9kLYOYSX/8gJVenv0yh7\nE2CZ3NtFWifk5FJJyHGVIdrtMwhtyRzE19nSvUltHOEewGLHj9jsz2b/8+Id\nBywGNMTYBrJGvOfirJ/RZHmCuYWEoCd2mCsq41meS13uZ7e78jM7gF+ahG2p\n6RhUAHz68o/HZrSIICiYSmeNOEz6xfDn0SfVZ1YVQ/XFbM7N4RiBHqy6mj42\n2onuXWwiYosk6qw3cX3WB1bnjEh2iqzHId0aBLoxd89h4VaXZ7nii+VJh335\n7XES\r\n=7qo0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCTmApTtichmPTc6IbLvn18XMQcbcGhaWiTgw1aMvNRFgIgAts4gZmHFzpZ5SGRW0jS/QP2GIz+h+dkeFaZeP8mqxU="}],"size":9532,"noattachment":false,"key":"/emotion-theming/-/emotion-theming-10.0.0-really-unsafe-please-do-not-use.2.tgz"},"maintainers":[{"name":"mitchellhamilton","email":"mitchell@mitchellhamilton.me"},{"name":"tkh44","email":"kye.hohenberger@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/emotion-theming_10.0.0-really-unsafe-please-do-not-use.2_1538109438931_0.6147039114331478"},"_hasShrinkwrap":false,"publish_time":1538109439129,"_cnpm_publish_time":1538109439129,"dist-tags":{"latest":"11.0.0","next":"11.0.0-next.6","rc":"11.0.0-rc.0","ten":"10.3.0"}}