Skip to content

Commit e2fb0f8

Browse files
refactor: ♻️ added few more social networks
1 parent 5c44d9c commit e2fb0f8

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Tiny [Web Share API](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/
1212
1313
## ✨ Features
1414

15-
- 🍃 Only ~3kb gzipped and no external dependencies
15+
- 🍃 Only ~6kb gzipped and no external dependencies
1616
- 🌀 Uses React Portal
1717
- ✌ Written w/ TypeScript
1818

@@ -61,11 +61,12 @@ 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-
| `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 | | |
6970

7071
## 🌎 Sites
7172

@@ -77,11 +78,8 @@ export default Example;
7778
- linkedin
7879
- mail
7980
- copy (Copy to Clipboard)
80-
81-
## 🤠 Credits
82-
83-
- [TypeScript](https://github.com/microsoft/typescript)
84-
- [TSDX](https://github.com/jaredpalmer/tsdx)
81+
- vk
82+
- okru
8583

8684
## 📜 License
8785

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-web-share",
33
"author": "Harsh Zalavadiya",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"license": "MIT",
66
"repository": "harshzalavadiya/react-web-share",
77
"module": "dist/react-web-share.esm.js",

src/components/icon/list.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ const iconList: IconListType = {
7171
color: "#718096",
7272
e: (l) => navigator.clipboard.writeText(decodeURIComponent(l)),
7373
},
74+
vk: {
75+
path: (
76+
<path d="M22.7 6.24c.16-.52 0-.9-.73-.9H19.5c-.62 0-.91.32-1.06.69 0 0-1.25 3.04-3.02 5.02-.57.57-.83.75-1.15.75-.15 0-.39-.18-.39-.7V6.24c0-.63-.17-.9-.69-.9H9.34c-.39 0-.62.29-.62.56 0 .59.88.72.97 2.4v3.6c0 .8-.14.95-.45.95-.84 0-2.86-3.06-4.06-6.56-.24-.68-.48-.96-1.1-.96H1.61c-.7 0-.85.33-.85.7 0 .65.84 3.88 3.88 8.14 2.03 2.92 4.9 4.5 7.5 4.5 1.55 0 1.75-.35 1.75-.96 0-2.78-.15-3.04.64-3.04.36 0 .99.18 2.44 1.58 1.67 1.67 1.95 2.42 2.88 2.42h2.45c.7 0 1.06-.35.85-1.05-.46-1.45-3.62-4.44-3.76-4.64-.36-.47-.26-.68 0-1.1 0 0 3-4.21 3.3-5.64Z" />
77+
),
78+
color: "#07f",
79+
e: (l, t, ti) => externalOpen(`http://vk.com/share.php?url=${l}&title=${ti}&comment=${t}`),
80+
},
81+
okru: {
82+
path: (
83+
<path d="M13.6 16.4c1-.3 2-.7 2.8-1.2a1.5 1.5 0 0 0-1.5-2.5 6.3 6.3 0 0 1-6.7 0 1.5 1.5 0 1 0-1.5 2.5c.9.5 1.8 1 2.9 1.2L6.8 19a1.4 1.4 0 1 0 2 2l2.8-2.6 2.7 2.7a1.5 1.5 0 1 0 2-2l-2.7-2.8Zm-2-11.1a2 2 0 1 1 0 4.1 2 2 0 0 1 0-4.1Zm0 7a5 5 0 1 0 0-10 5 5 0 0 0 0 10Z" />
84+
),
85+
color: "#e27e35",
86+
e: (l) => externalOpen(`https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=${l}`),
87+
},
7488
};
7589

7690
export default iconList;

src/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RWebShareProps } from "interfaces";
1+
import { RWebShareProps } from "./interfaces";
22
import React, { cloneElement, useMemo } from "react";
33

44
import Backdrop from "./components/backdrop";
@@ -7,12 +7,14 @@ import Portal from "./components/portal";
77
import SocialIcons from "./components/social-icons";
88
import useDisclosure from "./hooks/use-disclosure";
99

10+
const defaultSites = Object.keys(iconList).slice(0, 8);
11+
1012
export const RWebShare = ({
1113
children,
1214
closeText,
1315
data,
1416
onClick,
15-
sites = Object.keys(iconList),
17+
sites = defaultSites,
1618
}: RWebShareProps) => {
1719
const { onOpen, onClose, isOpen } = useDisclosure();
1820

@@ -27,7 +29,7 @@ export const RWebShare = ({
2729
);
2830

2931
const handleOnClick = async () => {
30-
if (window.navigator.share) {
32+
if (!window.navigator.share) {
3133
try {
3234
await window.navigator.share(shareData);
3335
onClick();

src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface RWebShareProps {
88
children: any;
99
closeText?: string;
1010
data: ShareData;
11-
sites: string[];
11+
sites?: string[];
1212
onClick?;
1313
}
1414

0 commit comments

Comments
 (0)