{"bugs":{"url":"https://github.com/emotion-js/emotion/issues"},"dist":{"shasum":"e10994048d5c937ba98a12e240d6bc88122231ef","tarball":"https://registry.npmjs.org/emotion-theming/-/emotion-theming-10.0.0-beta.0.tgz","fileCount":19,"integrity":"sha512-T8IZaS5EzUvYXKY9awr2OFm529cdLaBCjw90qMHDvxjOYKRNRuNaMCMWwsF3ghHcPXZ7UHcpqYKTI55rQkRAGw==","signatures":[{"sig":"MEUCIFArs6xdOybfnCT8yEhgL2ZOs+OtecoJU5GcqbwCrvixAiEAky4SU9FvQrnNcq6QabgpoEyPZ03xQDx8+YRX8I4GnWI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34405,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbwaAsCRA9TVsSAnZWagAAdooP/0BBOaBqBgdSSYKPKdOw\nIUBdkcW0fEZlRTuwn2QsXu38s7e/xeyapTI0FHSu2Kl9SXGV4VOpbwtig6qh\nmW+4p+gnbtojLknGLZGKSfMyNeCD1Ah4epQXuEiI9y7TpsRKhZp/X2KX1drk\n7Ne5fgIAlRlm/wmTBBevJ2ec5x7vgchvz7i7usiMOC16zb4OI7Q6DiGE6JFL\n4erSsFTmelvo0CSc67TDX9rRoWCidp4FS21fFFLBoPJFEaWRZM/S3/Q+GpJ7\n7Mobh+I0X4dJrvSqKXkwQk+h/r5ca7oViY2UUEcvSsOLJCUvpyWLuc0ECCY5\nGxo8nnAMs+aPnvzMc4md4Ou83mJtFBsknY0rnczT7+wlBmh9bGu19nAtcKpU\nimI1OSkcpEm2tBSFsIXu1Jn7ShXi+PGK0bPWqm/cCzshzIxFQpUJrSi1iEkl\nBlYWgPS367GUD5Qk2+ySKs6A/fJ/D/9NbRxpvbzoeMRdol1tYh4q7qiQ70Ek\nk2PA74ouf3YzNKj2VgXF8aNEDUdsMezxvHRbHUKn0y7hw6HXvgMUXAN8WX9g\niL0SPMMwfagoRtU0GyY72PvPKesEydYb03WMhthh+5gBWGBeKhTzMEy9i/Oy\n5sk+gXyrsOuNm20QefIXB2L63kmz/Xcd2NuClSO2KgH7qJB5SWLERcZXBn8H\ncV1R\r\n=hnyn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.cjs.js","name":"emotion-theming","types":"types/index.d.ts","author":{"name":"styled-components team"},"module":"dist/index.esm.js","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","browser":{"./dist/index.cjs.js":"./dist/index.browser.cjs.js","./dist/index.esm.js":"./dist/index.browser.esm.js"},"license":"MIT","scripts":{"test:typescript":"dtslint types"},"_npmUser":{"name":"mitchellhamilton","email":"mitchell@mitchellhamilton.me"},"homepage":"https://emotion.sh","keywords":["react","theme","theming","emotion","cssinjs","css-in-js"],"umd:main":"./dist/emotion.umd.min.js","repository":{"url":"https://github.com/emotion-js/emotion/tree/master/packages/emotion-theming","type":"git"},"_npmVersion":"6.4.1","description":"A CSS-in-JS theming solution, inspired by styled-components","directories":{},"maintainers":[{"name":"mitchellhamilton","email":"mitchell@mitchellhamilton.me"},{"name":"tkh44","email":"kye.hohenberger@gmail.com"}],"_nodeVersion":"10.11.0","contributors":[{"url":"https://github.com/probablyup","name":"Evan Scott","email":"probablyup@gmail.com"}],"dependencies":{"@emotion/weak-memoize":"^0.2.0","hoist-non-react-statics":"^2.3.1"},"publishConfig":{"tag":"next"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"dtslint":"^0.3.0","@types/react":"16.3.18"},"peerDependencies":{"react":"15.x || 16.x","@emotion/core":"0.x.x"},"_npmOperationalInternal":{"tmp":"tmp/emotion-theming_10.0.0-beta.0_1539416107633_0.6972230062090803","host":"s3://npm-registry-packages"},"_id":"emotion-theming@10.0.0-beta.0","version":"10.0.0-beta.0"}