{"name":"emotion-mdx","version":"1.0.0-6","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.10","@emotion/styled":"^10.0.10","@mdx-js/mdx":"^1.0.0-alpha.16","@mdx-js/react":"^1.0.0-alpha.16","@styled-system/css":"^1.0.0","emotion-theming":"^10.0.10","gx":"^2.0.0-22","jest":"^24.5.0","jest-emotion":"^10.0.10","lodash.pick":"^4.4.0","react":"^16.8.6","react-dom":"^16.8.6","react-test-renderer":"^16.8.6","styled-system":"^4.1.0"},"peerDependencies":{"@emotion/core":"^10.0.9","@emotion/styled":"^10.0.9","@mdx-js/mdx":"^1.0.0-alpha.16","@mdx-js/react":"^1.0.0-alpha.16","emotion-theming":"^10.0.9"},"dependencies":{"lodash.get":"^4.4.2","lodash.merge":"^4.6.1"},"jest":{"snapshotSerializers":["jest-emotion"],"coverageReporters":["lcov","html"]},"gitHead":"1d7984eb33a56d12592b4b9f79093b7f0b7b0e33","_id":"emotion-mdx@1.0.0-6","_nodeVersion":"10.15.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-oI7M/7FnHvf/iC4QPlDrJZabKSwLMpKWg68UM8EpOQ2gboReW24RoNjTnPwR0WBYkNicicT1J9uB3PWsB4m+2Q==","shasum":"0178ced4b9be8972ec233f720ec51af6ef390462","tarball":"http://registry-npm.ywwl.com/emotion-mdx/download/emotion-mdx-1.0.0-6.tgz","fileCount":4,"unpackedSize":13029,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcooEgCRA9TVsSAnZWagAAHVYP/3aYtH0omN14cJZyT8m4\nfAZq4QJfE0EI13HzEQK8tP5U+o9lHL/Vcds1jbD2VI9rBgg0qjRjpA1RVsKG\n7/rVIEjlrI7t3PkkKDJ6Zat0PaShOQtcl5zHxWiJTe5o7O9qHULg/PdAcs6c\nEpsq6bphlNqbcZlgcff1Yb6PEtSyTyarmr7NaXL14/ioHA8Q9rj5F07qpdMO\nmLcfhJN6SesKOyDPv0Sy4uux32CVvu8mUsv3zOPQuRNqgHj1xHPnwWPVUvBv\nW4Y72ySOhEdal2LPGfzQ1MjyIDgiU8pLSNoNzJMnIrwGPz6ylHhcsgTH/Zad\nj06TzAxqX58lMEs4ARbPNHGyE+acIq3DCSeI6aXXdEiUVldBQM9n4U9HNGvw\nshG/MZ/Y4Z/redBi3m8eglnR8eUna/8/TYHTBOeOhlHUWORRMI1ziEJ5xDS7\nkUynN+/SAiWO1b7LLzMb+Aq8cBnwLN4E93hkJgGQYKYtn6nB0U/MYej2phLH\nlcfKfXAJz4GQM0HGqyXMonbqN64rZzzU8DmjMsb3IYSHQuFhqJIjXolbcTwa\nYSBBAtZa8ZP6uy/ffvnI5o4ICW3iQXJwBJFVrjqHOCM4jjAzY3/Aum3it2x+\n8FtfralglY/Yh4O7eCagNmpdjWuDdW4RZMVlSWXB2NF2v/LCczErfAIf19x9\nJ/OE\r\n=tbIL\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB94BcOirV5p2HLHU+kprpirUaNY4GZ6UqBnTp1hFFrqAiEAjTkK9warqb4WHAokINJMp/3BcYPyoyJJLfxmgNCmyLk="}],"size":4094,"noattachment":false,"key":"/emotion-mdx/-/emotion-mdx-1.0.0-6.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-6_1554153760255_0.604325482555395"},"_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":1554153760360,"_cnpm_publish_time":1554153760360,"dist-tags":{"latest":"1.0.0-6","next":"1.0.0-3"}}