{"name":"emotion-mdx","version":"1.0.0-4","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.merge":"^4.6.1"},"jest":{"snapshotSerializers":["jest-emotion"],"coverageReporters":["lcov","html"]},"gitHead":"2aae92deccf9cf57b038731abbf38635080f8f77","_id":"emotion-mdx@1.0.0-4","_nodeVersion":"10.15.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-qj7dZEH9HIGGQTMinMIopIrUaCJaXv2r4KCONLAkeREeRVJ3nP0Yo75tMKwGiiILF88ob0E/iehUm0RjbgMkfw==","shasum":"3a7d5cb3eccc5151f3b699495add965cad774761","tarball":"http://registry-npm.ywwl.com/emotion-mdx/download/emotion-mdx-1.0.0-4.tgz","fileCount":4,"unpackedSize":14262,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcn86HCRA9TVsSAnZWagAAz58P/2qULU1pr5Fs/qWPYEpY\nczrfeec9UeVQQB/eqctPj4vsB/ea9fQFvwoMsh/P2ltIxFrYNwncWDFrM/WO\nUZkWqbw8hfTRfib+LA/frdyEEvt2kN6e3HvzaEh/M925qKCrvSO6AQPh2k1n\nU5w6pjnZn/KBNXD8ULOmD+qZqz4uznDfD+p+vvxGXHdwkMB76w/72RPhylqi\n+RlGsx5glgVdH5iHcx1+aCY+ofaZ/72eKMcSdQIiZfQivH3FF1Mig2FipBHl\nodt8KOThxm+hR4+nUYdEQktsRoZ9pyCLUZtBN+BDOsQEjxe8mNLan6+gN3Ec\ndzCDPD0ERnitojJluSs7pU5PNh1e3Ap/dXkT4aj9w9aFe3GOqfa7NsDpJQSb\nhr88oKCYRzJDZ1jeLgbM0Gmo9wu9KGx0okh5uM1tg9G/08j6dCUebGN5ofpD\n1Cr3KA6BoPd+khHCFWwT6Yns3MR7eC2RmIfwWnJKrDJSwfo2E0myCf691y4s\nfcqS00ibknoikCANmGEPjZk/8Hlgq939swxxvLR0wCvHqxc/BrvZ4OBJppmN\nU2RPEZOMUI+/XqXYEvKjhZlGoyWnWoZHcgSLbtWJS6/xM+uYciICb/vpWDFb\n8w9nogWlPMvG3KD8ElSQWdtsoy1Olk8lv7/lnq98gusabFe3YKENcg7KKriJ\nRgwl\r\n=9pQX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDaq8DRJahKOTqoegZMamA/UmpLXYfboVLPg2MM5ITIQgIhAN+sWRpy7Xh93WUA2oUZTVa0k9jUaHAWka3yU4qhitZY"}],"size":4274,"noattachment":false,"key":"/emotion-mdx/-/emotion-mdx-1.0.0-4.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-4_1553976966400_0.25754570060079063"},"_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":1553976966533,"_cnpm_publish_time":1553976966533,"dist-tags":{"latest":"1.0.0-6","next":"1.0.0-3"}}