{"name":"emotion-mdx","version":"1.0.0-5","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":"ec97629bd140cf0e99875fdaf204cdfa41ac2ab6","_id":"emotion-mdx@1.0.0-5","_nodeVersion":"10.15.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-u7JrHDQA8MiumXytJ9X9u2/LJyzwarGTTqQTOaUKnDsQIlWNt9i7nXW+8EjXtqecUTumtnTi9pUWuNLhf/f2Ow==","shasum":"6a49057392f10c2eb5a0740de8c38bc0f3c6a10b","tarball":"http://registry-npm.ywwl.com/emotion-mdx/download/emotion-mdx-1.0.0-5.tgz","fileCount":4,"unpackedSize":12874,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcon51CRA9TVsSAnZWagAAdYAP/10GvH0xHaaHSsZ81XkO\nKnUkoIndR0maQBTHuUlTYkMyvXKyNfKvL8yZzk+wxviXnYPtsIfJGrAKB+3T\ntNSnBDW/B9zUxb8bQdBiWQMlAyhJ3ZBqlcL6XjPBEiomJ0EY8r2eOAWAUJOX\nw/muQa+TQg1YUC3G9A/QQv00ikQp9kvKsbk6eSE+ysfgNEOvE5twazhN2lP9\nHYJPeJufeFI9q7sTx9olsz/k0AbTd8gcwjD86KXgeLjl+82Awhmp+qj8nmlP\ngDQIC3CxuVHgv40b7aIU0tpHnVyYlyFlWXeZpkRG9RTnG5MRNdzimdDYvLa6\nAuAEgURgrBE4wWQgGze8idJVlYtUUq0RfNjckYk9aLOe4PpE5mi945fa5UGc\nKj08fGZoVq7hxi9ELcNokvEvGixX1ceBWFMYW9oZAbVnMwWeI5moVuBK0aln\ngA6p0Sd5EQgMfGhcqE2fhrh8DkJYeTlXkVDsg7NNuDoxU8ubpO1gmPmLClkH\nSEX9LnO9StZu8bIZfHoQaWAQauC2DFOb1U8L90NpcfvPVCaHqE2fp9I/09K6\nYdnrbp37zGN2VAZYU97yTADk6BPepW8sZUEEE8qEGP6jjOXqmLz9/tnsrk9e\nrtIUOSDSPhl3CUC/yHZGNbaflTh29iknfFlKo6bdyQbm49HJi63AlKBMC0p6\nxwJb\r\n=D7qN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCHwDMECyxoHS7hEezjPuP4AjSxz/rEtC8aS/n/+IAXlwIga3taP06aHfVL3xCCQT5Xj9khJqV853kkB1poGLrfbtg="}],"size":4040,"noattachment":false,"key":"/emotion-mdx/-/emotion-mdx-1.0.0-5.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-5_1554153076439_0.062173798961239646"},"_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":1554153076607,"_cnpm_publish_time":1554153076607,"dist-tags":{"latest":"1.0.0-6","next":"1.0.0-3"}}