@kids-reporter/draft-renderer 0.1.0
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/README.md +86 -0
- package/lib/assets/annotation-arrow.png +0 -0
- package/lib/assets/audio-pause.png +0 -0
- package/lib/assets/audio-play.png +0 -0
- package/lib/assets/citation-download.png +0 -0
- package/lib/assets/default-og-img.png +0 -0
- package/lib/assets/slideshow-arrow-down-dark.png +0 -0
- package/lib/assets/slideshow-arrow-down.png +0 -0
- package/lib/assets/slideshow-arrow-up.png +0 -0
- package/lib/assets/slideshow-close-cross.png +0 -0
- package/lib/block-renderer-fn.js +123 -0
- package/lib/block-renderers/audio-block.js +162 -0
- package/lib/block-renderers/background-image-block.js +257 -0
- package/lib/block-renderers/background-video-block.js +272 -0
- package/lib/block-renderers/color-box-block.js +94 -0
- package/lib/block-renderers/divider-block.js +27 -0
- package/lib/block-renderers/embedded-code-block.js +121 -0
- package/lib/block-renderers/image-block.js +72 -0
- package/lib/block-renderers/index.js +53 -0
- package/lib/block-renderers/info-box-block.js +124 -0
- package/lib/block-renderers/media-block.js +65 -0
- package/lib/block-renderers/related-post-block.js +73 -0
- package/lib/block-renderers/side-index-block.js +49 -0
- package/lib/block-renderers/slideshow-block.js +253 -0
- package/lib/block-renderers/table-block.js +455 -0
- package/lib/block-renderers/video-block.js +37 -0
- package/lib/components/slideshow-lightbox.js +134 -0
- package/lib/components/slideshow-sidebar.js +148 -0
- package/lib/const.js +10 -0
- package/lib/draft-renderer.js +234 -0
- package/lib/entity-decorator.js +18 -0
- package/lib/entity-decorators/annotation-decorator.js +155 -0
- package/lib/entity-decorators/index.js +16 -0
- package/lib/entity-decorators/link-decorator.js +48 -0
- package/lib/index.js +30 -0
- package/lib/public/07d1287fd390346af0c15b930148a5e4.png +0 -0
- package/lib/public/5b3cb1a908786c8750f1041860699cc1.png +0 -0
- package/lib/public/679d63b1846e81ada28c2f76edbd2931.png +0 -0
- package/lib/public/722f90c535fa64c27555ec6ee5f22393.png +0 -0
- package/lib/public/903cf84ef5c5ad76634c30bdc0ff8c49.png +0 -0
- package/lib/public/dc249b3412c5af890a004508287a3c3d.png +0 -0
- package/lib/public/dd45f0788d9c70cabe72430bf08e7413.png +0 -0
- package/lib/public/f96d4b486ba2061c460962ae694f4670.png +0 -0
- package/lib/shared-style/content-type.js +163 -0
- package/lib/shared-style/index.js +108 -0
- package/lib/theme/index.js +39 -0
- package/lib/types/index.js +32 -0
- package/lib/utils/common.js +44 -0
- package/lib/utils/post.js +147 -0
- package/package.json +44 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InfoBoxBlock = InfoBoxBlock;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
|
|
12
|
+
var _sharedStyle = require("../shared-style");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const infoboxDefaultSpacing = 8;
|
|
17
|
+
const InfoBoxRenderWrapper = _styledComponents.default.div`
|
|
18
|
+
background: #f6f6fb;
|
|
19
|
+
position: relative;
|
|
20
|
+
padding: 24px 0px;
|
|
21
|
+
width: calc(100% + 40px);
|
|
22
|
+
transform: translateX(-20px);
|
|
23
|
+
${({
|
|
24
|
+
theme
|
|
25
|
+
}) => theme.margin.default};
|
|
26
|
+
|
|
27
|
+
${({
|
|
28
|
+
theme
|
|
29
|
+
}) => theme.breakpoint.md} {
|
|
30
|
+
max-width: 560px;
|
|
31
|
+
transform: none;
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const InfoTitle = _styledComponents.default.div`
|
|
35
|
+
width: 100%;
|
|
36
|
+
font-style: normal;
|
|
37
|
+
font-weight: 700;
|
|
38
|
+
${({
|
|
39
|
+
theme
|
|
40
|
+
}) => theme.fontSize.md};
|
|
41
|
+
line-height: 1.5;
|
|
42
|
+
letter-spacing: 0.03em;
|
|
43
|
+
color: #000928;
|
|
44
|
+
border-left: 8px solid #04295e;
|
|
45
|
+
padding: 0 32px 0 24px;
|
|
46
|
+
margin-bottom: ${infoboxDefaultSpacing}px;
|
|
47
|
+
`;
|
|
48
|
+
const InfoContent = _styledComponents.default.div`
|
|
49
|
+
padding: 0px 32px;
|
|
50
|
+
font-style: normal;
|
|
51
|
+
font-weight: 400;
|
|
52
|
+
${({
|
|
53
|
+
theme
|
|
54
|
+
}) => theme.fontSize.sm};
|
|
55
|
+
line-height: 1.6;
|
|
56
|
+
color: rgba(0, 9, 40, 0.87);
|
|
57
|
+
|
|
58
|
+
> div > * + * {
|
|
59
|
+
margin: ${infoboxDefaultSpacing}px 0 0;
|
|
60
|
+
min-height: 0.01px; //to make margins between paragraphs effective
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
h2 {
|
|
64
|
+
${_sharedStyle.defaultH2Style}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
ul {
|
|
68
|
+
${_sharedStyle.defaultUlStyle}
|
|
69
|
+
margin-top: ${infoboxDefaultSpacing}px;
|
|
70
|
+
|
|
71
|
+
> li {
|
|
72
|
+
${_sharedStyle.defaultUnorderedListStyle}
|
|
73
|
+
|
|
74
|
+
& + li {
|
|
75
|
+
margin: ${infoboxDefaultSpacing / 2}px 0 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
ol {
|
|
81
|
+
${_sharedStyle.defaultOlStyle}
|
|
82
|
+
margin-top: ${infoboxDefaultSpacing}px;
|
|
83
|
+
|
|
84
|
+
> li {
|
|
85
|
+
${_sharedStyle.defaultOrderedListStyle}
|
|
86
|
+
|
|
87
|
+
& + li {
|
|
88
|
+
margin: ${infoboxDefaultSpacing / 2}px 0 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
a {
|
|
94
|
+
${_sharedStyle.defaultLinkStyle}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
blockquote {
|
|
98
|
+
${_sharedStyle.defaultBlockQuoteStyle}
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
function InfoBoxBlock(props) {
|
|
103
|
+
const {
|
|
104
|
+
block,
|
|
105
|
+
contentState
|
|
106
|
+
} = props;
|
|
107
|
+
const entityKey = block.getEntityAt(0);
|
|
108
|
+
const entity = contentState.getEntity(entityKey);
|
|
109
|
+
const {
|
|
110
|
+
title,
|
|
111
|
+
body
|
|
112
|
+
} = entity.getData();
|
|
113
|
+
return /*#__PURE__*/_react.default.createElement(InfoBoxRenderWrapper, {
|
|
114
|
+
className: "infobox-wrapper"
|
|
115
|
+
}, /*#__PURE__*/_react.default.createElement(InfoTitle, {
|
|
116
|
+
className: "infobox-title"
|
|
117
|
+
}, title), /*#__PURE__*/_react.default.createElement(InfoContent, {
|
|
118
|
+
className: "infobox-content"
|
|
119
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
120
|
+
dangerouslySetInnerHTML: {
|
|
121
|
+
__html: body
|
|
122
|
+
}
|
|
123
|
+
})));
|
|
124
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MediaBlock = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const styles = {
|
|
13
|
+
media: {
|
|
14
|
+
width: '100%'
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const Audio = props => {
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement("audio", {
|
|
20
|
+
controls: true,
|
|
21
|
+
src: props.src,
|
|
22
|
+
style: styles.media
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const Image = props => {
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement("img", {
|
|
28
|
+
src: props.src,
|
|
29
|
+
style: styles.media
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const Video = props => {
|
|
34
|
+
return /*#__PURE__*/_react.default.createElement("video", {
|
|
35
|
+
controls: true,
|
|
36
|
+
src: props.src,
|
|
37
|
+
style: styles.media
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const MediaBlock = entity => {
|
|
42
|
+
const {
|
|
43
|
+
src
|
|
44
|
+
} = entity.getData();
|
|
45
|
+
const type = entity.getType();
|
|
46
|
+
let media;
|
|
47
|
+
|
|
48
|
+
if (type === 'audioLink') {
|
|
49
|
+
media = /*#__PURE__*/_react.default.createElement(Audio, {
|
|
50
|
+
src: src
|
|
51
|
+
});
|
|
52
|
+
} else if (type === 'imageLink') {
|
|
53
|
+
media = /*#__PURE__*/_react.default.createElement(Image, {
|
|
54
|
+
src: src
|
|
55
|
+
});
|
|
56
|
+
} else if (type === 'videoLink') {
|
|
57
|
+
media = /*#__PURE__*/_react.default.createElement(Video, {
|
|
58
|
+
src: src
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return media;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.MediaBlock = MediaBlock;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RelatedPostBlock = RelatedPostBlock;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
const RelatedPostWrapper = _styledComponents.default.div`
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
width: 100%;
|
|
18
|
+
border: 2px solid #04295e;
|
|
19
|
+
border-width: 2px 2px 2px 12px;
|
|
20
|
+
padding: 16px;
|
|
21
|
+
${({
|
|
22
|
+
theme
|
|
23
|
+
}) => theme.margin.default};
|
|
24
|
+
|
|
25
|
+
${({
|
|
26
|
+
theme
|
|
27
|
+
}) => theme.breakpoint.md} {
|
|
28
|
+
padding: 24px;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const RelatedPostTitle = _styledComponents.default.p`
|
|
32
|
+
color: #04295e;
|
|
33
|
+
font-size: 14px;
|
|
34
|
+
line-height: 20px;
|
|
35
|
+
margin: 0 0 -8px;
|
|
36
|
+
${({
|
|
37
|
+
theme
|
|
38
|
+
}) => theme.breakpoint.md} {
|
|
39
|
+
font-size: 16px;
|
|
40
|
+
line-height: 23px;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
const RelatedPostItem = _styledComponents.default.div`
|
|
44
|
+
display: flex;
|
|
45
|
+
`;
|
|
46
|
+
const RelatedPostAnchorWrapper = _styledComponents.default.a`
|
|
47
|
+
text-decoration: none;
|
|
48
|
+
display: inline-block;
|
|
49
|
+
margin: 12px 0 0;
|
|
50
|
+
|
|
51
|
+
&:hover span {
|
|
52
|
+
border-bottom: 2px solid #04295e;
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
const RelatedPost = _styledComponents.default.span`
|
|
56
|
+
color: rgba(0, 9, 40, 0.87);
|
|
57
|
+
font-size: 18px;
|
|
58
|
+
line-height: 1.6;
|
|
59
|
+
border-bottom: 2px solid #ebf02c;
|
|
60
|
+
padding-bottom: 2px;
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
function RelatedPostBlock(entity) {
|
|
64
|
+
const {
|
|
65
|
+
posts
|
|
66
|
+
} = entity.getData();
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(RelatedPostWrapper, null, /*#__PURE__*/_react.default.createElement(RelatedPostTitle, null, "\u63A8\u85A6\u95B1\u8B80"), posts.map(post => /*#__PURE__*/_react.default.createElement(RelatedPostItem, {
|
|
68
|
+
key: post.id
|
|
69
|
+
}, /*#__PURE__*/_react.default.createElement(RelatedPostAnchorWrapper, {
|
|
70
|
+
href: `/post/${post.id}`,
|
|
71
|
+
target: "_blank"
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(RelatedPost, null, post.name))))));
|
|
73
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SideIndexBlock = SideIndexBlock;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
|
|
12
|
+
var _sharedStyle = require("../shared-style");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const sideIndexDefaultSpacing = 32;
|
|
17
|
+
const SideIndexBlockWrapper = _styledComponents.default.div`
|
|
18
|
+
margin-top: ${sideIndexDefaultSpacing}px;
|
|
19
|
+
|
|
20
|
+
h2 {
|
|
21
|
+
${_sharedStyle.defaultH2Style}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
function SideIndexBlock(props) {
|
|
26
|
+
const {
|
|
27
|
+
block,
|
|
28
|
+
contentState
|
|
29
|
+
} = props;
|
|
30
|
+
const entityKey = block.getEntityAt(0);
|
|
31
|
+
const entity = contentState.getEntity(entityKey);
|
|
32
|
+
const {
|
|
33
|
+
h2Text,
|
|
34
|
+
sideIndexText
|
|
35
|
+
} = entity.getData();
|
|
36
|
+
const sideIndexTitle = sideIndexText || h2Text || '';
|
|
37
|
+
const key = sideIndexTitle.replace(/\s+/g, '');
|
|
38
|
+
let sideIndexBlock;
|
|
39
|
+
|
|
40
|
+
if (h2Text) {
|
|
41
|
+
sideIndexBlock = /*#__PURE__*/_react.default.createElement(SideIndexBlockWrapper, {
|
|
42
|
+
id: `header-${key}`
|
|
43
|
+
}, /*#__PURE__*/_react.default.createElement("h2", null, h2Text));
|
|
44
|
+
} else {
|
|
45
|
+
sideIndexBlock = null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, sideIndexBlock);
|
|
49
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SlideshowBlock = SlideshowBlock;
|
|
7
|
+
exports.SlideshowBlockV2 = SlideshowBlockV2;
|
|
8
|
+
|
|
9
|
+
var _reactImage = _interopRequireDefault(require("@readr-media/react-image"));
|
|
10
|
+
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
|
|
13
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
14
|
+
|
|
15
|
+
var _slideshowLightbox = _interopRequireDefault(require("../components/slideshow-lightbox"));
|
|
16
|
+
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
+
|
|
19
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
|
+
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
|
|
23
|
+
const defaultImage = "https://unpkg.com/@kids-reporter/draft-renderer@0.1.0/lib/public/722f90c535fa64c27555ec6ee5f22393.png";
|
|
24
|
+
const arrowDown = "https://unpkg.com/@kids-reporter/draft-renderer@0.1.0/lib/public/dd45f0788d9c70cabe72430bf08e7413.png";
|
|
25
|
+
const SlideShowDesktopSize = 960;
|
|
26
|
+
const SpacingBetweenSlideImages = 12;
|
|
27
|
+
const SlideShowBlockWrapper = _styledComponents.default.div`
|
|
28
|
+
width: calc(100% + 40px);
|
|
29
|
+
transform: translateX(-20px);
|
|
30
|
+
position: relative;
|
|
31
|
+
${({
|
|
32
|
+
theme
|
|
33
|
+
}) => theme.margin.default};
|
|
34
|
+
|
|
35
|
+
${({
|
|
36
|
+
theme
|
|
37
|
+
}) => theme.breakpoint.xl} {
|
|
38
|
+
width: ${SlideShowDesktopSize}px;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
flex-wrap: wrap;
|
|
43
|
+
transform: translateX(-180px);
|
|
44
|
+
gap: ${SpacingBetweenSlideImages}px;
|
|
45
|
+
max-height: ${props => props.expandSlideShow ? 'none' : '960px'};
|
|
46
|
+
overflow: ${props => props.expandSlideShow ? 'visible' : 'hidden'};
|
|
47
|
+
margin-bottom: ${props => props.expandSlideShow ? '32px' : '16px'};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.slideshow-image {
|
|
51
|
+
max-height: ${props => props.shouldLimitFigureHeight ? 'calc(960px - 324px)' : 'none'};
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
const SlideShowImage = _styledComponents.default.figure`
|
|
55
|
+
width: 100%;
|
|
56
|
+
aspect-ratio: 1/1;
|
|
57
|
+
|
|
58
|
+
& + .slideshow-image {
|
|
59
|
+
margin-top: ${SpacingBetweenSlideImages}px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
${({
|
|
63
|
+
theme
|
|
64
|
+
}) => theme.breakpoint.xl} {
|
|
65
|
+
flex: 1 0 calc((100% - ${SpacingBetweenSlideImages * 2}px) / 3);
|
|
66
|
+
min-width: ${SlideShowDesktopSize / 3 - 8}px;
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
filter: brightness(15%);
|
|
71
|
+
transition: 0.3s;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
& + .slideshow-image {
|
|
75
|
+
margin-top: unset;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
79
|
+
const FigCaption = _styledComponents.default.figcaption`
|
|
80
|
+
font-weight: 400;
|
|
81
|
+
line-height: 23px;
|
|
82
|
+
color: #000928;
|
|
83
|
+
opacity: 0.5;
|
|
84
|
+
${({
|
|
85
|
+
theme
|
|
86
|
+
}) => theme.fontSize.xs};
|
|
87
|
+
padding: 8px 20px 20px 20px;
|
|
88
|
+
|
|
89
|
+
${({
|
|
90
|
+
theme
|
|
91
|
+
}) => theme.breakpoint.md} {
|
|
92
|
+
${({
|
|
93
|
+
theme
|
|
94
|
+
}) => theme.fontSize.sm};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
${({
|
|
98
|
+
theme
|
|
99
|
+
}) => theme.breakpoint.xl} {
|
|
100
|
+
display: none;
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
const GradientMask = _styledComponents.default.div`
|
|
104
|
+
display: none;
|
|
105
|
+
|
|
106
|
+
${({
|
|
107
|
+
theme
|
|
108
|
+
}) => theme.breakpoint.xl} {
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
display: block;
|
|
111
|
+
position: absolute;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: ${SlideShowDesktopSize}px;
|
|
114
|
+
bottom: 0;
|
|
115
|
+
left: 0;
|
|
116
|
+
background: linear-gradient(
|
|
117
|
+
to bottom,
|
|
118
|
+
rgba(255, 255, 255, 0) 648px,
|
|
119
|
+
rgba(255, 255, 255, 1) 960px
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
const ExpandText = _styledComponents.default.div`
|
|
124
|
+
display: none;
|
|
125
|
+
|
|
126
|
+
${({
|
|
127
|
+
theme
|
|
128
|
+
}) => theme.breakpoint.xl} {
|
|
129
|
+
display: block;
|
|
130
|
+
font-style: normal;
|
|
131
|
+
font-weight: 700;
|
|
132
|
+
${({
|
|
133
|
+
theme
|
|
134
|
+
}) => theme.fontSize.md};
|
|
135
|
+
line-height: 18px;
|
|
136
|
+
letter-spacing: 0.03em;
|
|
137
|
+
color: #000928;
|
|
138
|
+
text-align: center;
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
position: relative;
|
|
141
|
+
margin-bottom: 48px;
|
|
142
|
+
transition: all 0.2s ease;
|
|
143
|
+
|
|
144
|
+
&:hover::after,
|
|
145
|
+
&:active::after {
|
|
146
|
+
bottom: -30px;
|
|
147
|
+
transition: all 0.2s;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&::after {
|
|
151
|
+
content: '';
|
|
152
|
+
position: absolute;
|
|
153
|
+
bottom: -26px;
|
|
154
|
+
left: 50%;
|
|
155
|
+
transform: translate(-50%, 0%);
|
|
156
|
+
width: 14px;
|
|
157
|
+
height: 13px;
|
|
158
|
+
background-image: url(${arrowDown});
|
|
159
|
+
background-repeat: no-repeat;
|
|
160
|
+
background-position: center center;
|
|
161
|
+
background-size: 14px;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
`; // support old version of slideshow without delay propertiy
|
|
165
|
+
|
|
166
|
+
const Figure = _styledComponents.default.figure`
|
|
167
|
+
position: relative;
|
|
168
|
+
margin-block: unset;
|
|
169
|
+
margin-inline: unset;
|
|
170
|
+
margin: 0 10px;
|
|
171
|
+
`;
|
|
172
|
+
const Image = _styledComponents.default.img`
|
|
173
|
+
width: 100%;
|
|
174
|
+
`;
|
|
175
|
+
|
|
176
|
+
function SlideshowBlock(entity) {
|
|
177
|
+
var _images$, _images$$resized, _images$2;
|
|
178
|
+
|
|
179
|
+
const images = entity.getData();
|
|
180
|
+
return /*#__PURE__*/_react.default.createElement(Figure, null, /*#__PURE__*/_react.default.createElement(Image, {
|
|
181
|
+
src: images === null || images === void 0 ? void 0 : (_images$ = images[0]) === null || _images$ === void 0 ? void 0 : (_images$$resized = _images$.resized) === null || _images$$resized === void 0 ? void 0 : _images$$resized.original,
|
|
182
|
+
alt: images === null || images === void 0 ? void 0 : (_images$2 = images[0]) === null || _images$2 === void 0 ? void 0 : _images$2.name,
|
|
183
|
+
onError: e => {
|
|
184
|
+
var _images$3, _images$3$imageFile;
|
|
185
|
+
|
|
186
|
+
return e.currentTarget.src = images === null || images === void 0 ? void 0 : (_images$3 = images[0]) === null || _images$3 === void 0 ? void 0 : (_images$3$imageFile = _images$3.imageFile) === null || _images$3$imageFile === void 0 ? void 0 : _images$3$imageFile.url;
|
|
187
|
+
}
|
|
188
|
+
}));
|
|
189
|
+
} // 202206 latest version of slideshow, support delay property
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
function SlideshowBlockV2(entity) {
|
|
193
|
+
const {
|
|
194
|
+
images
|
|
195
|
+
} = entity.getData();
|
|
196
|
+
const [expandSlideShow, setExpandSlideShow] = (0, _react.useState)(false);
|
|
197
|
+
const [showLightBox, setShowLightBox] = (0, _react.useState)(false);
|
|
198
|
+
const [focusImageIndex, setFocusImageIndex] = (0, _react.useState)(0);
|
|
199
|
+
const imagesRefs = (0, _react.useRef)(Array(images.length).fill(null));
|
|
200
|
+
(0, _react.useEffect)(() => {
|
|
201
|
+
const focusedImageRef = imagesRefs === null || imagesRefs === void 0 ? void 0 : imagesRefs.current[focusImageIndex];
|
|
202
|
+
|
|
203
|
+
if (focusedImageRef) {
|
|
204
|
+
focusedImageRef === null || focusedImageRef === void 0 ? void 0 : focusedImageRef.scrollIntoView({
|
|
205
|
+
behavior: 'smooth',
|
|
206
|
+
block: 'center'
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}, [focusImageIndex]);
|
|
210
|
+
const shouldMaskSlideShow = Boolean(images.length > 9 && !expandSlideShow);
|
|
211
|
+
const shouldLimitFigureHeight = Boolean(images.length > 1);
|
|
212
|
+
const slideShowImages = images.map((image, index) => {
|
|
213
|
+
const {
|
|
214
|
+
id,
|
|
215
|
+
resized,
|
|
216
|
+
desc,
|
|
217
|
+
name
|
|
218
|
+
} = image;
|
|
219
|
+
return /*#__PURE__*/_react.default.createElement(SlideShowImage, {
|
|
220
|
+
className: "slideshow-image",
|
|
221
|
+
key: id,
|
|
222
|
+
onClick: () => {
|
|
223
|
+
setShowLightBox(!showLightBox);
|
|
224
|
+
setFocusImageIndex(index);
|
|
225
|
+
}
|
|
226
|
+
}, /*#__PURE__*/_react.default.createElement(_reactImage.default, {
|
|
227
|
+
images: resized,
|
|
228
|
+
defaultImage: defaultImage,
|
|
229
|
+
alt: name,
|
|
230
|
+
rwd: {
|
|
231
|
+
mobile: '100vw',
|
|
232
|
+
tablet: '608px',
|
|
233
|
+
desktop: '960px',
|
|
234
|
+
default: '100%'
|
|
235
|
+
},
|
|
236
|
+
priority: true
|
|
237
|
+
}), desc && /*#__PURE__*/_react.default.createElement(FigCaption, null, desc));
|
|
238
|
+
});
|
|
239
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(SlideShowBlockWrapper, {
|
|
240
|
+
onClick: () => setExpandSlideShow(!expandSlideShow),
|
|
241
|
+
expandSlideShow: expandSlideShow,
|
|
242
|
+
shouldLimitFigureHeight: shouldLimitFigureHeight
|
|
243
|
+
}, slideShowImages, shouldMaskSlideShow && /*#__PURE__*/_react.default.createElement(GradientMask, null)), shouldMaskSlideShow && /*#__PURE__*/_react.default.createElement(ExpandText, {
|
|
244
|
+
className: "slideshow-expand-text",
|
|
245
|
+
onClick: () => setExpandSlideShow(!expandSlideShow)
|
|
246
|
+
}, "\u5C55\u958B\u6240\u6709\u5716\u7247"), showLightBox && /*#__PURE__*/_react.default.createElement(_slideshowLightbox.default, {
|
|
247
|
+
focusImageIndex: focusImageIndex,
|
|
248
|
+
images: images,
|
|
249
|
+
setShowLightBox: setShowLightBox,
|
|
250
|
+
setFocusImageIndex: setFocusImageIndex,
|
|
251
|
+
imagesRefs: imagesRefs
|
|
252
|
+
}));
|
|
253
|
+
}
|