@selfcommunity/react-ui 0.8.0-alpha.7 → 0.8.0-alpha.8
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.
|
@@ -12,10 +12,15 @@ const LazyLoad_1 = require("../../../constants/LazyLoad");
|
|
|
12
12
|
const Skeleton_1 = tslib_1.__importDefault(require("@mui/material/Skeleton"));
|
|
13
13
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
|
+
const material_1 = require("@mui/material");
|
|
15
16
|
const filter_1 = tslib_1.__importDefault(require("./filter"));
|
|
16
17
|
const classes = {
|
|
17
18
|
displayRoot: `${constants_1.PREFIX}-display-root`,
|
|
18
19
|
displayLink: `${constants_1.PREFIX}-link`,
|
|
20
|
+
displayHtmlWrap: `${constants_1.PREFIX}-html-wrap`,
|
|
21
|
+
displayHtml: `${constants_1.PREFIX}-html`,
|
|
22
|
+
displayHtmlPlaceholder: `${constants_1.PREFIX}-html-placeholder`,
|
|
23
|
+
displayHtmlLoading: `${constants_1.PREFIX}-html-loading`,
|
|
19
24
|
displayVideo: `${constants_1.PREFIX}-video`,
|
|
20
25
|
thumbnail: `${constants_1.PREFIX}-thumbnail`,
|
|
21
26
|
thumbnailFullWidth: `${constants_1.PREFIX}-thumbnail`,
|
|
@@ -40,12 +45,23 @@ exports.default = (props) => {
|
|
|
40
45
|
// RENDER
|
|
41
46
|
/**
|
|
42
47
|
* Renders link display
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
48
|
+
* @param media
|
|
49
|
+
* @param key
|
|
45
50
|
*/
|
|
46
|
-
const renderPreview = (
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
const renderPreview = (media, key) => {
|
|
52
|
+
if (media.embed.metadata.html) {
|
|
53
|
+
return renderHtml(media, key);
|
|
54
|
+
}
|
|
55
|
+
const domain = new URL(media.embed.metadata.url).hostname.replace('www.', '');
|
|
56
|
+
return ((0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.displayLink }, { children: [media.embed.metadata.images && media.embed.metadata.images.length > 0 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: fullWidth ? ((0, jsx_runtime_1.jsx)(Box_1.default, { className: (0, classnames_1.default)(classes.thumbnailFullWidth, classes.image), style: { background: `url(${media.image})`, paddingBottom: `${100 / media.image_width / media.image_height}%` } })) : ((0, jsx_runtime_1.jsx)(Box_1.default, { className: (0, classnames_1.default)(classes.thumbnail, classes.image), style: { background: `url(${media.image})` } })) })), (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.snippet }, { children: [(0, jsx_runtime_1.jsx)("b", Object.assign({ className: classes.snippetTitle }, { children: media.embed.metadata.title })), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("p", Object.assign({ className: classes.snippetDescription }, { children: media.embed.metadata.description })), (0, jsx_runtime_1.jsx)("a", Object.assign({ href: media.embed.metadata.url, target: '_blank', onClick: () => handleLinkClick(media) }, { children: domain }))] })), (0, jsx_runtime_1.jsx)("div", { style: { clear: 'both' } })] }), key));
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Render html embed
|
|
60
|
+
* @param media
|
|
61
|
+
* @param key
|
|
62
|
+
*/
|
|
63
|
+
const renderHtml = (media, key) => {
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.displayHtmlWrap }, { children: [(0, jsx_runtime_1.jsx)("div", { dangerouslySetInnerHTML: { __html: media.embed.metadata.html }, className: classes.displayHtml }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.displayHtmlPlaceholder, style: { paddingTop: `${(100 * media.embed.metadata.height) / media.embed.metadata.width}%`, maxHeight: media.embed.metadata.height } }, { children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20, className: classes.displayHtmlLoading }) }))] }), key));
|
|
49
65
|
};
|
|
50
66
|
/**
|
|
51
67
|
* Renders component
|
|
@@ -10,10 +10,15 @@ import { DEFAULT_PRELOAD_OFFSET_VIEWPORT } from '../../../constants/LazyLoad';
|
|
|
10
10
|
import Skeleton from '@mui/material/Skeleton';
|
|
11
11
|
import classNames from 'classnames';
|
|
12
12
|
import { PREFIX } from './constants';
|
|
13
|
+
import { CircularProgress } from '@mui/material';
|
|
13
14
|
import filter from './filter';
|
|
14
15
|
const classes = {
|
|
15
16
|
displayRoot: `${PREFIX}-display-root`,
|
|
16
17
|
displayLink: `${PREFIX}-link`,
|
|
18
|
+
displayHtmlWrap: `${PREFIX}-html-wrap`,
|
|
19
|
+
displayHtml: `${PREFIX}-html`,
|
|
20
|
+
displayHtmlPlaceholder: `${PREFIX}-html-placeholder`,
|
|
21
|
+
displayHtmlLoading: `${PREFIX}-html-loading`,
|
|
17
22
|
displayVideo: `${PREFIX}-video`,
|
|
18
23
|
thumbnail: `${PREFIX}-thumbnail`,
|
|
19
24
|
thumbnailFullWidth: `${PREFIX}-thumbnail`,
|
|
@@ -38,12 +43,23 @@ export default (props) => {
|
|
|
38
43
|
// RENDER
|
|
39
44
|
/**
|
|
40
45
|
* Renders link display
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
46
|
+
* @param media
|
|
47
|
+
* @param key
|
|
43
48
|
*/
|
|
44
|
-
const renderPreview = (
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
const renderPreview = (media, key) => {
|
|
50
|
+
if (media.embed.metadata.html) {
|
|
51
|
+
return renderHtml(media, key);
|
|
52
|
+
}
|
|
53
|
+
const domain = new URL(media.embed.metadata.url).hostname.replace('www.', '');
|
|
54
|
+
return (_jsxs(Box, Object.assign({ className: classes.displayLink }, { children: [media.embed.metadata.images && media.embed.metadata.images.length > 0 && (_jsx(_Fragment, { children: fullWidth ? (_jsx(Box, { className: classNames(classes.thumbnailFullWidth, classes.image), style: { background: `url(${media.image})`, paddingBottom: `${100 / media.image_width / media.image_height}%` } })) : (_jsx(Box, { className: classNames(classes.thumbnail, classes.image), style: { background: `url(${media.image})` } })) })), _jsxs(Box, Object.assign({ className: classes.snippet }, { children: [_jsx("b", Object.assign({ className: classes.snippetTitle }, { children: media.embed.metadata.title })), _jsx("br", {}), _jsx("p", Object.assign({ className: classes.snippetDescription }, { children: media.embed.metadata.description })), _jsx("a", Object.assign({ href: media.embed.metadata.url, target: '_blank', onClick: () => handleLinkClick(media) }, { children: domain }))] })), _jsx("div", { style: { clear: 'both' } })] }), key));
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Render html embed
|
|
58
|
+
* @param media
|
|
59
|
+
* @param key
|
|
60
|
+
*/
|
|
61
|
+
const renderHtml = (media, key) => {
|
|
62
|
+
return (_jsxs(Box, Object.assign({ className: classes.displayHtmlWrap }, { children: [_jsx("div", { dangerouslySetInnerHTML: { __html: media.embed.metadata.html }, className: classes.displayHtml }), _jsx("div", Object.assign({ className: classes.displayHtmlPlaceholder, style: { paddingTop: `${(100 * media.embed.metadata.height) / media.embed.metadata.width}%`, maxHeight: media.embed.metadata.height } }, { children: _jsx(CircularProgress, { size: 20, className: classes.displayHtmlLoading }) }))] }), key));
|
|
47
63
|
};
|
|
48
64
|
/**
|
|
49
65
|
* Renders component
|