@xyo-network/react-share 2.56.15 → 2.56.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ShareButton.js +4 -3
- package/dist/cjs/ShareButton.js.map +1 -1
- package/dist/docs.json +39 -13
- package/dist/esm/ShareButton.js +4 -3
- package/dist/esm/ShareButton.js.map +1 -1
- package/dist/types/ShareButton.d.ts +1 -0
- package/dist/types/ShareButton.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ShareButton.stories.tsx +5 -1
- package/src/ShareButton.tsx +5 -3
package/dist/cjs/ShareButton.js
CHANGED
|
@@ -12,16 +12,17 @@ const react_flexbox_1 = require("@xylabs/react-flexbox");
|
|
|
12
12
|
const react_link_1 = require("@xylabs/react-link");
|
|
13
13
|
const react_1 = require("react");
|
|
14
14
|
const ShareButton = (_a) => {
|
|
15
|
-
var { prepared = true } = _a, props = tslib_1.__rest(_a, ["prepared"]);
|
|
15
|
+
var { prepared = true, shareLink } = _a, props = tslib_1.__rest(_a, ["prepared", "shareLink"]);
|
|
16
16
|
const [expanded, setExpanded] = (0, react_1.useState)(false);
|
|
17
17
|
const anchorRef = (0, react_1.useRef)(null);
|
|
18
|
+
const link = shareLink !== null && shareLink !== void 0 ? shareLink : window.location.href;
|
|
18
19
|
return ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexRow, Object.assign({ gap: 1, ref: anchorRef }, { children: [(0, jsx_runtime_1.jsx)(react_button_1.ButtonEx, Object.assign({ variant: "text", minWidth: 32, size: "small", disabled: !prepared, onClick: () => {
|
|
19
20
|
setExpanded(true);
|
|
20
21
|
} }, props, { children: (0, jsx_runtime_1.jsx)(Share_1.default, { htmlColor: "gray", fontSize: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.Popover, Object.assign({ open: prepared ? expanded : false, anchorEl: anchorRef.current, onClose: () => setExpanded(false), transitionDuration: 500 }, { children: (0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexRow, Object.assign({ gap: 0.5, padding: 0.5 }, { children: [(0, jsx_runtime_1.jsx)(react_link_1.LinkEx, Object.assign({ lineHeight: 0, style: { color: '#1da1f2' }, onClick: () => {
|
|
21
|
-
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(
|
|
22
|
+
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`);
|
|
22
23
|
setExpanded(false);
|
|
23
24
|
} }, { children: (0, jsx_runtime_1.jsx)(Twitter_1.default, { fontSize: "small" }) })), (0, jsx_runtime_1.jsx)(react_link_1.LinkEx, Object.assign({ lineHeight: 0, style: { color: '#4267b2' }, onClick: () => {
|
|
24
|
-
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(
|
|
25
|
+
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`);
|
|
25
26
|
setExpanded(false);
|
|
26
27
|
} }, { children: (0, jsx_runtime_1.jsx)(Facebook_1.default, { fontSize: "small" }) }))] })) }))] })));
|
|
27
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.js","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":";;;;;AAAA,oFAAuD;AACvD,8EAAiD;AACjD,kFAAqD;AACrD,4CAAuC;AACvC,uDAA8D;AAC9D,yDAA+C;AAC/C,mDAA2C;AAC3C,iCAAwC;
|
|
1
|
+
{"version":3,"file":"ShareButton.js","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":";;;;;AAAA,oFAAuD;AACvD,8EAAiD;AACjD,kFAAqD;AACrD,4CAAuC;AACvC,uDAA8D;AAC9D,yDAA+C;AAC/C,mDAA2C;AAC3C,iCAAwC;AAOjC,MAAM,WAAW,GAA+B,CAAC,EAAwC,EAAE,EAAE;QAA5C,EAAE,QAAQ,GAAG,IAAI,EAAE,SAAS,OAAY,EAAP,KAAK,sBAAtC,yBAAwC,CAAF;IAC5F,MAAM,CAAC,QAA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AM,kBACL,UAAU,EAAE,CAAC,EACb,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAC3B,OAAO,EAAE,GAAG,EAAE;gCACZ,MAAM,CAAC,IAAI,CAAC,gDAAgD,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gCACvF,WAAW,CAAC,KAAK,CAAC,CAAA;4BACpB,CAAC,gBAED,uBAAC,kBAAY,IAAC,QAAQ,EAAC,OAAO,GAAG,IAC1B,KACD,IACF,KACF,CACX,CAAA;AACH,CAAC,CAAA;AA7CY,QAAA,WAAW,eA6CvB"}
|
package/dist/docs.json
CHANGED
|
@@ -25,20 +25,42 @@
|
|
|
25
25
|
"fileName": "packages/sdk/packages/share/src/ShareButton.tsx",
|
|
26
26
|
"line": 11,
|
|
27
27
|
"character": 2,
|
|
28
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
28
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/7ca61dd74/packages/sdk/packages/share/src/ShareButton.tsx#L11"
|
|
29
29
|
}
|
|
30
30
|
],
|
|
31
31
|
"type": {
|
|
32
32
|
"type": "intrinsic",
|
|
33
33
|
"name": "boolean"
|
|
34
34
|
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": 3,
|
|
38
|
+
"name": "shareLink",
|
|
39
|
+
"variant": "declaration",
|
|
40
|
+
"kind": 1024,
|
|
41
|
+
"flags": {
|
|
42
|
+
"isOptional": true
|
|
43
|
+
},
|
|
44
|
+
"sources": [
|
|
45
|
+
{
|
|
46
|
+
"fileName": "packages/sdk/packages/share/src/ShareButton.tsx",
|
|
47
|
+
"line": 12,
|
|
48
|
+
"character": 2,
|
|
49
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/7ca61dd74/packages/sdk/packages/share/src/ShareButton.tsx#L12"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"type": {
|
|
53
|
+
"type": "intrinsic",
|
|
54
|
+
"name": "string"
|
|
55
|
+
}
|
|
35
56
|
}
|
|
36
57
|
],
|
|
37
58
|
"groups": [
|
|
38
59
|
{
|
|
39
60
|
"title": "Properties",
|
|
40
61
|
"children": [
|
|
41
|
-
2
|
|
62
|
+
2,
|
|
63
|
+
3
|
|
42
64
|
]
|
|
43
65
|
}
|
|
44
66
|
],
|
|
@@ -47,7 +69,7 @@
|
|
|
47
69
|
"fileName": "packages/sdk/packages/share/src/ShareButton.tsx",
|
|
48
70
|
"line": 10,
|
|
49
71
|
"character": 17,
|
|
50
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
72
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/7ca61dd74/packages/sdk/packages/share/src/ShareButton.tsx#L10"
|
|
51
73
|
}
|
|
52
74
|
],
|
|
53
75
|
"extendedTypes": [
|
|
@@ -63,7 +85,7 @@
|
|
|
63
85
|
]
|
|
64
86
|
},
|
|
65
87
|
{
|
|
66
|
-
"id":
|
|
88
|
+
"id": 4,
|
|
67
89
|
"name": "ShareButton",
|
|
68
90
|
"variant": "declaration",
|
|
69
91
|
"kind": 64,
|
|
@@ -71,14 +93,14 @@
|
|
|
71
93
|
"sources": [
|
|
72
94
|
{
|
|
73
95
|
"fileName": "packages/sdk/packages/share/src/ShareButton.tsx",
|
|
74
|
-
"line":
|
|
96
|
+
"line": 15,
|
|
75
97
|
"character": 13,
|
|
76
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
98
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/7ca61dd74/packages/sdk/packages/share/src/ShareButton.tsx#L15"
|
|
77
99
|
}
|
|
78
100
|
],
|
|
79
101
|
"signatures": [
|
|
80
102
|
{
|
|
81
|
-
"id":
|
|
103
|
+
"id": 5,
|
|
82
104
|
"name": "ShareButton",
|
|
83
105
|
"variant": "signature",
|
|
84
106
|
"kind": 4096,
|
|
@@ -92,7 +114,7 @@
|
|
|
92
114
|
],
|
|
93
115
|
"parameters": [
|
|
94
116
|
{
|
|
95
|
-
"id":
|
|
117
|
+
"id": 6,
|
|
96
118
|
"name": "props",
|
|
97
119
|
"variant": "param",
|
|
98
120
|
"kind": 32768,
|
|
@@ -105,7 +127,7 @@
|
|
|
105
127
|
}
|
|
106
128
|
},
|
|
107
129
|
{
|
|
108
|
-
"id":
|
|
130
|
+
"id": 7,
|
|
109
131
|
"name": "context",
|
|
110
132
|
"variant": "param",
|
|
111
133
|
"kind": 32768,
|
|
@@ -161,7 +183,7 @@
|
|
|
161
183
|
{
|
|
162
184
|
"title": "Functions",
|
|
163
185
|
"children": [
|
|
164
|
-
|
|
186
|
+
4
|
|
165
187
|
]
|
|
166
188
|
}
|
|
167
189
|
],
|
|
@@ -187,17 +209,21 @@
|
|
|
187
209
|
},
|
|
188
210
|
"3": {
|
|
189
211
|
"sourceFileName": "src/ShareButton.tsx",
|
|
190
|
-
"qualifiedName": "
|
|
212
|
+
"qualifiedName": "ShareButtonProps.shareLink"
|
|
191
213
|
},
|
|
192
214
|
"4": {
|
|
193
|
-
"sourceFileName": "
|
|
215
|
+
"sourceFileName": "src/ShareButton.tsx",
|
|
194
216
|
"qualifiedName": "ShareButton"
|
|
195
217
|
},
|
|
196
218
|
"5": {
|
|
197
219
|
"sourceFileName": "../../../../node_modules/@types/react/ts5.0/index.d.ts",
|
|
198
|
-
"qualifiedName": "
|
|
220
|
+
"qualifiedName": "ShareButton"
|
|
199
221
|
},
|
|
200
222
|
"6": {
|
|
223
|
+
"sourceFileName": "../../../../node_modules/@types/react/ts5.0/index.d.ts",
|
|
224
|
+
"qualifiedName": "props"
|
|
225
|
+
},
|
|
226
|
+
"7": {
|
|
201
227
|
"sourceFileName": "../../../../node_modules/@types/react/ts5.0/index.d.ts",
|
|
202
228
|
"qualifiedName": "context"
|
|
203
229
|
}
|
package/dist/esm/ShareButton.js
CHANGED
|
@@ -7,16 +7,17 @@ import { ButtonEx } from '@xylabs/react-button';
|
|
|
7
7
|
import { FlexRow } from '@xylabs/react-flexbox';
|
|
8
8
|
import { LinkEx } from '@xylabs/react-link';
|
|
9
9
|
import { useRef, useState } from 'react';
|
|
10
|
-
export const ShareButton = ({ prepared = true, ...props }) => {
|
|
10
|
+
export const ShareButton = ({ prepared = true, shareLink, ...props }) => {
|
|
11
11
|
const [expanded, setExpanded] = useState(false);
|
|
12
12
|
const anchorRef = useRef(null);
|
|
13
|
+
const link = shareLink ?? window.location.href;
|
|
13
14
|
return (_jsxs(FlexRow, { gap: 1, ref: anchorRef, children: [_jsx(ButtonEx, { variant: "text", minWidth: 32, size: "small", disabled: !prepared, onClick: () => {
|
|
14
15
|
setExpanded(true);
|
|
15
16
|
}, ...props, children: _jsx(ShareIcon, { htmlColor: "gray", fontSize: "small" }) }), _jsx(Popover, { open: prepared ? expanded : false, anchorEl: anchorRef.current, onClose: () => setExpanded(false), transitionDuration: 500, children: _jsxs(FlexRow, { gap: 0.5, padding: 0.5, children: [_jsx(LinkEx, { lineHeight: 0, style: { color: '#1da1f2' }, onClick: () => {
|
|
16
|
-
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(
|
|
17
|
+
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`);
|
|
17
18
|
setExpanded(false);
|
|
18
19
|
}, children: _jsx(TwitterIcon, { fontSize: "small" }) }), _jsx(LinkEx, { lineHeight: 0, style: { color: '#4267b2' }, onClick: () => {
|
|
19
|
-
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(
|
|
20
|
+
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`);
|
|
20
21
|
setExpanded(false);
|
|
21
22
|
}, children: _jsx(FacebookIcon, { fontSize: "small" }) })] }) })] }));
|
|
22
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.js","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":";A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,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ButtonExProps } from '@xylabs/react-button';
|
|
3
3
|
export interface ShareButtonProps extends ButtonExProps {
|
|
4
4
|
prepared?: boolean;
|
|
5
|
+
shareLink?: string;
|
|
5
6
|
}
|
|
6
7
|
export declare const ShareButton: React.FC<ShareButtonProps>;
|
|
7
8
|
//# sourceMappingURL=ShareButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAK9D,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAK9D,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6ClD,CAAA"}
|
package/package.json
CHANGED
|
@@ -13,7 +13,11 @@ const Template: StoryFn<typeof ShareButton> = (props) => {
|
|
|
13
13
|
|
|
14
14
|
const Default = Template.bind({})
|
|
15
15
|
Default.args = {}
|
|
16
|
+
|
|
16
17
|
const WithUnPrepared = Template.bind({})
|
|
17
18
|
WithUnPrepared.args = { prepared: false }
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
const WithCustomShareLink = Template.bind({})
|
|
21
|
+
WithCustomShareLink.args = { shareLink: 'http://explore.xyo.network' }
|
|
22
|
+
|
|
23
|
+
export { Default, WithCustomShareLink, WithUnPrepared }
|
package/src/ShareButton.tsx
CHANGED
|
@@ -9,11 +9,13 @@ import { useRef, useState } from 'react'
|
|
|
9
9
|
|
|
10
10
|
export interface ShareButtonProps extends ButtonExProps {
|
|
11
11
|
prepared?: boolean
|
|
12
|
+
shareLink?: string
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export const ShareButton: React.FC<ShareButtonProps> = ({ prepared = true, ...props }) => {
|
|
15
|
+
export const ShareButton: React.FC<ShareButtonProps> = ({ prepared = true, shareLink, ...props }) => {
|
|
15
16
|
const [expanded, setExpanded] = useState(false)
|
|
16
17
|
const anchorRef = useRef(null)
|
|
18
|
+
const link = shareLink ?? window.location.href
|
|
17
19
|
|
|
18
20
|
return (
|
|
19
21
|
<FlexRow gap={1} ref={anchorRef}>
|
|
@@ -35,7 +37,7 @@ export const ShareButton: React.FC<ShareButtonProps> = ({ prepared = true, ...pr
|
|
|
35
37
|
lineHeight={0}
|
|
36
38
|
style={{ color: '#1da1f2' }}
|
|
37
39
|
onClick={() => {
|
|
38
|
-
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(
|
|
40
|
+
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`)
|
|
39
41
|
setExpanded(false)
|
|
40
42
|
}}
|
|
41
43
|
>
|
|
@@ -45,7 +47,7 @@ export const ShareButton: React.FC<ShareButtonProps> = ({ prepared = true, ...pr
|
|
|
45
47
|
lineHeight={0}
|
|
46
48
|
style={{ color: '#4267b2' }}
|
|
47
49
|
onClick={() => {
|
|
48
|
-
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(
|
|
50
|
+
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`)
|
|
49
51
|
setExpanded(false)
|
|
50
52
|
}}
|
|
51
53
|
>
|