Skip to content

Commit 241adb8

Browse files
refactor: ♻️ move to tsup (#31)
- moved to `tsup` since `tsdx` is unmaintained - moved to css auto inject script rather then inlining them to keep things easy - added recommended plugins and vscode configs - added `disableNative` prop - moved from default exports to named exports - most components now have classes associated to them so you can easily override them
1 parent 1a94fd8 commit 241adb8

33 files changed

+4384
-8214
lines changed

.eslintrc.cjs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
es2021: true,
6+
node: true,
7+
},
8+
parser: "@typescript-eslint/parser",
9+
plugins: ["@typescript-eslint", "prettier", "simple-import-sort"],
10+
extends: [
11+
"eslint:recommended",
12+
"plugin:@typescript-eslint/eslint-recommended",
13+
"plugin:@typescript-eslint/recommended",
14+
"plugin:react/recommended",
15+
"plugin:storybook/recommended",
16+
],
17+
rules: {
18+
"@typescript-eslint/ban-ts-comment": "off",
19+
"@typescript-eslint/ban-ts-ignore": "off",
20+
"@typescript-eslint/camelcase": "off",
21+
"@typescript-eslint/explicit-function-return-type": "off",
22+
"@typescript-eslint/explicit-module-boundary-types": "off",
23+
"@typescript-eslint/interface-name-prefix": "off",
24+
"@typescript-eslint/no-empty-interface": "off",
25+
"@typescript-eslint/no-explicit-any": "off",
26+
"@typescript-eslint/no-unused-vars": [
27+
"error",
28+
{
29+
ignoreRestSiblings: true,
30+
},
31+
],
32+
"no-case-declarations": "off",
33+
"no-console": [
34+
"error",
35+
{
36+
allow: ["warn", "error", "debug"],
37+
},
38+
],
39+
"no-useless-escape": "off",
40+
"prettier/prettier": "error",
41+
"react/display-name": "off",
42+
"react/jsx-key": "off",
43+
"react/no-children-prop": "off",
44+
"react/prop-types": "off",
45+
"simple-import-sort/exports": "error",
46+
"simple-import-sort/imports": "error",
47+
},
48+
settings: {
49+
react: {
50+
version: "detect",
51+
},
52+
},
53+
};

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**Sandbox / Git Repo**
14+
<!-- Pleaseeee fork below template and create a reproduction -->
15+
https://codesandbox.io/s/react-web-share-46skt
16+
17+
**To Reproduce**
18+
Steps to reproduce the behavior:
19+
1. Go to '...'
20+
2. Click on '....'
21+
3. Scroll down to '....'
22+
4. See error
23+
24+
**Expected behavior**
25+
A clear and concise description of what you expected to happen.
26+
27+
**Screenshots**
28+
If applicable, add screenshots to help explain your problem.
29+
30+
**Desktop (please complete the following information):**
31+
- OS: [e.g. iOS]
32+
- Browser [e.g. chrome, safari]
33+
- Version [e.g. 22]
34+
35+
**Smartphone (please complete the following information):**
36+
- Device: [e.g. iPhone6]
37+
- OS: [e.g. iOS8.1]
38+
- Browser [e.g. stock browser, safari]
39+
- Version [e.g. 22]
40+
41+
**Additional context**
42+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: monthly
7+
time: "23:30"
8+
open-pull-requests-limit: 10

.github/workflows/main.yml

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
1-
name: NodeJS
1+
name: CI
2+
23
on: [push]
4+
35
jobs:
46
build:
5-
runs-on: ubuntu-latest
7+
name: Node ${{ matrix.node }} on ${{ matrix.os }}
8+
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
node: ["16.x"]
13+
os: [ubuntu-latest, windows-latest, macOS-latest]
614

715
steps:
8-
- name: Begin CI...
16+
- name: Checkout repo
917
uses: actions/checkout@v2
1018

11-
- name: Use Node 14
12-
uses: actions/setup-node@v1
19+
- name: Use Node ${{ matrix.node }}
20+
uses: actions/setup-node@v2
1321
with:
14-
node-version: 14.x
22+
node-version: ${{ matrix.node }}
1523

16-
- name: Use cached node_modules
17-
uses: actions/cache@v1
18-
with:
19-
path: node_modules
20-
key: nodeModules-${{ hashFiles('**/yarn.lock') }}
21-
restore-keys: |
22-
nodeModules-
24+
- name: Install deps and build (with cache)
25+
uses: bahmutov/npm-install@v1
2326

24-
- name: Install dependencies
25-
run: yarn install --frozen-lockfile
26-
env:
27-
CI: true
27+
- name: Lint
28+
run: yarn lint
2829

2930
- name: Build
3031
run: yarn build
31-
env:
32-
CI: true
33-
34-
- name: Publish
35-
if: startsWith(github.ref, 'refs/tags/')
36-
run: echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > ~/.npmrc && npm publish --access public
37-
env:
38-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: RELEASE
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.[0-9]+.[0-9]+
7+
8+
jobs:
9+
test:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v2
16+
17+
- name: Setup node
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: 16.x
21+
registry-url: https://registry.npmjs.org
22+
23+
- name: Install deps and build (with cache)
24+
uses: bahmutov/npm-install@v1
25+
26+
- name: Lint
27+
run: yarn lint
28+
29+
- name: Build
30+
run: yarn build
31+
32+
- name: Publishing to NPM
33+
env:
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
35+
run: npm publish

.husky/pre-commit

Lines changed: 0 additions & 4 deletions
This file was deleted.

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": false
7+
}

.storybook/main.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
module.exports = {
2-
stories: ["../stories/**/*.stories.@(ts|tsx|js|jsx)"],
2+
stories: [
3+
"../stories/**/*.stories.mdx",
4+
"../stories/**/*.stories.@(js|jsx|ts|tsx)",
5+
],
36
addons: [
4-
"@storybook/addon-essentials",
57
"@storybook/addon-links",
6-
"@storybook/addon-knobs",
7-
"@storybook/addon-storysource",
8+
"@storybook/addon-essentials",
9+
{
10+
name: '@storybook/addon-docs',
11+
options: {
12+
configureJSX: true,
13+
transcludeMarkdown: true,
14+
},
15+
},
816
],
9-
// https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration
10-
typescript: {
11-
check: true, // type-check stories during Storybook build
12-
},
17+
framework: "@storybook/react",
1318
};

.storybook/preview-head.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#root {
99
height: 100%;
1010
font-family: sans-serif;
11-
padding: 0!important;
12-
margin: 0!important;
11+
padding: 0 !important;
12+
margin: 0 !important;
1313
}
1414

1515
.multi-select {

.storybook/preview.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
// https://storybook.js.org/docs/react/writing-stories/parameters#global-parameters
21
export const parameters = {
3-
// https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args
4-
actions: { argTypesRegex: "^on.*" },
5-
};
2+
actions: { argTypesRegex: "^on[A-Z].*" },
3+
controls: {
4+
matchers: {
5+
color: /(background|color)$/i,
6+
date: /Date$/,
7+
},
8+
},
9+
}

.vscode/extensions.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"dsznajder.es7-react-js-snippets",
5+
"esbenp.prettier-vscode",
6+
"meganrogge.template-string-converter",
7+
"paragdiwan.gitpatch",
8+
"shardulm94.trailing-spaces",
9+
"wix.vscode-import-cost",
10+
"formulahendry.auto-rename-tag"
11+
]
12+
}

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"workbench.colorCustomizations": {
3+
"activityBar.background": "#5a56a0",
4+
"titleBar.activeBackground": "#604e98",
5+
"titleBar.activeForeground": "#FBFAF9"
6+
}
7+
}

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Tiny [Web Share API](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/
66
[![NPM](https://img.shields.io/npm/v/react-web-share.svg)](https://npm.im/react-web-share)
77
[![gzip](https://badgen.net/bundlephobia/minzip/react-web-share@latest)](https://bundlephobia.com/result?p=react-web-share@latest)
88

9-
[![Edit react-web-share](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-web-share-46skt?fontsize=14&hidenavigation=1&theme=dark)
9+
[![Edit react-web-share](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-web-share-46skt)
1010

1111
> 💡 most browsers restricts web share api only to https websites
1212
@@ -27,11 +27,11 @@ yarn add react-web-share # yarn
2727

2828
### Mobile
2929

30-
![Mobile Preview](preview/preview-mobile.jpg)
30+
![Mobile Preview](https://user-images.githubusercontent.com/5774849/188565874-177a6cc4-0521-4f14-8339-4c31f1476a5d.jpg)
3131

3232
### Desktop
3333

34-
![Desktop Preview](preview/preview-desktop.jpg)
34+
![Desktop Preview](https://user-images.githubusercontent.com/5774849/188565984-5782d979-b57b-4b6d-9135-591f77ea8ee7.jpg)
3535

3636
## 📦 Example
3737

@@ -61,12 +61,13 @@ export default Example;
6161

6262
## 👀 Props
6363

64-
| Prop | Description | Type | Default |
65-
| ----------- | --------------------------- | -------------------- | --------------------------------------------- |
66-
| `data` | Share Object | `{text, url, title}` | `{text: "", url: currentURL, title: "Share"}` |
67-
| `sites` | sites | `string[]` | all platforms (see list below for key list) |
68-
| `closeText` | translate close | `string` | localise close text |
69-
| `onClick` | callback on sucessful share | | |
64+
| Prop | Description | Type | Default |
65+
| --------------- | --------------------------- | -------------------- | --------------------------------------------- |
66+
| `data` | Share Object | `{text, url, title}` | `{text: "", url: currentURL, title: "Share"}` |
67+
| `sites` | sites | `string[]` | all platforms (see list below for key list) |
68+
| `closeText` | translate close | `string` | localise close text |
69+
| `onClick` | callback on sucessful share | | |
70+
| `disableNative` | disables native share | `boolean` | `false` |
7071

7172
## 🌎 Sites
7273

0 commit comments

Comments
 (0)