Skip to content

Commit

Permalink
feat: new example package
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Zivolo committed Dec 4, 2018
1 parent 3bdaa26 commit 49b9e1f
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages/_example/Button.examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This file is served by the styleguide to showcase the usage
of the `Button.js` component.

Use it to document its API and to provide some usage examples.

```js
<Button>test</Button>
```
9 changes: 9 additions & 0 deletions packages/_example/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @flow
import styled from '@emotion/styled';

const Button = styled.button`
color: red;
`;

// @component
export default Button;
11 changes: 11 additions & 0 deletions packages/_example/Button.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @flow
import React from 'react';
import { mount } from 'enzyme';

import Button from './Button';

it('renders a button', () => {
const wrapper = mount(<Button>foo</Button>);
expect(wrapper.find('button')).toHaveLength(1);
expect(wrapper).toMatchSnapshot();
});
19 changes: 19 additions & 0 deletions packages/_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This component showcases how to create a React based library
with the help of Emotion and Flow in the Quid UI repository.


### Bundling the package

To easily bundle the package, we make use of the microbundle tool,
which wraps Rollup, Babel and other useful utilities into a single CLI utility.
Read more about [microbundle][microbundle] on its official GitHub repository.

### Type checking

The whole Quid UI repository is type-checked using [Flow][flow],
you can start the Flow type checker by running `flow` on the root
of the Quid UI repository.


[microbundle]: https://github.com/developit/microbundle
[flow]: https://flow.org/
15 changes: 15 additions & 0 deletions packages/_example/__snapshots__/Button.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders a button 1`] = `
.emotion-0 {
color: red;
}
<Styled(button)>
<button
className="emotion-0"
>
foo
</button>
</Styled(button)>
`;
2 changes: 2 additions & 0 deletions packages/_example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @flow
export { default } from './Button';
21 changes: 21 additions & 0 deletions packages/_example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@quid/example",
"version": "1.0.0",
"description": "Minimal example to create a React library using Emotion in Quid UI",
"main": "dist/index.js",
"umd:main": "dist/index.umd.js",
"module": "dist/index.es.js",
"license": "MIT",
"private": true,
"scripts": {
"start": "microbundle watch",
"prepare": "microbundle build"
},
"dependencies": {
"@emotion/core": "^10.0.1",
"@emotion/styled": "^10.0.1"
},
"devDependencies": {
"microbundle": "^0.8.3"
}
}
126 changes: 124 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,107 @@
resolved "https://registry.npmjs.org/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"
integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw==

"@emotion/cache@10.0.0":
version "10.0.0"
resolved "https://registry.npmjs.org/@emotion/cache/-/cache-10.0.0.tgz#e22eadcb770de4131ec707c84207e9e1ce210413"
integrity sha512-1/sT6GNyvWmxCtJek8ZDV+b+a+NMDx8/61UTnnF3rqrTY7bLTjw+fmXO7WgUIH0owuWKxza/J/FfAWC/RU4G7A==
dependencies:
"@emotion/sheet" "0.9.2"
"@emotion/stylis" "0.8.3"
"@emotion/utils" "0.11.1"
"@emotion/weak-memoize" "0.2.2"

"@emotion/core@^10.0.1":
version "10.0.1"
resolved "https://registry.npmjs.org/@emotion/core/-/core-10.0.1.tgz#5cbd7507e87473c390478120cf16e0e328e4259f"
integrity sha512-Fbk+pqwdPCdm7oY6UuaJ9JNT+ig5bRLjlEwH20Uq5brrWvRc+NqI8PhcfK4jZul24etj45pFRSIoteaUD2H2jw==
dependencies:
"@emotion/cache" "10.0.0"
"@emotion/css" "10.0.0"
"@emotion/serialize" "0.11.0"
"@emotion/sheet" "0.9.2"
"@emotion/utils" "0.11.1"

"@emotion/css@10.0.0":
version "10.0.0"
resolved "https://registry.npmjs.org/@emotion/css/-/css-10.0.0.tgz#aee814e8edee4ae9fa8e682abf2eb30f22cdb840"
integrity sha512-XvPKeXSnLhxJkMTKXZqd605rXRnUht/ncelbyhV0+MuojhLihH+/3oV4m5ltqhvFcnNpDrtqS2QjuMhUpmXxIw==
dependencies:
"@emotion/serialize" "0.11.0"
"@emotion/utils" "0.11.1"
babel-plugin-emotion "10.0.0"

"@emotion/hash@0.7.1":
version "0.7.1"
resolved "https://registry.npmjs.org/@emotion/hash/-/hash-0.7.1.tgz#9833722341379fb7d67f06a4b00ab3c37913da53"
integrity sha512-OYpa/Sg+2GDX+jibUfpZVn1YqSVRpYmTLF2eyAfrFTIJSbwyIrc+YscayoykvaOME/wV4BV0Sa0yqdMrgse6mA==

"@emotion/is-prop-valid@0.7.2":
version "0.7.2"
resolved "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.7.2.tgz#bfff84765f39c352570ff537c5670dfdc90a1dbe"
integrity sha512-UCkzksTUib0aVnR5O7UxxDmlaUTEfQLRFBjC29z6FJ10Vg/P2T01iaq76I11katqmZjKHNVKJLH1nOvOY2E9Cw==
dependencies:
"@emotion/memoize" "0.7.1"

"@emotion/memoize@0.7.1":
version "0.7.1"
resolved "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.1.tgz#e93c13942592cf5ef01aa8297444dc192beee52f"
integrity sha512-Qv4LTqO11jepd5Qmlp3M1YEjBumoTHcHFdgPTQ+sFlIL5myi/7xu/POwP7IRu6odBdmLXdtIs1D6TuW6kbwbbg==

"@emotion/serialize@0.11.0":
version "0.11.0"
resolved "https://registry.npmjs.org/@emotion/serialize/-/serialize-0.11.0.tgz#9332b483a112af7b515d20470a7bf1aa5f8dcf6c"
integrity sha512-SpUumzuN7CxEGvJKe3bul8+VKdcNleACokv5YgS+k4KQIurdq7dbm4sM7aT9hBx3ccMpDfg5BYVfR3NPoeU5PA==
dependencies:
"@emotion/hash" "0.7.1"
"@emotion/memoize" "0.7.1"
"@emotion/unitless" "0.7.3"
"@emotion/utils" "0.11.1"
csstype "^2.5.7"

"@emotion/sheet@0.9.2":
version "0.9.2"
resolved "https://registry.npmjs.org/@emotion/sheet/-/sheet-0.9.2.tgz#74e5c6b5e489a1ba30ab246ab5eedd96916487c4"
integrity sha512-pVBLzIbC/QCHDKJF2E82V2H/W/B004mDFQZiyo/MSR+VC4pV5JLG0TF/zgQDFvP3fZL/5RTPGEmXlYJBMUuJ+A==

"@emotion/styled-base@10.0.1":
version "10.0.1"
resolved "https://registry.npmjs.org/@emotion/styled-base/-/styled-base-10.0.1.tgz#751b5db7401b159e13f2b69165ff010ea43505cf"
integrity sha512-vCWNZ2LGL9aV2QFFOojypGyUFWKwmCYsLJ843QYImsQEMdfDgiTqKdnxDty4di1BftQY+vLiD2woR/mzB8lfZw==
dependencies:
"@emotion/is-prop-valid" "0.7.2"
"@emotion/serialize" "0.11.0"
"@emotion/utils" "0.11.1"
object-assign "^4.1.1"

"@emotion/styled@^10.0.1":
version "10.0.1"
resolved "https://registry.npmjs.org/@emotion/styled/-/styled-10.0.1.tgz#be7c57e69aa87f9e1158dbeb1894ee871de074c4"
integrity sha512-j1s4oUxAb8RRr8e3u+ygiZ/54Fb5d8vZl6WhoYRRw7SNxOhSUXs4HsEKSMOpP6MYizPYNIFiVm41RFT9QmXw4Q==
dependencies:
"@emotion/styled-base" "10.0.1"
babel-plugin-emotion "10.0.0"

"@emotion/stylis@0.8.3":
version "0.8.3"
resolved "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.3.tgz#3ca7e9bcb31b3cb4afbaeb66156d86ee85e23246"
integrity sha512-M3nMfJ6ndJMYloSIbYEBq6G3eqoYD41BpDOxreE8j0cb4fzz/5qvmqU9Mb2hzsXcCnIlGlWhS03PCzVGvTAe0Q==

"@emotion/unitless@0.7.3":
version "0.7.3"
resolved "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.3.tgz#6310a047f12d21a1036fb031317219892440416f"
integrity sha512-4zAPlpDEh2VwXswwr/t8xGNDGg8RQiPxtxZ3qQEXyQsBV39ptTdESCjuBvGze1nLMVrxmTIKmnO/nAV8Tqjjzg==

"@emotion/utils@0.11.1":
version "0.11.1"
resolved "https://registry.npmjs.org/@emotion/utils/-/utils-0.11.1.tgz#8529b7412a6eb4b48bdf6e720cc1b8e6e1e17628"
integrity sha512-8M3VN0hetwhsJ8dH8VkVy7xo5/1VoBsDOk/T4SJOeXwTO1c4uIqVNx2qyecLFnnUWD5vvUqHQ1gASSeUN6zcTg==

"@emotion/weak-memoize@0.2.2":
version "0.2.2"
resolved "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.2.tgz#63985d3d8b02530e0869962f4da09142ee8e200e"
integrity sha512-n/VQ4mbfr81aqkx/XmVicOLjviMuy02eenSdJY33SVA7S2J42EU0P1H0mOogfYedb3wXA0d/LVtBrgTSm04WEA==

"@iamstarkov/listr-update-renderer@0.4.1":
version "0.4.1"
resolved "https://registry.npmjs.org/@iamstarkov/listr-update-renderer/-/listr-update-renderer-0.4.1.tgz#d7c48092a2dcf90fd672b6c8b458649cb350c77e"
Expand Down Expand Up @@ -2467,6 +2568,22 @@ babel-plugin-dynamic-import-node@2.2.0:
dependencies:
object.assign "^4.1.0"

babel-plugin-emotion@10.0.0:
version "10.0.0"
resolved "https://registry.npmjs.org/babel-plugin-emotion/-/babel-plugin-emotion-10.0.0.tgz#ceb177a64d5ccba3c28d7de4a0697d0f3a66315f"
integrity sha512-O0ykSwaJQVHuZcAd0/TuMbG6QzuArGheL9XeEoQfgBeFlcyrGEj/2JexsCk4iMMiykxW7hfulm0zKy864PWOSw==
dependencies:
"@babel/helper-module-imports" "^7.0.0"
"@emotion/hash" "0.7.1"
"@emotion/memoize" "0.7.1"
"@emotion/serialize" "0.11.0"
babel-plugin-macros "^2.0.0"
babel-plugin-syntax-jsx "^6.18.0"
convert-source-map "^1.5.0"
escape-string-regexp "^1.0.5"
find-root "^1.1.0"
source-map "^0.5.7"

babel-plugin-istanbul@^4.1.6:
version "4.1.6"
resolved "http://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.6.tgz#36c59b2192efce81c5b378321b74175add1c9a45"
Expand All @@ -2482,7 +2599,7 @@ babel-plugin-jest-hoist@^23.2.0:
resolved "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.2.0.tgz#e61fae05a1ca8801aadee57a6d66b8cefaf44167"
integrity sha1-5h+uBaHKiAGq3uV6bWa4zvr0QWc=

babel-plugin-macros@2.4.2:
babel-plugin-macros@2.4.2, babel-plugin-macros@^2.0.0:
version "2.4.2"
resolved "https://registry.npmjs.org/babel-plugin-macros/-/babel-plugin-macros-2.4.2.tgz#21b1a2e82e2130403c5ff785cba6548e9b644b28"
integrity sha512-NBVpEWN4OQ/bHnu1fyDaAaTPAjnhXCEPqr1RwqxrU7b6tZ2hypp+zX4hlNfmVGfClD5c3Sl6Hfj5TJNF5VG5aA==
Expand All @@ -2495,6 +2612,11 @@ babel-plugin-named-asset-import@^0.2.3:
resolved "https://registry.npmjs.org/babel-plugin-named-asset-import/-/babel-plugin-named-asset-import-0.2.3.tgz#b40ed50a848e7bb0a2a7e34d990d1f9d46fe9b38"
integrity sha512-9mx2Z9M4EGbutvXxoLV7aUBCY6ps3sqLFl094FeA2tFQzQffIh0XSsmwwQRxiSfpg3rnb5x/o46qRLxS/OzFTg==

babel-plugin-syntax-jsx@^6.18.0:
version "6.18.0"
resolved "http://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946"
integrity sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY=

babel-plugin-syntax-object-rest-spread@^6.13.0, babel-plugin-syntax-object-rest-spread@^6.8.0:
version "6.13.0"
resolved "http://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"
Expand Down Expand Up @@ -3645,7 +3767,7 @@ conventional-recommended-bump@^4.0.4:
meow "^4.0.0"
q "^1.5.1"

convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.5.1:
convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.5.0, convert-source-map@^1.5.1:
version "1.6.0"
resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20"
integrity sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==
Expand Down

0 comments on commit 49b9e1f

Please sign in to comment.