{"name":"emotion-mdx","version":"1.0.0-0","description":"A fine blend of Emotion, theming, MDX, and React components","main":"index.cjs.js","scripts":{"prepare":"babel index.js -o index.cjs.js","test":"jest","start":"gx docs"},"keywords":[],"author":{"name":"Brent Jackson","email":"jxnblk@gmail.com"},"license":"MIT","devDependencies":{"@babel/cli":"^7.2.3","@babel/core":"^7.4.0","@babel/preset-env":"^7.4.2","@babel/preset-react":"^7.0.0","@emotion/core":"^10.0.9","@emotion/styled":"^10.0.9","@mdx-js/mdx":"^1.0.0-alpha.9","@mdx-js/tag":"^1.0.0-alpha.6","emotion-theming":"^10.0.9","gx":"^2.0.0-18","jest":"^24.5.0","jest-emotion":"^10.0.9","lodash.pick":"^4.4.0","react":"^16.8.5","react-dom":"^16.8.5","react-test-renderer":"^16.8.5","styled-system":"^4.0.6"},"peerDependencies":{"@emotion/core":"^10.0.9","@emotion/styled":"^10.0.9","@mdx-js/mdx":"^1.0.0-alpha.7","@mdx-js/tag":"^1.0.0-alpha.6","emotion-theming":"^10.0.9"},"dependencies":{"lodash.merge":"^4.6.1"},"jest":{"snapshotSerializers":["jest-emotion"],"coverageReporters":["lcov","html"]},"gitHead":"97baceefd688f27d52b85a168f61f91d1270075e","_id":"emotion-mdx@1.0.0-0","_nodeVersion":"10.15.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-03RqINHYdW20QfW/74F/7EyArQkp+qIL0psSG1MUKxR7O/q2No5bOPJwVTPQnezEOQJvdzR8HfjdzGhRpKbrmA==","shasum":"631eeecefd0cf64e200fd684263ecfa9cf9e605d","tarball":"http://registry-npm.ywwl.com/emotion-mdx/download/emotion-mdx-1.0.0-0.tgz","fileCount":4,"unpackedSize":12754,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJclZ+xCRA9TVsSAnZWagAABhoP/2bXYq6ucIrAWZVPHMjv\nEidVTguufJ9Dcn/zymLMbr+0SJMujq31BoyaMlKq+tM11Sk18NRgLu+MvGJi\nQXGPXShywN/VmCn4Nl+QNbp5S9u+GCMJ3LQ9hcO/MnPx+haLaRuLbjFfH9AW\nYLsS3o7gtqY5syCv/0QM4u34e51l2POioHgd6rO2rokqPXaaIe9am9qow03c\n/VhIwSEL9jvdragAYGr+6m75YbE67b7gX50GYeiYZAhsbW9fLWxkVTXwIpQ1\nLo6poNXwH8ijrrabiNFcGgO5pwUft68tF1hCOFfa2CItE/6PRBMKJWQQ9Fyf\n7rLC0ouDmWH3uO2eGfJj9ltsk2Z18/rQYurzoF0AnlGgw1APgdmcxByzHJqe\nEzjdT/YJNKv4vq2jUt/DZYrAhHg9uKylM2rr3PRMVxuXvjQNeXC3pxWrrnkb\nnu7XFyEbz6AR38yku4SNasSOtJR6pGhhEtlFCJQLLgHUIg7aP+8maMmFosz8\nCX0LQn0r5bipZNR6ZqCP3XEj1Wvlo5LEyesK+7Z+y3Ie1Otd4osisXju8bbp\nS5iQ/jdWEYopI+OCZZnVTmMJ+1qLSChUxwt0X4tZcYUF+Xcf7AgoaZFiDuH5\np1TOBtdOBBWiU4hWbgI9g3VedoW/54aNY48X+J4NReZzyWIfcS9AHjsE3d7D\nB3/C\r\n=mIv8\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCv9ihJfaNPIWHvYzTucx5erZbbz8r5sKCFLTPSFPt8nAIgVJLpfBAVxNq9hhC1bzxEAeCkFF38y3K/G+l2zYFYurw="}],"size":3928,"noattachment":false,"key":"/emotion-mdx/-/emotion-mdx-1.0.0-0.tgz"},"maintainers":[{"name":"jxnblk","email":"jxnblk@gmail.com"}],"_npmUser":{"name":"jxnblk","email":"jxnblk@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/emotion-mdx_1.0.0-0_1553309617140_0.10411730871346192"},"_hasShrinkwrap":false,"readme":"\n# emotion-mdx\n\nA fine blend of [Emotion][], theming, [MDX][], and React components\n\n**WIP/Experimental**\n\n```sh\nnpm i emotion-mdx\n```\n\nYou'll also need the following:\n\n```sh\nnpm i @emotion/core emotion-theming @mdx-js/mdx@next @mdx-js/react@next\n```\n\nEmotion MDX is a context provider meant to be a complete replacement for both the `MDXProvider` and `ThemeProvider`.\nIt creates styled MDX components that have access to the Emotion theme object and can be nested to created contextual styles.\n\n```jsx\n// basic example\nimport React from 'react'\nimport { ComponentProvider } from 'emotion-mdx'\nimport theme from './theme'\nimport components from './components'\nimport Hello from './hello.mdx'\n\nexport default props =>\n  <ComponentProvider\n    theme={theme}\n    components={components}>\n    <Hello />\n  </ComponentProvider>\n```\n\n## Styles\n\nThe `theme.styles` object adds styles to child MDX elements.\n\n```jsx\n<ComponentProvider\n  theme={{\n    styles: {\n      h1: {\n        fontSize: 48,\n        color: 'tomato',\n      },\n    }\n  }}\n/>\n```\n\n## Transforming Styles\n\nA `transform` function can be provided to transform the style object based on the theme.\nThis can be used with libraries like [Styled System][] to quickly add theme-derived styles.\n\n```jsx\nimport React from 'react'\nimport { ComponentProvider } from 'emotion-mdx'\nimport css from '@styled-system/css'\n\nexport default props =>\n  <ComponentProvider\n    transform={css}\n    theme={{\n      colors: {\n        primary: 'tomato',\n      },\n      styles: {\n        h1: {\n          color: 'primary'\n        }\n      }\n    }}\n  />\n```\n\nThe `transform` function should accept `styles` as an argument and return a function that accepts `theme` as an argument.\n\n```js\ntransform(styles)(theme)\n```\n\n## Nesting Providers\n\nThe `ComponentProvider` can be nested to make contextual changes to the `theme`, `components`, or `theme.styles`.\n\n## Props\n\n- `components` (object) React components to render MDX elements\n- `theme` (object) Emotion theming object\n- `theme.styles` (object) Nested style objects for each component, with access to the Emotion `theme` context\n- `transform` (function) Optional function to transform styles\n\n## useComponents\n\nThe `useComponents` hook will return an object of styled components that can be used outside of an MDX document.\n\n```jsx\nimport React from 'react'\nimport { useComponents } from 'emotion-mdx'\n\nexport default props => {\n  const Styled = useComponents()\n  return (\n    <>\n      <Styled.h1>Hello</Styled.h1>\n      <Styled.p>I'm themed</Styled.p>\n    </>\n  )\n}\n```\n\n## Styled Components\n\nThe `Styled` component can be imported directly and works similarly to the `useComponents` hook.\n\n```jsx\nimport React from 'react'\nimport { Styled } from 'emotion-mdx'\n\nexport default props =>\n  <Styled.div>\n    <Styled.h1>Hello</Styled.h1>\n  </Styled.div>\n```\n\n## Theming\n\nEmotion MDX can be used to create isolated \"theme\" layout components for MDX documents.\nThese component can encapsulate typography styles that will only apply to MDX elements.\n\n```jsx\n// example MDX theme\nimport React from 'react'\nimport { ComponentProvider } from 'emotion-mdx'\n\nconst theme = {\n  styles: {\n    wrapper: {\n      fontFamily: 'Roboto, system-ui, sans-serif',\n      lineHeight: 1.5,\n    },\n    h1: {\n      fontSize: 48,\n      fontWeight: 900,\n      lineHeight: 1.25,\n    },\n    h2: {\n      fontSize: 32,\n      lineHeight: 1.25,\n    }\n  }\n}\n\nexport default props =>\n  <ComponentProvider\n    {...props}\n    theme={theme}\n  />\n```\n\n```mdx\n// example mdx file\nimport Theme from './theme'\nexport default Theme\n\n# Hello\n\n## We're styled!\n```\n\nMIT License\n\n[mdx]: https://mdxjs.com\n[emotion]: https://emotion.sh\n[styled system]: https://styled-system.com\n\n","publish_time":1553309617317,"_cnpm_publish_time":1553309617317,"dist-tags":{"latest":"1.0.0-6","next":"1.0.0-3"}}