{"name":"emotion-theming","version":"11.0.0-next.5","description":"A CSS-in-JS theming solution, inspired by styled-components","main":"dist/emotion-theming.cjs.js","module":"dist/emotion-theming.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":{"@emotion/core":"^11.0.0-next.5","@emotion/styled":"^11.0.0-next.5","@types/react":"^16.9.11","dtslint":"^0.3.0","react":"^16.11.0"},"dependencies":{"@babel/runtime":"^7.7.2","@emotion/weak-memoize":"0.2.4","hoist-non-react-statics":"^3.3.0"},"peerDependencies":{"@emotion/core":"^11.0.0-next.5","react":">=16.8.0"},"umd:main":"dist/emotion-theming.umd.min.js","browser":{"./dist/emotion-theming.cjs.js":"./dist/emotion-theming.browser.cjs.js","./dist/emotion-theming.esm.js":"./dist/emotion-theming.browser.esm.js"},"preconstruct":{"umdName":"emotionTheming"},"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-reactcomponenttype)\n  - [withTheme](#withthemecomponent-reactcomponenttype-reactcomponenttype)\n  - [useTheme](#usetheme)\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\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. This HOC gets 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`. The theme can also be accessed via passing a function to the css prop.\n\n```jsx\n// Page.js\nimport * as React from 'react'\n/** @jsx jsx */\nimport { jsx } from '@emotion/core'\nimport styled from '@emotion/styled'\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-family: sans-serif;\n`\n\nexport default class Page extends React.Component {\n  render() {\n    return (\n      <Container>\n        <Headline>I'm red!</Headline>\n        <p css={theme => ({ color: theme.color })}>I'm also red!</p>\n      </Container>\n    )\n  }\n}\n\n// App.js\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport { ThemeProvider } from 'emotion-theming'\n\nimport Page from './Page.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\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` components can be added deeper in the tree 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`: React.Node**\n- **`theme`: Object|Object => Object** - An object or function that provides an object.\n\n```jsx\nimport React from 'react'\nimport styled from '@emotion/styled'\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```\n\n> Note:\n>\n> Make sure to hoist your theme out of render otherwise you may have performance problems.\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### useTheme\n\nA React hook that provides the current theme as its value. If the theme is updated, the child component will be re-rendered accordingly.\n\n```jsx\n// @live\n/** @jsx jsx */\nimport { jsx } from '@emotion/core'\nimport styled from '@emotion/styled'\nimport { ThemeProvider, useTheme } from 'emotion-theming'\n\nconst theme = {\n  colors: {\n    primary: 'hotpink'\n  }\n}\n\nfunction SomeText(props) {\n  const theme = useTheme()\n  return <div css={{ color: theme.colors.primary }} {...props} />\n}\n\nrender(\n  <ThemeProvider theme={theme}>\n    <SomeText>some text</SomeText>\n  </ThemeProvider>\n)\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 designed this API.\n\n## License\n\nMIT 2017-present\n","readmeFilename":"README.md","_id":"emotion-theming@11.0.0-next.5","_nodeVersion":"10.17.0","_npmVersion":"6.10.2","dist":{"integrity":"sha512-RGgCge3Jtwis6owosE5PfJtn/wwjhYkTCwGLb7FslqRJm2Gkr41RH+sP69bX/+H4yZ40jNq4BDHqxteGfiEi4A==","shasum":"a98cd5773f6fc316839a9991a18bd4f2046dc13b","tarball":"http://registry-npm.ywwl.com/emotion-theming/download/emotion-theming-11.0.0-next.5.tgz","fileCount":20,"unpackedSize":51625,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdzmv4CRA9TVsSAnZWagAAF2YQAIfUjnqwLuLafPoiIeZr\n/y0cYI5SZIrAPXG3i8rd51kvuXrThoxsxqI+5sOZjlo1c6My9FFalUpl+g0K\nT3yyPHDCdK9tWhd+dkw0OKnkGLZjVq1ax05yPXx9vjx5lUSosMRubPTcwGx9\nsK3R+yeg+GPTSfHxCZQNk5sqAHvdtmsxSoEpDQfXE/Olc6MvMqAmgjgOrGGc\nLd4ombB/EUuQeh4MkbtT845a0KORme2H5tjA2cj2uS9AuEDsMtE6jBnX6W9P\nRQ+5Z/P87bKNxsqluiCuELh0grtuMLKpvhIZkYHqYOBMxfDF09pwZHuB9YY5\n1DySkDNgBzQDlyukBfQdfiWb+eQB/bPeXiFALJYCJGQnKy8P/02O3Fsr4y1S\nMpFiG9bL1x0ERne6J0qfEv8tSjKkdN4vQUdN6j1Md1gZdUEddaXLql5ErOQd\n2F99a+nevWVlSOlg7AiGSimpX76uRuHmUXrqIRkt0zGwDHGg+IhUliPitWqP\nr0hvFs+PqbBmoJJoqvGpLnEaldr8LdmZZjwIA7G6AdTBIGRRTSnnkqs5IFPc\nZjN+vLl2coA1edQIZZQvPt2OmdBh4i5zIoQ+bc+Gi7mQMrxjCvyKuGaRd/FW\nSAj3/AVv8g5cip/D0cdt1dDrA0mMVzk65vvUsPMUr1Y+FRJ/xIHhzqpW5gTh\nBFNo\r\n=oQIW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDbFpoE1CcPISWUGcCHWnyLFe1G0CPz0akAxsI2EiE8sQIhALRp/AMM37ykcSoFZbMYEK8es0PofrByZCW7wdI8DpHZ"}],"size":13737,"noattachment":false,"key":"/emotion-theming/-/emotion-theming-11.0.0-next.5.tgz"},"maintainers":[{"email":"mitchell+emotion-release-bot@hamil.town","name":"emotion-release-bot"},{"email":"mitchell@mitchellhamilton.me","name":"mitchellhamilton"},{"email":"kye.hohenberger@gmail.com","name":"tkh44"}],"_npmUser":{"name":"emotion-release-bot","email":"mitchell+emotion-release-bot@hamil.town"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/emotion-theming_11.0.0-next.5_1573809143919_0.3092745379483386"},"_hasShrinkwrap":false,"publish_time":1573809144051,"_cnpm_publish_time":1573809144051,"dist-tags":{"latest":"11.0.0","next":"11.0.0-next.6","rc":"11.0.0-rc.0","ten":"10.3.0"}}