@micromag/element-share-options 0.3.120 → 0.3.126
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/assets/css/styles.css +1 -0
- package/es/index.js +136 -0
- package/lib/index.js +145 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.micromag-element-share-options-container{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;overflow-x:auto;overflow-y:hidden}.micromag-element-share-options-item{max-width:64px;margin-right:.5rem;text-align:center}.micromag-element-share-options-item:last-child{margin-right:0}.micromag-element-share-options-label{margin-top:.5rem;color:#6c6c6c;font-size:.75rem;font-weight:400}
|
package/es/index.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import React, { useCallback, useMemo } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { FormattedMessage } from 'react-intl';
|
|
6
|
+
import { EmailShareButton, EmailIcon, FacebookShareButton, FacebookIcon, TwitterShareButton, TwitterIcon, LinkedinShareButton, LinkedinIcon } from 'react-share';
|
|
7
|
+
|
|
8
|
+
var styles = {"container":"micromag-element-share-options-container","item":"micromag-element-share-options-item","label":"micromag-element-share-options-label"};
|
|
9
|
+
|
|
10
|
+
var propTypes = {
|
|
11
|
+
className: PropTypes.string,
|
|
12
|
+
itemClassName: PropTypes.string,
|
|
13
|
+
labelClassName: PropTypes.string,
|
|
14
|
+
title: PropTypes.string,
|
|
15
|
+
url: PropTypes.string,
|
|
16
|
+
options: PropTypes.arrayOf(PropTypes.string),
|
|
17
|
+
onShare: PropTypes.func,
|
|
18
|
+
onClose: PropTypes.func,
|
|
19
|
+
focusable: PropTypes.bool
|
|
20
|
+
};
|
|
21
|
+
var defaultProps = {
|
|
22
|
+
className: null,
|
|
23
|
+
itemClassName: null,
|
|
24
|
+
labelClassName: null,
|
|
25
|
+
title: null,
|
|
26
|
+
url: null,
|
|
27
|
+
options: null,
|
|
28
|
+
onShare: null,
|
|
29
|
+
onClose: null,
|
|
30
|
+
focusable: true
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var ShareOptions = function ShareOptions(_ref) {
|
|
34
|
+
var className = _ref.className,
|
|
35
|
+
itemClassName = _ref.itemClassName,
|
|
36
|
+
labelClassName = _ref.labelClassName,
|
|
37
|
+
title = _ref.title,
|
|
38
|
+
url = _ref.url,
|
|
39
|
+
options = _ref.options,
|
|
40
|
+
onShare = _ref.onShare,
|
|
41
|
+
onClose = _ref.onClose,
|
|
42
|
+
focusable = _ref.focusable;
|
|
43
|
+
var onShareButtonClick = useCallback(function (type) {
|
|
44
|
+
if (onShare !== null) {
|
|
45
|
+
onShare(type);
|
|
46
|
+
}
|
|
47
|
+
}, [onShare]);
|
|
48
|
+
var shareButtonProps = useMemo(function () {
|
|
49
|
+
return {
|
|
50
|
+
url: url,
|
|
51
|
+
onShareWindowClose: function onShareWindowClose() {
|
|
52
|
+
if (onClose !== null) {
|
|
53
|
+
onClose();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, [url, onClose]);
|
|
58
|
+
var shareIconProps = useMemo(function () {
|
|
59
|
+
return {
|
|
60
|
+
size: 64,
|
|
61
|
+
round: true
|
|
62
|
+
};
|
|
63
|
+
}, []);
|
|
64
|
+
var shareOptions = [{
|
|
65
|
+
id: 'email',
|
|
66
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
67
|
+
id: "Lrwi2G",
|
|
68
|
+
defaultMessage: [{
|
|
69
|
+
"type": 0,
|
|
70
|
+
"value": "Email"
|
|
71
|
+
}]
|
|
72
|
+
}),
|
|
73
|
+
icon: /*#__PURE__*/React.createElement(EmailShareButton, Object.assign({}, shareButtonProps, {
|
|
74
|
+
subject: title,
|
|
75
|
+
beforeOnClick: function beforeOnClick() {
|
|
76
|
+
onShareButtonClick('Email');
|
|
77
|
+
return Promise.resolve();
|
|
78
|
+
},
|
|
79
|
+
tabIndex: focusable ? null : '-1'
|
|
80
|
+
}), /*#__PURE__*/React.createElement(EmailIcon, shareIconProps))
|
|
81
|
+
}, {
|
|
82
|
+
id: 'facebook',
|
|
83
|
+
label: 'Facebook',
|
|
84
|
+
icon: /*#__PURE__*/React.createElement(FacebookShareButton, Object.assign({}, shareButtonProps, {
|
|
85
|
+
quote: title,
|
|
86
|
+
beforeOnClick: function beforeOnClick() {
|
|
87
|
+
onShareButtonClick('Facebook');
|
|
88
|
+
return Promise.resolve();
|
|
89
|
+
},
|
|
90
|
+
tabIndex: focusable ? null : '-1'
|
|
91
|
+
}), /*#__PURE__*/React.createElement(FacebookIcon, shareIconProps))
|
|
92
|
+
}, {
|
|
93
|
+
id: 'twitter',
|
|
94
|
+
label: 'Twitter',
|
|
95
|
+
icon: /*#__PURE__*/React.createElement(TwitterShareButton, Object.assign({}, shareButtonProps, {
|
|
96
|
+
title: title,
|
|
97
|
+
beforeOnClick: function beforeOnClick() {
|
|
98
|
+
onShareButtonClick('Twitter');
|
|
99
|
+
return Promise.resolve();
|
|
100
|
+
},
|
|
101
|
+
tabIndex: focusable ? null : '-1'
|
|
102
|
+
}), /*#__PURE__*/React.createElement(TwitterIcon, shareIconProps))
|
|
103
|
+
}, {
|
|
104
|
+
id: 'linkedin',
|
|
105
|
+
label: 'LinkedIn',
|
|
106
|
+
icon: /*#__PURE__*/React.createElement(LinkedinShareButton, Object.assign({}, shareButtonProps, {
|
|
107
|
+
title: title,
|
|
108
|
+
beforeOnClick: function beforeOnClick() {
|
|
109
|
+
onShareButtonClick('LinkedIns');
|
|
110
|
+
return Promise.resolve();
|
|
111
|
+
},
|
|
112
|
+
tabIndex: focusable ? null : '-1'
|
|
113
|
+
}), /*#__PURE__*/React.createElement(LinkedinIcon, shareIconProps))
|
|
114
|
+
}];
|
|
115
|
+
var selectedOptions = options !== null ? shareOptions.filter(function (opt) {
|
|
116
|
+
return options.includes(opt.id);
|
|
117
|
+
}) : shareOptions;
|
|
118
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
119
|
+
className: classNames([styles.container, _defineProperty({}, className, className !== null)])
|
|
120
|
+
}, selectedOptions.map(function (_ref3) {
|
|
121
|
+
var id = _ref3.id,
|
|
122
|
+
label = _ref3.label,
|
|
123
|
+
icon = _ref3.icon;
|
|
124
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
125
|
+
key: id,
|
|
126
|
+
className: classNames([styles.item, _defineProperty({}, itemClassName, itemClassName !== null)])
|
|
127
|
+
}, icon, /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
className: classNames([styles.label, _defineProperty({}, labelClassName, labelClassName !== null)])
|
|
129
|
+
}, label));
|
|
130
|
+
}));
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
ShareOptions.propTypes = propTypes;
|
|
134
|
+
ShareOptions.defaultProps = defaultProps;
|
|
135
|
+
|
|
136
|
+
export { ShareOptions as default };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var classNames = require('classnames');
|
|
6
|
+
var PropTypes = require('prop-types');
|
|
7
|
+
var reactIntl = require('react-intl');
|
|
8
|
+
var reactShare = require('react-share');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
15
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
16
|
+
|
|
17
|
+
var styles = {"container":"micromag-element-share-options-container","item":"micromag-element-share-options-item","label":"micromag-element-share-options-label"};
|
|
18
|
+
|
|
19
|
+
var propTypes = {
|
|
20
|
+
className: PropTypes__default["default"].string,
|
|
21
|
+
itemClassName: PropTypes__default["default"].string,
|
|
22
|
+
labelClassName: PropTypes__default["default"].string,
|
|
23
|
+
title: PropTypes__default["default"].string,
|
|
24
|
+
url: PropTypes__default["default"].string,
|
|
25
|
+
options: PropTypes__default["default"].arrayOf(PropTypes__default["default"].string),
|
|
26
|
+
onShare: PropTypes__default["default"].func,
|
|
27
|
+
onClose: PropTypes__default["default"].func,
|
|
28
|
+
focusable: PropTypes__default["default"].bool
|
|
29
|
+
};
|
|
30
|
+
var defaultProps = {
|
|
31
|
+
className: null,
|
|
32
|
+
itemClassName: null,
|
|
33
|
+
labelClassName: null,
|
|
34
|
+
title: null,
|
|
35
|
+
url: null,
|
|
36
|
+
options: null,
|
|
37
|
+
onShare: null,
|
|
38
|
+
onClose: null,
|
|
39
|
+
focusable: true
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var ShareOptions = function ShareOptions(_ref) {
|
|
43
|
+
var className = _ref.className,
|
|
44
|
+
itemClassName = _ref.itemClassName,
|
|
45
|
+
labelClassName = _ref.labelClassName,
|
|
46
|
+
title = _ref.title,
|
|
47
|
+
url = _ref.url,
|
|
48
|
+
options = _ref.options,
|
|
49
|
+
onShare = _ref.onShare,
|
|
50
|
+
onClose = _ref.onClose,
|
|
51
|
+
focusable = _ref.focusable;
|
|
52
|
+
var onShareButtonClick = React.useCallback(function (type) {
|
|
53
|
+
if (onShare !== null) {
|
|
54
|
+
onShare(type);
|
|
55
|
+
}
|
|
56
|
+
}, [onShare]);
|
|
57
|
+
var shareButtonProps = React.useMemo(function () {
|
|
58
|
+
return {
|
|
59
|
+
url: url,
|
|
60
|
+
onShareWindowClose: function onShareWindowClose() {
|
|
61
|
+
if (onClose !== null) {
|
|
62
|
+
onClose();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}, [url, onClose]);
|
|
67
|
+
var shareIconProps = React.useMemo(function () {
|
|
68
|
+
return {
|
|
69
|
+
size: 64,
|
|
70
|
+
round: true
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
var shareOptions = [{
|
|
74
|
+
id: 'email',
|
|
75
|
+
label: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
76
|
+
id: "Lrwi2G",
|
|
77
|
+
defaultMessage: [{
|
|
78
|
+
"type": 0,
|
|
79
|
+
"value": "Email"
|
|
80
|
+
}]
|
|
81
|
+
}),
|
|
82
|
+
icon: /*#__PURE__*/React__default["default"].createElement(reactShare.EmailShareButton, Object.assign({}, shareButtonProps, {
|
|
83
|
+
subject: title,
|
|
84
|
+
beforeOnClick: function beforeOnClick() {
|
|
85
|
+
onShareButtonClick('Email');
|
|
86
|
+
return Promise.resolve();
|
|
87
|
+
},
|
|
88
|
+
tabIndex: focusable ? null : '-1'
|
|
89
|
+
}), /*#__PURE__*/React__default["default"].createElement(reactShare.EmailIcon, shareIconProps))
|
|
90
|
+
}, {
|
|
91
|
+
id: 'facebook',
|
|
92
|
+
label: 'Facebook',
|
|
93
|
+
icon: /*#__PURE__*/React__default["default"].createElement(reactShare.FacebookShareButton, Object.assign({}, shareButtonProps, {
|
|
94
|
+
quote: title,
|
|
95
|
+
beforeOnClick: function beforeOnClick() {
|
|
96
|
+
onShareButtonClick('Facebook');
|
|
97
|
+
return Promise.resolve();
|
|
98
|
+
},
|
|
99
|
+
tabIndex: focusable ? null : '-1'
|
|
100
|
+
}), /*#__PURE__*/React__default["default"].createElement(reactShare.FacebookIcon, shareIconProps))
|
|
101
|
+
}, {
|
|
102
|
+
id: 'twitter',
|
|
103
|
+
label: 'Twitter',
|
|
104
|
+
icon: /*#__PURE__*/React__default["default"].createElement(reactShare.TwitterShareButton, Object.assign({}, shareButtonProps, {
|
|
105
|
+
title: title,
|
|
106
|
+
beforeOnClick: function beforeOnClick() {
|
|
107
|
+
onShareButtonClick('Twitter');
|
|
108
|
+
return Promise.resolve();
|
|
109
|
+
},
|
|
110
|
+
tabIndex: focusable ? null : '-1'
|
|
111
|
+
}), /*#__PURE__*/React__default["default"].createElement(reactShare.TwitterIcon, shareIconProps))
|
|
112
|
+
}, {
|
|
113
|
+
id: 'linkedin',
|
|
114
|
+
label: 'LinkedIn',
|
|
115
|
+
icon: /*#__PURE__*/React__default["default"].createElement(reactShare.LinkedinShareButton, Object.assign({}, shareButtonProps, {
|
|
116
|
+
title: title,
|
|
117
|
+
beforeOnClick: function beforeOnClick() {
|
|
118
|
+
onShareButtonClick('LinkedIns');
|
|
119
|
+
return Promise.resolve();
|
|
120
|
+
},
|
|
121
|
+
tabIndex: focusable ? null : '-1'
|
|
122
|
+
}), /*#__PURE__*/React__default["default"].createElement(reactShare.LinkedinIcon, shareIconProps))
|
|
123
|
+
}];
|
|
124
|
+
var selectedOptions = options !== null ? shareOptions.filter(function (opt) {
|
|
125
|
+
return options.includes(opt.id);
|
|
126
|
+
}) : shareOptions;
|
|
127
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
128
|
+
className: classNames__default["default"]([styles.container, _defineProperty__default["default"]({}, className, className !== null)])
|
|
129
|
+
}, selectedOptions.map(function (_ref3) {
|
|
130
|
+
var id = _ref3.id,
|
|
131
|
+
label = _ref3.label,
|
|
132
|
+
icon = _ref3.icon;
|
|
133
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
134
|
+
key: id,
|
|
135
|
+
className: classNames__default["default"]([styles.item, _defineProperty__default["default"]({}, itemClassName, itemClassName !== null)])
|
|
136
|
+
}, icon, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
137
|
+
className: classNames__default["default"]([styles.label, _defineProperty__default["default"]({}, labelClassName, labelClassName !== null)])
|
|
138
|
+
}, label));
|
|
139
|
+
}));
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
ShareOptions.propTypes = propTypes;
|
|
143
|
+
ShareOptions.defaultProps = defaultProps;
|
|
144
|
+
|
|
145
|
+
module.exports = ShareOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-share-options",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.126",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/runtime": "^7.13.10",
|
|
56
|
-
"@micromag/core": "^0.3.
|
|
56
|
+
"@micromag/core": "^0.3.126",
|
|
57
57
|
"classnames": "^2.2.6",
|
|
58
58
|
"prop-types": "^15.7.2",
|
|
59
59
|
"react-intl": "^5.12.1",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "079203c5850c4aa771bc4fa1c567d2db1bc3ee3d"
|
|
67
67
|
}
|