Skip to content

Commit

Permalink
Typescript Usage (#267)
Browse files Browse the repository at this point in the history
* add types field to exports

* Add TypeScript usage example.

rebase

* remove unused import

* Fixed TypeScript related issues

* TypeScript example is complete

* Update CRA example a little

* fixed core types; tested core types

* update payment-providers info

* update docs and type fixes

* testing

* uncollapsed docs sidebar

* Updated all-contributors info

* remove dep
  • Loading branch information
andria-dev authored Mar 10, 2022
1 parent 7ad0fd6 commit a7c64e4
Show file tree
Hide file tree
Showing 74 changed files with 3,835 additions and 11,610 deletions.
63 changes: 41 additions & 22 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"projectName": "use-shopping-cart",
"projectOwner": "dayhaysoos",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
"README.md",
"docs/docs/welcome/contributors.mdx"
],
"imageSize": 100,
"commit": false,
"commit": true,
"commitConvention": "none",
"contributors": [
{
"login": "doingandlearning",
Expand All @@ -24,25 +30,24 @@
"test"
]
},
{
"login": "ChrisBrownie55",
"name": "Chris Brown",
"avatar_url": "https://avatars2.githubusercontent.com/u/19195374?v=4",
"profile": "https://chrisbrownie.dev/",
"contributions": [
"test",
"code",
"doc"
]
},
{
"login": "dayhaysoos",
"name": "Nick DeJesus",
"avatar_url": "https://avatars3.githubusercontent.com/u/1852675?v=4",
"profile": "https://github.com/dayhaysoos",
"contributions": [
"code",
"test"
"test",
"blog",
"business",
"bug",
"data",
"doc",
"fundingFinding",
"infra",
"projectManagement",
"question",
"review",
"security"
]
},
{
Expand Down Expand Up @@ -125,7 +130,8 @@
"avatar_url": "https://avatars.githubusercontent.com/u/204841?v=4",
"profile": "https://www.erichowey.dev/",
"contributions": [
"doc"
"doc",
"plugin"
]
},
{
Expand All @@ -136,12 +142,25 @@
"contributions": [
"code"
]
},
{
"login": "andria-dev",
"name": "Andria Brown",
"avatar_url": "https://avatars.githubusercontent.com/u/19195374?v=4",
"profile": "https://github.com/andria-dev",
"contributions": [
"test",
"code",
"doc",
"bug",
"example",
"infra",
"maintenance",
"ideas",
"question",
"review"
]
}
],
"contributorsPerLine": 7,
"projectName": "use-shopping-cart",
"projectOwner": "dayhaysoos",
"repoType": "github",
"repoHost": "https://github.com",
"skipCi": true
"contributorsPerLine": 7
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ coverage

# Build file for UMD
examples/umd/src/use-shopping-cart.umd.js
use-shopping-cart/use-shopping-cart-v*.tgz
60 changes: 60 additions & 0 deletions .quokka
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"pro": true,
"babel": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"esmodules": true
},
"shippedProposals": true
}
],
[
"@babel/preset-react",
{
"runtime": "automatic"
}
]
]
},
"plugins": [
"jsdom-quokka-plugin"
],
"useWsl": true,
"jsdom": {
"html": "<div id=\"root\"></div>"
},
"env": {
"params": {
"runner": "--experimental-specifier-resolution=node"
}
},
"ts": {
"compilerOptions": {
"module": "esnext",
"target": "ES2019",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}
}
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@

# use-shopping-cart
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![NPM](https://img.shields.io/npm/v/use-shopping-cart.svg?style=flat-square)](https://www.npmjs.com/package/use-shopping-cart)

> A React Hook that handles shopping cart state and logic for Stripe.
https://useshoppingcart.com


[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors-) [![NPM](https://img.shields.io/npm/v/use-shopping-cart.svg)](https://www.npmjs.com/package/use-shopping-cart) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

[
![Product JSON example](/assets/products.png)
![Front-End code example](/assets/front-end.png)
![Serverless code example](/assets/serverless.png)
Click to open gist.
](https://gist.github.com/ChrisBrownie55/f4d395b104a06e8df44e009440247856)

](https://gist.github.com/andria-dev/f4d395b104a06e8df44e009440247856)

## Documentation

Expand All @@ -32,38 +32,35 @@ You need to polyfill `formatToParts` if you want to support older browsers. You

It is likely that you are using a value like `cartCount` that is loaded from LocalStorage which doesn't exist on the server. More info in [issue #122](https://github.com/dayhaysoos/use-shopping-cart/issues/122)


## Contributing to use-shopping-cart

If you're working on this project **please check out
[the CONTRIBUTING.md file](https://github.com/dayhaysoos/use-shopping-cart/blob/master/use-shopping-cart/CONTRIBUTING.md)**.


## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="http://www.kevincunningham.co.uk"><img src="https://avatars3.githubusercontent.com/u/8320213?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin Cunningham</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=doingandlearning" title="Tests">⚠️</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=doingandlearning" title="Code">💻</a></td>
<td align="center"><a href="https://ianjones.us/"><img src="https://avatars2.githubusercontent.com/u/4407263?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ian Jones</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=theianjones" title="Tests">⚠️</a></td>
<td align="center"><a href="https://chrisbrownie.dev/"><img src="https://avatars2.githubusercontent.com/u/19195374?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chris Brown</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=ChrisBrownie55" title="Tests">⚠️</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=ChrisBrownie55" title="Code">💻</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=ChrisBrownie55" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/dayhaysoos"><img src="https://avatars3.githubusercontent.com/u/1852675?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nick DeJesus</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=dayhaysoos" title="Code">💻</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=dayhaysoos" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/dayhaysoos"><img src="https://avatars3.githubusercontent.com/u/1852675?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nick DeJesus</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=dayhaysoos" title="Tests">⚠️</a> <a href="#blog-dayhaysoos" title="Blogposts">📝</a> <a href="#business-dayhaysoos" title="Business development">💼</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/issues?q=author%3Adayhaysoos" title="Bug reports">🐛</a> <a href="#data-dayhaysoos" title="Data">🔣</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=dayhaysoos" title="Documentation">📖</a> <a href="#fundingFinding-dayhaysoos" title="Funding Finding">🔍</a> <a href="#infra-dayhaysoos" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#projectManagement-dayhaysoos" title="Project Management">📆</a> <a href="#question-dayhaysoos" title="Answering Questions">💬</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/pulls?q=is%3Apr+reviewed-by%3Adayhaysoos" title="Reviewed Pull Requests">👀</a> <a href="#security-dayhaysoos" title="Security">🛡️</a></td>
<td align="center"><a href="http://shodipoayomide.com"><img src="https://avatars2.githubusercontent.com/u/20538832?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shodipo Ayomide</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=Developerayo" title="Documentation">📖</a></td>
<td align="center"><a href="http://appbureauet.dk"><img src="https://avatars1.githubusercontent.com/u/167574?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Anders Bech Mellson</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=mellson" title="Code">💻</a></td>
<td align="center"><a href="https://thorweb.dev"><img src="https://avatars0.githubusercontent.com/u/23213994?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Thor 雷神</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=thorsten-stripe" title="Documentation">📖</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=thorsten-stripe" title="Code">💻</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=thorsten-stripe" title="Tests">⚠️</a></td>
<td align="center"><a href="https://ryan.warner.codes"><img src="https://avatars2.githubusercontent.com/u/1595979?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ryan Warner</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=RyanWarner" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="https://ryan.warner.codes"><img src="https://avatars2.githubusercontent.com/u/1595979?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ryan Warner</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=RyanWarner" title="Documentation">📖</a></td>
<td align="center"><a href="http://horacioh.com"><img src="https://avatars3.githubusercontent.com/u/725120?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Horacio Herrera</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=horacioh" title="Documentation">📖</a></td>
<td align="center"><a href="https://bdougie.live"><img src="https://avatars2.githubusercontent.com/u/5713670?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Brian Douglas</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=bdougie" title="Documentation">📖</a></td>
<td align="center"><a href="https://bdesigned.netlify.com/"><img src="https://avatars2.githubusercontent.com/u/45889730?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Brittney Postma</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=brittneypostma" title="Documentation">📖</a></td>
<td align="center"><a href="https://prince.dev"><img src="https://avatars1.githubusercontent.com/u/8431042?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Prince Wilson</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=maxcell" title="Documentation">📖</a></td>
<td align="center"><a href="https://www.erichowey.dev/"><img src="https://avatars.githubusercontent.com/u/204841?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eric Howey</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=ehowey" title="Documentation">📖</a></td>
<td align="center"><a href="https://www.erichowey.dev/"><img src="https://avatars.githubusercontent.com/u/204841?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eric Howey</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=ehowey" title="Documentation">📖</a> <a href="#plugin-ehowey" title="Plugin/utility libraries">🔌</a></td>
<td align="center"><a href="https://github.com/hideokamoto-stripe"><img src="https://avatars.githubusercontent.com/u/95597878?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hidetaka Okamoto</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=hideokamoto-stripe" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/andria-dev"><img src="https://avatars.githubusercontent.com/u/19195374?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andria Brown</b></sub></a><br /><a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=andria-dev" title="Tests">⚠️</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=andria-dev" title="Code">💻</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/commits?author=andria-dev" title="Documentation">📖</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/issues?q=author%3Aandria-dev" title="Bug reports">🐛</a> <a href="#example-andria-dev" title="Examples">💡</a> <a href="#infra-andria-dev" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-andria-dev" title="Maintenance">🚧</a> <a href="#ideas-andria-dev" title="Ideas, Planning, & Feedback">🤔</a> <a href="#question-andria-dev" title="Answering Questions">💬</a> <a href="https://github.com/dayhaysoos/use-shopping-cart/pulls?q=is%3Apr+reviewed-by%3Aandria-dev" title="Reviewed Pull Requests">👀</a></td>
</tr>
</table>

Expand All @@ -74,7 +71,6 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!


## License

MIT © [dayhaysoos](https://github.com/dayhaysoos)
MIT © [dayhaysoos](https://github.com/dayhaysoos)
131 changes: 0 additions & 131 deletions docs/docs/contributors.mdx

This file was deleted.

Loading

0 comments on commit a7c64e4

Please sign in to comment.