@micromag/element-visual 0.3.119 → 0.3.123
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/es/index.js +15 -36
- package/lib/index.js +15 -36
- package/package.json +5 -5
package/es/index.js
CHANGED
|
@@ -58,50 +58,29 @@ var Visual = function Visual(_ref) {
|
|
|
58
58
|
|
|
59
59
|
var _ref2 = media || {},
|
|
60
60
|
_ref2$type = _ref2.type,
|
|
61
|
-
type = _ref2$type === void 0 ? null : _ref2$type
|
|
62
|
-
_ref2$thumbnail_url = _ref2.thumbnail_url,
|
|
63
|
-
thumbnailUrl = _ref2$thumbnail_url === void 0 ? null : _ref2$thumbnail_url,
|
|
64
|
-
metadata = _ref2.metadata,
|
|
65
|
-
url = _ref2.url;
|
|
61
|
+
type = _ref2$type === void 0 ? null : _ref2$type;
|
|
66
62
|
|
|
67
|
-
var _ref3 = metadata || {},
|
|
68
|
-
mime = _ref3.mime;
|
|
69
|
-
|
|
70
|
-
var isVideo = type === 'video';
|
|
71
|
-
var isGIF = type === 'image' && mime === 'image/gif';
|
|
72
63
|
var elProps = useMemo(function () {
|
|
73
64
|
return _objectSpread(_objectSpread({}, props), {}, {
|
|
74
65
|
media: media
|
|
75
66
|
});
|
|
76
67
|
}, [props, media]);
|
|
77
|
-
var imageElProps = useMemo(function () {
|
|
78
|
-
var tmpProps = !playing && (isVideo || isGIF) ? _objectSpread(_objectSpread({}, elProps), {}, {
|
|
79
|
-
media: {
|
|
80
|
-
url: thumbnailUrl
|
|
81
|
-
}
|
|
82
|
-
}) : elProps;
|
|
83
|
-
return isGIF && playing ? _objectSpread(_objectSpread({}, elProps), {}, {
|
|
84
|
-
media: {
|
|
85
|
-
url: url
|
|
86
|
-
}
|
|
87
|
-
}) : tmpProps;
|
|
88
|
-
}, [isVideo, isGIF, elProps, thumbnailUrl, url, playing]);
|
|
89
68
|
var videoContainerStyle = null;
|
|
90
69
|
|
|
91
|
-
if (
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
fit =
|
|
70
|
+
if (type === 'video' && objectFit !== null && playing) {
|
|
71
|
+
var _ref3 = objectFit || {},
|
|
72
|
+
_ref3$fit = _ref3.fit,
|
|
73
|
+
fit = _ref3$fit === void 0 ? 'cover' : _ref3$fit;
|
|
95
74
|
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
videoMetadata =
|
|
75
|
+
var _ref4 = media || {},
|
|
76
|
+
_ref4$metadata = _ref4.metadata,
|
|
77
|
+
videoMetadata = _ref4$metadata === void 0 ? null : _ref4$metadata;
|
|
99
78
|
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
videoWidth =
|
|
103
|
-
|
|
104
|
-
videoHeight =
|
|
79
|
+
var _ref5 = videoMetadata || {},
|
|
80
|
+
_ref5$width = _ref5.width,
|
|
81
|
+
videoWidth = _ref5$width === void 0 ? 0 : _ref5$width,
|
|
82
|
+
_ref5$height = _ref5.height,
|
|
83
|
+
videoHeight = _ref5$height === void 0 ? 0 : _ref5$height;
|
|
105
84
|
|
|
106
85
|
var _getSizeWithinBounds = getSizeWithinBounds(videoWidth, videoHeight, width, height, {
|
|
107
86
|
cover: fit === 'cover'
|
|
@@ -119,7 +98,7 @@ var Visual = function Visual(_ref) {
|
|
|
119
98
|
};
|
|
120
99
|
}
|
|
121
100
|
|
|
122
|
-
return type !== null ? /*#__PURE__*/React.createElement(React.Fragment, null, type === 'image'
|
|
101
|
+
return type !== null ? /*#__PURE__*/React.createElement(React.Fragment, null, type === 'image' ? /*#__PURE__*/React.createElement(Image, Object.assign({}, elProps, {
|
|
123
102
|
objectFit: objectFit,
|
|
124
103
|
width: width,
|
|
125
104
|
height: height,
|
|
@@ -127,7 +106,7 @@ var Visual = function Visual(_ref) {
|
|
|
127
106
|
shouldLoad: shouldLoad,
|
|
128
107
|
onLoaded: onLoaded,
|
|
129
108
|
className: classNames([styles.container, _defineProperty({}, className, className !== null)])
|
|
130
|
-
})) : null,
|
|
109
|
+
})) : null, type === 'video' ? /*#__PURE__*/React.createElement("div", {
|
|
131
110
|
className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
|
|
132
111
|
style: {
|
|
133
112
|
width: width,
|
package/lib/index.js
CHANGED
|
@@ -71,50 +71,29 @@ var Visual = function Visual(_ref) {
|
|
|
71
71
|
|
|
72
72
|
var _ref2 = media || {},
|
|
73
73
|
_ref2$type = _ref2.type,
|
|
74
|
-
type = _ref2$type === void 0 ? null : _ref2$type
|
|
75
|
-
_ref2$thumbnail_url = _ref2.thumbnail_url,
|
|
76
|
-
thumbnailUrl = _ref2$thumbnail_url === void 0 ? null : _ref2$thumbnail_url,
|
|
77
|
-
metadata = _ref2.metadata,
|
|
78
|
-
url = _ref2.url;
|
|
74
|
+
type = _ref2$type === void 0 ? null : _ref2$type;
|
|
79
75
|
|
|
80
|
-
var _ref3 = metadata || {},
|
|
81
|
-
mime = _ref3.mime;
|
|
82
|
-
|
|
83
|
-
var isVideo = type === 'video';
|
|
84
|
-
var isGIF = type === 'image' && mime === 'image/gif';
|
|
85
76
|
var elProps = React.useMemo(function () {
|
|
86
77
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, props), {}, {
|
|
87
78
|
media: media
|
|
88
79
|
});
|
|
89
80
|
}, [props, media]);
|
|
90
|
-
var imageElProps = React.useMemo(function () {
|
|
91
|
-
var tmpProps = !playing && (isVideo || isGIF) ? _objectSpread__default["default"](_objectSpread__default["default"]({}, elProps), {}, {
|
|
92
|
-
media: {
|
|
93
|
-
url: thumbnailUrl
|
|
94
|
-
}
|
|
95
|
-
}) : elProps;
|
|
96
|
-
return isGIF && playing ? _objectSpread__default["default"](_objectSpread__default["default"]({}, elProps), {}, {
|
|
97
|
-
media: {
|
|
98
|
-
url: url
|
|
99
|
-
}
|
|
100
|
-
}) : tmpProps;
|
|
101
|
-
}, [isVideo, isGIF, elProps, thumbnailUrl, url, playing]);
|
|
102
81
|
var videoContainerStyle = null;
|
|
103
82
|
|
|
104
|
-
if (
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
fit =
|
|
83
|
+
if (type === 'video' && objectFit !== null && playing) {
|
|
84
|
+
var _ref3 = objectFit || {},
|
|
85
|
+
_ref3$fit = _ref3.fit,
|
|
86
|
+
fit = _ref3$fit === void 0 ? 'cover' : _ref3$fit;
|
|
108
87
|
|
|
109
|
-
var
|
|
110
|
-
|
|
111
|
-
videoMetadata =
|
|
88
|
+
var _ref4 = media || {},
|
|
89
|
+
_ref4$metadata = _ref4.metadata,
|
|
90
|
+
videoMetadata = _ref4$metadata === void 0 ? null : _ref4$metadata;
|
|
112
91
|
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
videoWidth =
|
|
116
|
-
|
|
117
|
-
videoHeight =
|
|
92
|
+
var _ref5 = videoMetadata || {},
|
|
93
|
+
_ref5$width = _ref5.width,
|
|
94
|
+
videoWidth = _ref5$width === void 0 ? 0 : _ref5$width,
|
|
95
|
+
_ref5$height = _ref5.height,
|
|
96
|
+
videoHeight = _ref5$height === void 0 ? 0 : _ref5$height;
|
|
118
97
|
|
|
119
98
|
var _getSizeWithinBounds = size.getSizeWithinBounds(videoWidth, videoHeight, width, height, {
|
|
120
99
|
cover: fit === 'cover'
|
|
@@ -132,7 +111,7 @@ var Visual = function Visual(_ref) {
|
|
|
132
111
|
};
|
|
133
112
|
}
|
|
134
113
|
|
|
135
|
-
return type !== null ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, type === 'image'
|
|
114
|
+
return type !== null ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, type === 'image' ? /*#__PURE__*/React__default["default"].createElement(Image__default["default"], Object.assign({}, elProps, {
|
|
136
115
|
objectFit: objectFit,
|
|
137
116
|
width: width,
|
|
138
117
|
height: height,
|
|
@@ -140,7 +119,7 @@ var Visual = function Visual(_ref) {
|
|
|
140
119
|
shouldLoad: shouldLoad,
|
|
141
120
|
onLoaded: onLoaded,
|
|
142
121
|
className: classNames__default["default"]([styles.container, _defineProperty__default["default"]({}, className, className !== null)])
|
|
143
|
-
})) : null,
|
|
122
|
+
})) : null, type === 'video' ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
144
123
|
className: classNames__default["default"]([styles.container, _defineProperty__default["default"]({}, className, className !== null)]),
|
|
145
124
|
style: {
|
|
146
125
|
width: width,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-visual",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.123",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@babel/runtime": "^7.13.10",
|
|
52
52
|
"@folklore/size": "^0.1.20",
|
|
53
|
-
"@micromag/core": "^0.3.
|
|
54
|
-
"@micromag/element-image": "^0.3.
|
|
55
|
-
"@micromag/element-video": "^0.3.
|
|
53
|
+
"@micromag/core": "^0.3.122",
|
|
54
|
+
"@micromag/element-image": "^0.3.122",
|
|
55
|
+
"@micromag/element-video": "^0.3.123",
|
|
56
56
|
"classnames": "^2.2.6",
|
|
57
57
|
"prop-types": "^15.7.2",
|
|
58
58
|
"uuid": "^8.3.2"
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "1815cb0d51d34e283db3390bd56113dbac339098"
|
|
64
64
|
}
|