@xyo-network/react-share 2.82.0 → 2.83.1
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/browser/index.d.ts +60 -2
- package/dist/browser/index.mjs +224 -2
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +7 -22
- package/src/button/index.ts +1 -0
- package/src/icons/index.ts +1 -0
- package/src/icons/social/Facebook.tsx +10 -0
- package/src/icons/social/XTwitter.tsx +8 -0
- package/src/icons/social/index.ts +2 -0
- package/src/index.ts +3 -1
- package/src/out/CopyLinkTextField.stories.tsx +22 -0
- package/src/out/CopyLinkTextField.tsx +48 -0
- package/src/out/Dialog.stories.tsx +72 -0
- package/src/out/Dialog.tsx +42 -0
- package/src/out/Explanation.tsx +28 -0
- package/src/out/GenerateShareLinkButton.stories.tsx +22 -0
- package/src/out/GenerateShareLinkButton.tsx +26 -0
- package/src/out/HeadingFlexbox.tsx +24 -0
- package/src/out/SocialButtonsFlexbox.stories.tsx +22 -0
- package/src/out/SocialButtonsFlexbox.tsx +48 -0
- package/src/out/index.ts +6 -0
- package/xy.config.ts +12 -0
- package/dist/browser/ShareButton.d.cts +0 -8
- package/dist/browser/ShareButton.d.cts.map +0 -1
- package/dist/browser/ShareButton.d.mts +0 -8
- package/dist/browser/ShareButton.d.mts.map +0 -1
- package/dist/browser/ShareButton.d.ts +0 -8
- package/dist/browser/ShareButton.d.ts.map +0 -1
- package/dist/browser/index.cjs +0 -96
- package/dist/browser/index.cjs.map +0 -1
- package/dist/browser/index.d.cts +0 -2
- package/dist/browser/index.d.cts.map +0 -1
- package/dist/browser/index.d.mts +0 -2
- package/dist/browser/index.d.mts.map +0 -1
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/neutral/ShareButton.d.cts +0 -8
- package/dist/neutral/ShareButton.d.cts.map +0 -1
- package/dist/neutral/ShareButton.d.mts +0 -8
- package/dist/neutral/ShareButton.d.mts.map +0 -1
- package/dist/neutral/ShareButton.d.ts +0 -8
- package/dist/neutral/ShareButton.d.ts.map +0 -1
- package/dist/neutral/index.cjs +0 -96
- package/dist/neutral/index.cjs.map +0 -1
- package/dist/neutral/index.d.cts +0 -2
- package/dist/neutral/index.d.cts.map +0 -1
- package/dist/neutral/index.d.mts +0 -2
- package/dist/neutral/index.d.mts.map +0 -1
- package/dist/neutral/index.d.ts +0 -2
- package/dist/neutral/index.d.ts.map +0 -1
- package/dist/neutral/index.mjs +0 -65
- package/dist/neutral/index.mjs.map +0 -1
- package/dist/node/ShareButton.d.cts +0 -8
- package/dist/node/ShareButton.d.cts.map +0 -1
- package/dist/node/ShareButton.d.mts +0 -8
- package/dist/node/ShareButton.d.mts.map +0 -1
- package/dist/node/ShareButton.d.ts +0 -8
- package/dist/node/ShareButton.d.ts.map +0 -1
- package/dist/node/index.cjs +0 -100
- package/dist/node/index.cjs.map +0 -1
- package/dist/node/index.d.cts +0 -2
- package/dist/node/index.d.cts.map +0 -1
- package/dist/node/index.d.mts +0 -2
- package/dist/node/index.d.mts.map +0 -1
- package/dist/node/index.d.ts +0 -2
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.mjs +0 -65
- package/dist/node/index.mjs.map +0 -1
- /package/src/{ShareButton.stories.tsx → button/ShareButton.stories.tsx} +0 -0
- /package/src/{ShareButton.tsx → button/ShareButton.tsx} +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { InfoOutlined } from '@mui/icons-material'
|
|
2
|
+
import { Tooltip, Typography, useTheme } from '@mui/material'
|
|
3
|
+
import { FlexGrowRow } from '@xylabs/react-flexbox'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
|
|
6
|
+
export interface ShareOutExplanationProps {
|
|
7
|
+
toolTipTitle?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const ShareOutExplanation: React.FC<ShareOutExplanationProps> = ({ toolTipTitle }) => {
|
|
11
|
+
const theme = useTheme()
|
|
12
|
+
const title = toolTipTitle ?? 'In order for your data to be publicly viewable, it needs to be saved to the XYO Network Public Archivist. Public data can be seen by your friends, and XYO can generate preview images for easier sharing on social media.'
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<FlexGrowRow alignItems="center">
|
|
16
|
+
<Typography variant="body2" paddingRight={0.5}>
|
|
17
|
+
What am I sharing?
|
|
18
|
+
</Typography>
|
|
19
|
+
<Tooltip
|
|
20
|
+
title={title}
|
|
21
|
+
placement="bottom"
|
|
22
|
+
>
|
|
23
|
+
<InfoOutlined fontSize="small" sx={{ fontSize: theme.typography.caption.fontSize }} />
|
|
24
|
+
</Tooltip>
|
|
25
|
+
</FlexGrowRow>
|
|
26
|
+
</>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { GenerateShareLinkButton } from './GenerateShareLinkButton.tsx'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'modules/ShareOut/GenerateShareLinkButton',
|
|
8
|
+
} as Meta<typeof GenerateShareLinkButton>
|
|
9
|
+
|
|
10
|
+
const Template: StoryFn<typeof GenerateShareLinkButton> = (props) => {
|
|
11
|
+
return <GenerateShareLinkButton {...props} />
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Default = Template.bind({})
|
|
15
|
+
Default.args = {}
|
|
16
|
+
|
|
17
|
+
const WithLoading = Template.bind({})
|
|
18
|
+
WithLoading.args = {
|
|
19
|
+
loading: true,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { Default, WithLoading }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Button, ButtonProps, CircularProgress, styled } from '@mui/material'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
export interface GenerateShareLinkButtonProps extends ButtonProps {
|
|
5
|
+
loading?: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const GenerateShareLinkButton: React.FC<GenerateShareLinkButtonProps> = ({ children = 'Generate My Share Link', loading, ...props }) => {
|
|
9
|
+
return (
|
|
10
|
+
<Button
|
|
11
|
+
variant="contained"
|
|
12
|
+
startIcon={loading ? <StyledCircularProgress size="small" /> : null}
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
{children}
|
|
16
|
+
</Button>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const StyledCircularProgress = styled(CircularProgress, { name: 'StyledCircularProgress' })(({ theme }) => ({
|
|
21
|
+
// ensure the color of the spinner is the same as the button color
|
|
22
|
+
color: theme.palette.getContrastText(theme.palette.primary.main),
|
|
23
|
+
height: '20px',
|
|
24
|
+
opacity: '.87',
|
|
25
|
+
width: '20px',
|
|
26
|
+
}))
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Typography } from '@mui/material'
|
|
2
|
+
import { FlexBoxProps, FlexGrowCol } from '@xylabs/react-flexbox'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
export interface ShareOutHeadingFlexboxProps extends FlexBoxProps {
|
|
6
|
+
shareLinkName?: string
|
|
7
|
+
shareUrl?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const ShareOutHeadingFlexbox: React.FC<ShareOutHeadingFlexboxProps> = ({ children, shareLinkName, shareUrl, ...props }) => {
|
|
11
|
+
const GenerateShareLinkExplanation = "When you generate your share link, we'll make a small amount of your data public so friends can check it out!"
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<FlexGrowCol alignItems="flex-start" paddingBottom={1} {...props}>
|
|
15
|
+
<Typography variant="body1" gutterBottom>
|
|
16
|
+
<strong>Your Share Link</strong>
|
|
17
|
+
</Typography>
|
|
18
|
+
<Typography variant="body1">
|
|
19
|
+
{shareUrl ? `Use this link or the buttons below to share ${shareLinkName}` : GenerateShareLinkExplanation}
|
|
20
|
+
</Typography>
|
|
21
|
+
{children}
|
|
22
|
+
</FlexGrowCol>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { SocialButtonsFlexbox } from './SocialButtonsFlexbox.tsx'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'modules/ShareOut/SocialButtonsFlexbox',
|
|
8
|
+
} as Meta<typeof SocialButtonsFlexbox>
|
|
9
|
+
|
|
10
|
+
const Template: StoryFn<typeof SocialButtonsFlexbox> = (props) => {
|
|
11
|
+
return <SocialButtonsFlexbox {...props} />
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Default = Template.bind({})
|
|
15
|
+
Default.args = {}
|
|
16
|
+
|
|
17
|
+
const WithShareUrl = Template.bind({})
|
|
18
|
+
WithShareUrl.args = {
|
|
19
|
+
shareUrl: 'https://google.com',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { Default, WithShareUrl }
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Typography } from '@mui/material'
|
|
2
|
+
import { ButtonEx } from '@xylabs/react-button'
|
|
3
|
+
import { FlexBoxProps, FlexGrowCol, FlexRow } from '@xylabs/react-flexbox'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
|
|
6
|
+
import { FacebookSvgIcon, XTwitterSvgIcon } from '../icons/index.ts'
|
|
7
|
+
|
|
8
|
+
export interface SocialButtonsFlexboxProps extends FlexBoxProps {
|
|
9
|
+
shareUrl?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const SocialButtonsFlexbox: React.FC<SocialButtonsFlexboxProps> = ({ shareUrl, ...props }) => {
|
|
13
|
+
return (
|
|
14
|
+
<FlexGrowCol alignItems="stretch" paddingTop={2} {...props}>
|
|
15
|
+
<Typography variant="body1" gutterBottom>
|
|
16
|
+
<strong>Share on Social Media</strong>
|
|
17
|
+
</Typography>
|
|
18
|
+
<FlexRow gap={0.5} sx={{ flexDirection: { md: 'row', xs: 'column' } }}>
|
|
19
|
+
{shareUrl
|
|
20
|
+
? (
|
|
21
|
+
<>
|
|
22
|
+
<ButtonEx
|
|
23
|
+
variant="contained"
|
|
24
|
+
style={{ backgroundColor: '#000', color: '#fff' }}
|
|
25
|
+
onClick={() => {
|
|
26
|
+
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}`)
|
|
27
|
+
}}
|
|
28
|
+
startIcon={<XTwitterSvgIcon width="20px" />}
|
|
29
|
+
>
|
|
30
|
+
Share on X (Twitter)
|
|
31
|
+
</ButtonEx>
|
|
32
|
+
<ButtonEx
|
|
33
|
+
variant="contained"
|
|
34
|
+
style={{ backgroundColor: '#4267b2', color: '#fff' }}
|
|
35
|
+
onClick={() => {
|
|
36
|
+
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`)
|
|
37
|
+
}}
|
|
38
|
+
startIcon={<FacebookSvgIcon />}
|
|
39
|
+
>
|
|
40
|
+
Share on Facebook
|
|
41
|
+
</ButtonEx>
|
|
42
|
+
</>
|
|
43
|
+
)
|
|
44
|
+
: null}
|
|
45
|
+
</FlexRow>
|
|
46
|
+
</FlexGrowCol>
|
|
47
|
+
)
|
|
48
|
+
}
|
package/src/out/index.ts
ADDED
package/xy.config.ts
ADDED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ButtonExProps } from '@xylabs/react-button';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export interface ShareButtonProps extends ButtonExProps {
|
|
4
|
-
prepared?: boolean;
|
|
5
|
-
shareLink?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ShareButton: React.FC<ShareButtonProps>;
|
|
8
|
-
//# sourceMappingURL=ShareButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ButtonExProps } from '@xylabs/react-button';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export interface ShareButtonProps extends ButtonExProps {
|
|
4
|
-
prepared?: boolean;
|
|
5
|
-
shareLink?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ShareButton: React.FC<ShareButtonProps>;
|
|
8
|
-
//# sourceMappingURL=ShareButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ButtonExProps } from '@xylabs/react-button';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export interface ShareButtonProps extends ButtonExProps {
|
|
4
|
-
prepared?: boolean;
|
|
5
|
-
shareLink?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ShareButton: React.FC<ShareButtonProps>;
|
|
8
|
-
//# sourceMappingURL=ShareButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,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/dist/browser/index.cjs
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var src_exports = {};
|
|
33
|
-
__export(src_exports, {
|
|
34
|
-
ShareButton: () => ShareButton
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(src_exports);
|
|
37
|
-
|
|
38
|
-
// src/ShareButton.tsx
|
|
39
|
-
var import_icons_material = require("@mui/icons-material");
|
|
40
|
-
var import_material = require("@mui/material");
|
|
41
|
-
var import_react_button = require("@xylabs/react-button");
|
|
42
|
-
var import_react_flexbox = require("@xylabs/react-flexbox");
|
|
43
|
-
var import_react_link = require("@xylabs/react-link");
|
|
44
|
-
var import_react = __toESM(require("react"), 1);
|
|
45
|
-
var ShareButton = /* @__PURE__ */ __name(({ prepared = true, shareLink, ...props }) => {
|
|
46
|
-
const [expanded, setExpanded] = (0, import_react.useState)(false);
|
|
47
|
-
const anchorRef = (0, import_react.useRef)(null);
|
|
48
|
-
const link = shareLink ?? window.location.href;
|
|
49
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react_flexbox.FlexRow, {
|
|
50
|
-
gap: 1,
|
|
51
|
-
ref: anchorRef
|
|
52
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_react_button.ButtonEx, {
|
|
53
|
-
variant: "text",
|
|
54
|
-
minWidth: 32,
|
|
55
|
-
size: "small",
|
|
56
|
-
disabled: !prepared,
|
|
57
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
58
|
-
setExpanded(true);
|
|
59
|
-
}, "onClick"),
|
|
60
|
-
...props
|
|
61
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Share, {
|
|
62
|
-
htmlColor: "gray",
|
|
63
|
-
fontSize: "small"
|
|
64
|
-
})), /* @__PURE__ */ import_react.default.createElement(import_material.Popover, {
|
|
65
|
-
open: prepared ? expanded : false,
|
|
66
|
-
anchorEl: anchorRef.current,
|
|
67
|
-
onClose: /* @__PURE__ */ __name(() => setExpanded(false), "onClose"),
|
|
68
|
-
transitionDuration: 500
|
|
69
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_react_flexbox.FlexRow, {
|
|
70
|
-
gap: 0.5,
|
|
71
|
-
padding: 0.5
|
|
72
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_react_link.LinkEx, {
|
|
73
|
-
lineHeight: 0,
|
|
74
|
-
style: {
|
|
75
|
-
color: "#1da1f2"
|
|
76
|
-
},
|
|
77
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
78
|
-
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`);
|
|
79
|
-
setExpanded(false);
|
|
80
|
-
}, "onClick")
|
|
81
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Twitter, {
|
|
82
|
-
fontSize: "small"
|
|
83
|
-
})), /* @__PURE__ */ import_react.default.createElement(import_react_link.LinkEx, {
|
|
84
|
-
lineHeight: 0,
|
|
85
|
-
style: {
|
|
86
|
-
color: "#4267b2"
|
|
87
|
-
},
|
|
88
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
89
|
-
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`);
|
|
90
|
-
setExpanded(false);
|
|
91
|
-
}, "onClick")
|
|
92
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Facebook, {
|
|
93
|
-
fontSize: "small"
|
|
94
|
-
})))));
|
|
95
|
-
}, "ShareButton");
|
|
96
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/ShareButton.tsx"],"sourcesContent":["export * from './ShareButton.tsx'\n","import { Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon } from '@mui/icons-material'\nimport { Popover } from '@mui/material'\nimport { ButtonEx, ButtonExProps } from '@xylabs/react-button'\nimport { FlexRow } from '@xylabs/react-flexbox'\nimport { LinkEx } from '@xylabs/react-link'\nimport React, { useRef, useState } from 'react'\n\nexport interface ShareButtonProps extends ButtonExProps {\n prepared?: boolean\n shareLink?: string\n}\n\nexport const ShareButton: React.FC<ShareButtonProps> = ({ prepared = true, shareLink, ...props }) => {\n const [expanded, setExpanded] = useState(false)\n const anchorRef = useRef(null)\n const link = shareLink ?? window.location.href\n\n return (\n <FlexRow gap={1} ref={anchorRef}>\n <ButtonEx\n variant=\"text\"\n minWidth={32}\n size=\"small\"\n disabled={!prepared}\n onClick={() => {\n setExpanded(true)\n }}\n {...props}\n >\n <ShareIcon htmlColor=\"gray\" fontSize=\"small\" />\n </ButtonEx>\n <Popover open={prepared ? expanded : false} anchorEl={anchorRef.current} onClose={() => setExpanded(false)} transitionDuration={500}>\n <FlexRow gap={0.5} padding={0.5}>\n <LinkEx\n lineHeight={0}\n style={{ color: '#1da1f2' }}\n onClick={() => {\n window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`)\n setExpanded(false)\n }}\n >\n <TwitterIcon fontSize=\"small\" />\n </LinkEx>\n <LinkEx\n lineHeight={0}\n style={{ color: '#4267b2' }}\n onClick={() => {\n window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`)\n setExpanded(false)\n }}\n >\n <FacebookIcon fontSize=\"small\" />\n </LinkEx>\n </FlexRow>\n </Popover>\n </FlexRow>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,4BAAqF;AACrF,sBAAwB;AACxB,0BAAwC;AACxC,2BAAwB;AACxB,wBAAuB;AACvB,mBAAwC;AAOjC,IAAMA,cAA0C,wBAAC,EAAEC,WAAW,MAAMC,WAAW,GAAGC,MAAAA,MAAO;AAC9F,QAAM,CAACC,UAAUC,WAAAA,QAAeC,uBAAS,KAAA;AACzC,QAAMC,gBAAYC,qBAAO,IAAA;AACzB,QAAMC,OAAOP,aAAaQ,OAAOC,SAASC;AAE1C,SACE,6BAAAC,QAAA,cAACC,8BAAAA;IAAQC,KAAK;IAAGC,KAAKT;KACpB,6BAAAM,QAAA,cAACI,8BAAAA;IACCC,SAAQ;IACRC,UAAU;IACVC,MAAK;IACLC,UAAU,CAACpB;IACXqB,SAAS,6BAAA;AACPjB,kBAAY,IAAA;IACd,GAFS;IAGR,GAAGF;KAEJ,6BAAAU,QAAA,cAACU,sBAAAA,OAAAA;IAAUC,WAAU;IAAOC,UAAS;OAEvC,6BAAAZ,QAAA,cAACa,yBAAAA;IAAQC,MAAM1B,WAAWG,WAAW;IAAOwB,UAAUrB,UAAUsB;IAASC,SAAS,6BAAMzB,YAAY,KAAA,GAAlB;IAA0B0B,oBAAoB;KAC9H,6BAAAlB,QAAA,cAACC,8BAAAA;IAAQC,KAAK;IAAKiB,SAAS;KAC1B,6BAAAnB,QAAA,cAACoB,0BAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPZ,aAAOiB,KAAK,wCAAwCU,mBAAmB5B,IAAAA,CAAAA,EAAO;AAC9EJ,kBAAY,KAAA;IACd,GAHS;KAKT,6BAAAQ,QAAA,cAACyB,sBAAAA,SAAAA;IAAYb,UAAS;OAExB,6BAAAZ,QAAA,cAACoB,0BAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPZ,aAAOiB,KAAK,gDAAgDU,mBAAmB5B,IAAAA,CAAAA,EAAO;AACtFJ,kBAAY,KAAA;IACd,GAHS;KAKT,6BAAAQ,QAAA,cAAC0B,sBAAAA,UAAAA;IAAad,UAAS;;AAMnC,GA7CuD;","names":["ShareButton","prepared","shareLink","props","expanded","setExpanded","useState","anchorRef","useRef","link","window","location","href","React","FlexRow","gap","ref","ButtonEx","variant","minWidth","size","disabled","onClick","ShareIcon","htmlColor","fontSize","Popover","open","anchorEl","current","onClose","transitionDuration","padding","LinkEx","lineHeight","style","color","encodeURIComponent","TwitterIcon","FacebookIcon"]}
|
package/dist/browser/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/browser/index.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ButtonExProps } from '@xylabs/react-button';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export interface ShareButtonProps extends ButtonExProps {
|
|
4
|
-
prepared?: boolean;
|
|
5
|
-
shareLink?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ShareButton: React.FC<ShareButtonProps>;
|
|
8
|
-
//# sourceMappingURL=ShareButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ButtonExProps } from '@xylabs/react-button';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export interface ShareButtonProps extends ButtonExProps {
|
|
4
|
-
prepared?: boolean;
|
|
5
|
-
shareLink?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ShareButton: React.FC<ShareButtonProps>;
|
|
8
|
-
//# sourceMappingURL=ShareButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ButtonExProps } from '@xylabs/react-button';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export interface ShareButtonProps extends ButtonExProps {
|
|
4
|
-
prepared?: boolean;
|
|
5
|
-
shareLink?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ShareButton: React.FC<ShareButtonProps>;
|
|
8
|
-
//# sourceMappingURL=ShareButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,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/dist/neutral/index.cjs
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var src_exports = {};
|
|
33
|
-
__export(src_exports, {
|
|
34
|
-
ShareButton: () => ShareButton
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(src_exports);
|
|
37
|
-
|
|
38
|
-
// src/ShareButton.tsx
|
|
39
|
-
var import_icons_material = require("@mui/icons-material");
|
|
40
|
-
var import_material = require("@mui/material");
|
|
41
|
-
var import_react_button = require("@xylabs/react-button");
|
|
42
|
-
var import_react_flexbox = require("@xylabs/react-flexbox");
|
|
43
|
-
var import_react_link = require("@xylabs/react-link");
|
|
44
|
-
var import_react = __toESM(require("react"), 1);
|
|
45
|
-
var ShareButton = /* @__PURE__ */ __name(({ prepared = true, shareLink, ...props }) => {
|
|
46
|
-
const [expanded, setExpanded] = (0, import_react.useState)(false);
|
|
47
|
-
const anchorRef = (0, import_react.useRef)(null);
|
|
48
|
-
const link = shareLink ?? window.location.href;
|
|
49
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react_flexbox.FlexRow, {
|
|
50
|
-
gap: 1,
|
|
51
|
-
ref: anchorRef
|
|
52
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_react_button.ButtonEx, {
|
|
53
|
-
variant: "text",
|
|
54
|
-
minWidth: 32,
|
|
55
|
-
size: "small",
|
|
56
|
-
disabled: !prepared,
|
|
57
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
58
|
-
setExpanded(true);
|
|
59
|
-
}, "onClick"),
|
|
60
|
-
...props
|
|
61
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Share, {
|
|
62
|
-
htmlColor: "gray",
|
|
63
|
-
fontSize: "small"
|
|
64
|
-
})), /* @__PURE__ */ import_react.default.createElement(import_material.Popover, {
|
|
65
|
-
open: prepared ? expanded : false,
|
|
66
|
-
anchorEl: anchorRef.current,
|
|
67
|
-
onClose: /* @__PURE__ */ __name(() => setExpanded(false), "onClose"),
|
|
68
|
-
transitionDuration: 500
|
|
69
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_react_flexbox.FlexRow, {
|
|
70
|
-
gap: 0.5,
|
|
71
|
-
padding: 0.5
|
|
72
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_react_link.LinkEx, {
|
|
73
|
-
lineHeight: 0,
|
|
74
|
-
style: {
|
|
75
|
-
color: "#1da1f2"
|
|
76
|
-
},
|
|
77
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
78
|
-
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`);
|
|
79
|
-
setExpanded(false);
|
|
80
|
-
}, "onClick")
|
|
81
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Twitter, {
|
|
82
|
-
fontSize: "small"
|
|
83
|
-
})), /* @__PURE__ */ import_react.default.createElement(import_react_link.LinkEx, {
|
|
84
|
-
lineHeight: 0,
|
|
85
|
-
style: {
|
|
86
|
-
color: "#4267b2"
|
|
87
|
-
},
|
|
88
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
89
|
-
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`);
|
|
90
|
-
setExpanded(false);
|
|
91
|
-
}, "onClick")
|
|
92
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_icons_material.Facebook, {
|
|
93
|
-
fontSize: "small"
|
|
94
|
-
})))));
|
|
95
|
-
}, "ShareButton");
|
|
96
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/ShareButton.tsx"],"sourcesContent":["export * from './ShareButton.tsx'\n","import { Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon } from '@mui/icons-material'\nimport { Popover } from '@mui/material'\nimport { ButtonEx, ButtonExProps } from '@xylabs/react-button'\nimport { FlexRow } from '@xylabs/react-flexbox'\nimport { LinkEx } from '@xylabs/react-link'\nimport React, { useRef, useState } from 'react'\n\nexport interface ShareButtonProps extends ButtonExProps {\n prepared?: boolean\n shareLink?: string\n}\n\nexport const ShareButton: React.FC<ShareButtonProps> = ({ prepared = true, shareLink, ...props }) => {\n const [expanded, setExpanded] = useState(false)\n const anchorRef = useRef(null)\n const link = shareLink ?? window.location.href\n\n return (\n <FlexRow gap={1} ref={anchorRef}>\n <ButtonEx\n variant=\"text\"\n minWidth={32}\n size=\"small\"\n disabled={!prepared}\n onClick={() => {\n setExpanded(true)\n }}\n {...props}\n >\n <ShareIcon htmlColor=\"gray\" fontSize=\"small\" />\n </ButtonEx>\n <Popover open={prepared ? expanded : false} anchorEl={anchorRef.current} onClose={() => setExpanded(false)} transitionDuration={500}>\n <FlexRow gap={0.5} padding={0.5}>\n <LinkEx\n lineHeight={0}\n style={{ color: '#1da1f2' }}\n onClick={() => {\n window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`)\n setExpanded(false)\n }}\n >\n <TwitterIcon fontSize=\"small\" />\n </LinkEx>\n <LinkEx\n lineHeight={0}\n style={{ color: '#4267b2' }}\n onClick={() => {\n window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`)\n setExpanded(false)\n }}\n >\n <FacebookIcon fontSize=\"small\" />\n </LinkEx>\n </FlexRow>\n </Popover>\n </FlexRow>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,4BAAqF;AACrF,sBAAwB;AACxB,0BAAwC;AACxC,2BAAwB;AACxB,wBAAuB;AACvB,mBAAwC;AAOjC,IAAMA,cAA0C,wBAAC,EAAEC,WAAW,MAAMC,WAAW,GAAGC,MAAAA,MAAO;AAC9F,QAAM,CAACC,UAAUC,WAAAA,QAAeC,uBAAS,KAAA;AACzC,QAAMC,gBAAYC,qBAAO,IAAA;AACzB,QAAMC,OAAOP,aAAaQ,OAAOC,SAASC;AAE1C,SACE,6BAAAC,QAAA,cAACC,8BAAAA;IAAQC,KAAK;IAAGC,KAAKT;KACpB,6BAAAM,QAAA,cAACI,8BAAAA;IACCC,SAAQ;IACRC,UAAU;IACVC,MAAK;IACLC,UAAU,CAACpB;IACXqB,SAAS,6BAAA;AACPjB,kBAAY,IAAA;IACd,GAFS;IAGR,GAAGF;KAEJ,6BAAAU,QAAA,cAACU,sBAAAA,OAAAA;IAAUC,WAAU;IAAOC,UAAS;OAEvC,6BAAAZ,QAAA,cAACa,yBAAAA;IAAQC,MAAM1B,WAAWG,WAAW;IAAOwB,UAAUrB,UAAUsB;IAASC,SAAS,6BAAMzB,YAAY,KAAA,GAAlB;IAA0B0B,oBAAoB;KAC9H,6BAAAlB,QAAA,cAACC,8BAAAA;IAAQC,KAAK;IAAKiB,SAAS;KAC1B,6BAAAnB,QAAA,cAACoB,0BAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPZ,aAAOiB,KAAK,wCAAwCU,mBAAmB5B,IAAAA,CAAAA,EAAO;AAC9EJ,kBAAY,KAAA;IACd,GAHS;KAKT,6BAAAQ,QAAA,cAACyB,sBAAAA,SAAAA;IAAYb,UAAS;OAExB,6BAAAZ,QAAA,cAACoB,0BAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPZ,aAAOiB,KAAK,gDAAgDU,mBAAmB5B,IAAAA,CAAAA,EAAO;AACtFJ,kBAAY,KAAA;IACd,GAHS;KAKT,6BAAAQ,QAAA,cAAC0B,sBAAAA,UAAAA;IAAad,UAAS;;AAMnC,GA7CuD;","names":["ShareButton","prepared","shareLink","props","expanded","setExpanded","useState","anchorRef","useRef","link","window","location","href","React","FlexRow","gap","ref","ButtonEx","variant","minWidth","size","disabled","onClick","ShareIcon","htmlColor","fontSize","Popover","open","anchorEl","current","onClose","transitionDuration","padding","LinkEx","lineHeight","style","color","encodeURIComponent","TwitterIcon","FacebookIcon"]}
|
package/dist/neutral/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/neutral/index.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/neutral/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
package/dist/neutral/index.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/ShareButton.tsx
|
|
5
|
-
import { Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon } from "@mui/icons-material";
|
|
6
|
-
import { Popover } from "@mui/material";
|
|
7
|
-
import { ButtonEx } from "@xylabs/react-button";
|
|
8
|
-
import { FlexRow } from "@xylabs/react-flexbox";
|
|
9
|
-
import { LinkEx } from "@xylabs/react-link";
|
|
10
|
-
import React, { useRef, useState } from "react";
|
|
11
|
-
var ShareButton = /* @__PURE__ */ __name(({ prepared = true, shareLink, ...props }) => {
|
|
12
|
-
const [expanded, setExpanded] = useState(false);
|
|
13
|
-
const anchorRef = useRef(null);
|
|
14
|
-
const link = shareLink ?? window.location.href;
|
|
15
|
-
return /* @__PURE__ */ React.createElement(FlexRow, {
|
|
16
|
-
gap: 1,
|
|
17
|
-
ref: anchorRef
|
|
18
|
-
}, /* @__PURE__ */ React.createElement(ButtonEx, {
|
|
19
|
-
variant: "text",
|
|
20
|
-
minWidth: 32,
|
|
21
|
-
size: "small",
|
|
22
|
-
disabled: !prepared,
|
|
23
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
24
|
-
setExpanded(true);
|
|
25
|
-
}, "onClick"),
|
|
26
|
-
...props
|
|
27
|
-
}, /* @__PURE__ */ React.createElement(ShareIcon, {
|
|
28
|
-
htmlColor: "gray",
|
|
29
|
-
fontSize: "small"
|
|
30
|
-
})), /* @__PURE__ */ React.createElement(Popover, {
|
|
31
|
-
open: prepared ? expanded : false,
|
|
32
|
-
anchorEl: anchorRef.current,
|
|
33
|
-
onClose: /* @__PURE__ */ __name(() => setExpanded(false), "onClose"),
|
|
34
|
-
transitionDuration: 500
|
|
35
|
-
}, /* @__PURE__ */ React.createElement(FlexRow, {
|
|
36
|
-
gap: 0.5,
|
|
37
|
-
padding: 0.5
|
|
38
|
-
}, /* @__PURE__ */ React.createElement(LinkEx, {
|
|
39
|
-
lineHeight: 0,
|
|
40
|
-
style: {
|
|
41
|
-
color: "#1da1f2"
|
|
42
|
-
},
|
|
43
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
44
|
-
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`);
|
|
45
|
-
setExpanded(false);
|
|
46
|
-
}, "onClick")
|
|
47
|
-
}, /* @__PURE__ */ React.createElement(TwitterIcon, {
|
|
48
|
-
fontSize: "small"
|
|
49
|
-
})), /* @__PURE__ */ React.createElement(LinkEx, {
|
|
50
|
-
lineHeight: 0,
|
|
51
|
-
style: {
|
|
52
|
-
color: "#4267b2"
|
|
53
|
-
},
|
|
54
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
55
|
-
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`);
|
|
56
|
-
setExpanded(false);
|
|
57
|
-
}, "onClick")
|
|
58
|
-
}, /* @__PURE__ */ React.createElement(FacebookIcon, {
|
|
59
|
-
fontSize: "small"
|
|
60
|
-
})))));
|
|
61
|
-
}, "ShareButton");
|
|
62
|
-
export {
|
|
63
|
-
ShareButton
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ShareButton.tsx"],"sourcesContent":["import { Facebook as FacebookIcon, Share as ShareIcon, Twitter as TwitterIcon } from '@mui/icons-material'\nimport { Popover } from '@mui/material'\nimport { ButtonEx, ButtonExProps } from '@xylabs/react-button'\nimport { FlexRow } from '@xylabs/react-flexbox'\nimport { LinkEx } from '@xylabs/react-link'\nimport React, { useRef, useState } from 'react'\n\nexport interface ShareButtonProps extends ButtonExProps {\n prepared?: boolean\n shareLink?: string\n}\n\nexport const ShareButton: React.FC<ShareButtonProps> = ({ prepared = true, shareLink, ...props }) => {\n const [expanded, setExpanded] = useState(false)\n const anchorRef = useRef(null)\n const link = shareLink ?? window.location.href\n\n return (\n <FlexRow gap={1} ref={anchorRef}>\n <ButtonEx\n variant=\"text\"\n minWidth={32}\n size=\"small\"\n disabled={!prepared}\n onClick={() => {\n setExpanded(true)\n }}\n {...props}\n >\n <ShareIcon htmlColor=\"gray\" fontSize=\"small\" />\n </ButtonEx>\n <Popover open={prepared ? expanded : false} anchorEl={anchorRef.current} onClose={() => setExpanded(false)} transitionDuration={500}>\n <FlexRow gap={0.5} padding={0.5}>\n <LinkEx\n lineHeight={0}\n style={{ color: '#1da1f2' }}\n onClick={() => {\n window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(link)}`)\n setExpanded(false)\n }}\n >\n <TwitterIcon fontSize=\"small\" />\n </LinkEx>\n <LinkEx\n lineHeight={0}\n style={{ color: '#4267b2' }}\n onClick={() => {\n window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(link)}`)\n setExpanded(false)\n }}\n >\n <FacebookIcon fontSize=\"small\" />\n </LinkEx>\n </FlexRow>\n </Popover>\n </FlexRow>\n )\n}\n"],"mappings":";;;;AAAA,SAASA,YAAYC,cAAcC,SAASC,WAAWC,WAAWC,mBAAmB;AACrF,SAASC,eAAe;AACxB,SAASC,gBAA+B;AACxC,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,OAAOC,SAASC,QAAQC,gBAAgB;AAOjC,IAAMC,cAA0C,wBAAC,EAAEC,WAAW,MAAMC,WAAW,GAAGC,MAAAA,MAAO;AAC9F,QAAM,CAACC,UAAUC,WAAAA,IAAeC,SAAS,KAAA;AACzC,QAAMC,YAAYC,OAAO,IAAA;AACzB,QAAMC,OAAOP,aAAaQ,OAAOC,SAASC;AAE1C,SACE,sBAAA,cAACC,SAAAA;IAAQC,KAAK;IAAGC,KAAKR;KACpB,sBAAA,cAACS,UAAAA;IACCC,SAAQ;IACRC,UAAU;IACVC,MAAK;IACLC,UAAU,CAACnB;IACXoB,SAAS,6BAAA;AACPhB,kBAAY,IAAA;IACd,GAFS;IAGR,GAAGF;KAEJ,sBAAA,cAACmB,WAAAA;IAAUC,WAAU;IAAOC,UAAS;OAEvC,sBAAA,cAACC,SAAAA;IAAQC,MAAMzB,WAAWG,WAAW;IAAOuB,UAAUpB,UAAUqB;IAASC,SAAS,6BAAMxB,YAAY,KAAA,GAAlB;IAA0ByB,oBAAoB;KAC9H,sBAAA,cAACjB,SAAAA;IAAQC,KAAK;IAAKiB,SAAS;KAC1B,sBAAA,cAACC,QAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPX,aAAOgB,KAAK,wCAAwCU,mBAAmB3B,IAAAA,CAAAA,EAAO;AAC9EJ,kBAAY,KAAA;IACd,GAHS;KAKT,sBAAA,cAACgC,aAAAA;IAAYb,UAAS;OAExB,sBAAA,cAACQ,QAAAA;IACCC,YAAY;IACZC,OAAO;MAAEC,OAAO;IAAU;IAC1Bd,SAAS,6BAAA;AACPX,aAAOgB,KAAK,gDAAgDU,mBAAmB3B,IAAAA,CAAAA,EAAO;AACtFJ,kBAAY,KAAA;IACd,GAHS;KAKT,sBAAA,cAACiC,cAAAA;IAAad,UAAS;;AAMnC,GA7CuD;","names":["Facebook","FacebookIcon","Share","ShareIcon","Twitter","TwitterIcon","Popover","ButtonEx","FlexRow","LinkEx","React","useRef","useState","ShareButton","prepared","shareLink","props","expanded","setExpanded","useState","anchorRef","useRef","link","window","location","href","FlexRow","gap","ref","ButtonEx","variant","minWidth","size","disabled","onClick","ShareIcon","htmlColor","fontSize","Popover","open","anchorEl","current","onClose","transitionDuration","padding","LinkEx","lineHeight","style","color","encodeURIComponent","TwitterIcon","FacebookIcon"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ButtonExProps } from '@xylabs/react-button';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export interface ShareButtonProps extends ButtonExProps {
|
|
4
|
-
prepared?: boolean;
|
|
5
|
-
shareLink?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ShareButton: React.FC<ShareButtonProps>;
|
|
8
|
-
//# sourceMappingURL=ShareButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShareButton.d.ts","sourceRoot":"","sources":["../../src/ShareButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG9D,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ButtonExProps } from '@xylabs/react-button';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export interface ShareButtonProps extends ButtonExProps {
|
|
4
|
-
prepared?: boolean;
|
|
5
|
-
shareLink?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const ShareButton: React.FC<ShareButtonProps>;
|
|
8
|
-
//# sourceMappingURL=ShareButton.d.ts.map
|