@kids-reporter/draft-renderer 0.1.0 → 0.2.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.
Files changed (51) hide show
  1. package/lib/block-render-map.js +183 -0
  2. package/lib/block-renderer-fn.js +16 -75
  3. package/lib/block-renderers/embedded-code-block.js +33 -21
  4. package/lib/block-renderers/image-block.js +90 -46
  5. package/lib/block-renderers/index.js +3 -31
  6. package/lib/block-renderers/info-box-block.js +2 -115
  7. package/lib/block-renderers/multimedia.js +127 -0
  8. package/lib/block-renderers/slideshow-block.js +574 -199
  9. package/lib/draft-renderer.js +10 -194
  10. package/lib/entity-decorators/annotation-decorator.js +58 -100
  11. package/lib/entity-decorators/index.js +17 -6
  12. package/lib/entity-decorators/link-decorator.js +4 -7
  13. package/lib/index.js +39 -14
  14. package/lib/theme/index.js +0 -11
  15. package/package.json +10 -6
  16. package/lib/assets/annotation-arrow.png +0 -0
  17. package/lib/assets/audio-pause.png +0 -0
  18. package/lib/assets/audio-play.png +0 -0
  19. package/lib/assets/citation-download.png +0 -0
  20. package/lib/assets/default-og-img.png +0 -0
  21. package/lib/assets/slideshow-arrow-down-dark.png +0 -0
  22. package/lib/assets/slideshow-arrow-down.png +0 -0
  23. package/lib/assets/slideshow-arrow-up.png +0 -0
  24. package/lib/assets/slideshow-close-cross.png +0 -0
  25. package/lib/block-renderers/audio-block.js +0 -162
  26. package/lib/block-renderers/background-image-block.js +0 -257
  27. package/lib/block-renderers/background-video-block.js +0 -272
  28. package/lib/block-renderers/color-box-block.js +0 -94
  29. package/lib/block-renderers/divider-block.js +0 -27
  30. package/lib/block-renderers/media-block.js +0 -65
  31. package/lib/block-renderers/related-post-block.js +0 -73
  32. package/lib/block-renderers/side-index-block.js +0 -49
  33. package/lib/block-renderers/table-block.js +0 -455
  34. package/lib/block-renderers/video-block.js +0 -37
  35. package/lib/components/slideshow-lightbox.js +0 -134
  36. package/lib/components/slideshow-sidebar.js +0 -148
  37. package/lib/const.js +0 -10
  38. package/lib/entity-decorator.js +0 -18
  39. package/lib/public/07d1287fd390346af0c15b930148a5e4.png +0 -0
  40. package/lib/public/5b3cb1a908786c8750f1041860699cc1.png +0 -0
  41. package/lib/public/679d63b1846e81ada28c2f76edbd2931.png +0 -0
  42. package/lib/public/722f90c535fa64c27555ec6ee5f22393.png +0 -0
  43. package/lib/public/903cf84ef5c5ad76634c30bdc0ff8c49.png +0 -0
  44. package/lib/public/dc249b3412c5af890a004508287a3c3d.png +0 -0
  45. package/lib/public/dd45f0788d9c70cabe72430bf08e7413.png +0 -0
  46. package/lib/public/f96d4b486ba2061c460962ae694f4670.png +0 -0
  47. package/lib/shared-style/content-type.js +0 -163
  48. package/lib/shared-style/index.js +0 -108
  49. package/lib/types/index.js +0 -32
  50. package/lib/utils/common.js +0 -44
  51. package/lib/utils/post.js +0 -147
@@ -1,455 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TableEditorBlock = exports.TableBlock = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _styledComponents = _interopRequireDefault(require("styled-components"));
11
-
12
- var _draftJs = require("draft-js");
13
-
14
- var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- 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); }
19
-
20
- 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; }
21
-
22
- const _ = {
23
- cloneDeep: _cloneDeep.default
24
- };
25
- var ActionType;
26
-
27
- (function (ActionType) {
28
- ActionType["Insert"] = "insert";
29
- ActionType["Delete"] = "delete";
30
- ActionType["Update"] = "update";
31
- })(ActionType || (ActionType = {}));
32
-
33
- var TableEnum;
34
-
35
- (function (TableEnum) {
36
- TableEnum["Row"] = "row";
37
- TableEnum["Column"] = "column";
38
- })(TableEnum || (TableEnum = {}));
39
-
40
- function createEmptyRow(colLen = 0, emptyValue) {
41
- const rtn = [];
42
-
43
- for (let i = 0; i < colLen; i++) {
44
- rtn.push(emptyValue);
45
- }
46
-
47
- return rtn;
48
- }
49
-
50
- function resolveTableStyles(action, tableStyles) {
51
- switch (action === null || action === void 0 ? void 0 : action.type) {
52
- case ActionType.Insert:
53
- {
54
- if (action.target === TableEnum.Row) {
55
- const rows = [...tableStyles.rows.slice(0, action.index), {}, ...tableStyles.rows.slice(action.index)];
56
- return Object.assign({}, tableStyles, {
57
- rows
58
- });
59
- } // TODO: handle target === TableEnum.Column if needed
60
-
61
-
62
- return tableStyles;
63
- }
64
-
65
- case ActionType.Delete:
66
- {
67
- if (action.target === TableEnum.Row) {
68
- const rows = [...tableStyles.rows.slice(0, action.index), ...tableStyles.rows.slice(action.index + 1)];
69
- return Object.assign({}, tableStyles, {
70
- rows
71
- });
72
- } // TODO: handle target === TableEnum.Column if needed
73
-
74
-
75
- return tableStyles;
76
- }
77
- // TODO: handle action.type === ActionType.Update if needed
78
-
79
- default:
80
- {
81
- return tableStyles;
82
- }
83
- }
84
- }
85
-
86
- function resolveTableData(action, tableData) {
87
- switch (action === null || action === void 0 ? void 0 : action.type) {
88
- case ActionType.Insert:
89
- {
90
- var _tableData$;
91
-
92
- if (typeof (action === null || action === void 0 ? void 0 : action.index) !== 'number') {
93
- return tableData;
94
- }
95
-
96
- if ((action === null || action === void 0 ? void 0 : action.target) === TableEnum.Column) {
97
- // add the new column at specific position in each row
98
- return tableData.map(r => [...r.slice(0, action === null || action === void 0 ? void 0 : action.index), _draftJs.EditorState.createEmpty(), ...r.slice(action === null || action === void 0 ? void 0 : action.index)]);
99
- } // add the new row
100
-
101
-
102
- return [...tableData.slice(0, action === null || action === void 0 ? void 0 : action.index), createEmptyRow(tableData === null || tableData === void 0 ? void 0 : (_tableData$ = tableData[0]) === null || _tableData$ === void 0 ? void 0 : _tableData$.length, _draftJs.EditorState.createEmpty()), ...tableData.slice(action === null || action === void 0 ? void 0 : action.index)];
103
- }
104
-
105
- case ActionType.Delete:
106
- {
107
- if (typeof (action === null || action === void 0 ? void 0 : action.index) !== 'number') {
108
- return tableData;
109
- }
110
-
111
- if ((action === null || action === void 0 ? void 0 : action.target) === 'column') {
112
- // delete the column at specific position in each row
113
- return tableData.map(r => [...r.slice(0, action.index), ...r.slice(action.index + 1)]);
114
- } // delete the column
115
-
116
-
117
- return [...tableData.slice(0, action.index), ...tableData.slice(action.index + 1)];
118
- }
119
-
120
- case ActionType.Update:
121
- {
122
- // The reason we copy the array is to make sure
123
- // that React component re-renders.
124
- const copiedData = [...tableData];
125
-
126
- if (typeof (action === null || action === void 0 ? void 0 : action.rIndex) !== 'number' || typeof (action === null || action === void 0 ? void 0 : action.cIndex) !== 'number') {
127
- return copiedData;
128
- }
129
-
130
- copiedData[action.rIndex][action.cIndex] = action === null || action === void 0 ? void 0 : action.value;
131
- return copiedData;
132
- }
133
-
134
- default:
135
- {
136
- return tableData;
137
- }
138
- }
139
- }
140
-
141
- function convertTableDataFromRaw(rawTableData) {
142
- return rawTableData.map(rowData => {
143
- return rowData.map(colData => {
144
- const contentState = (0, _draftJs.convertFromRaw)(colData);
145
- return _draftJs.EditorState.createWithContent(contentState);
146
- });
147
- });
148
- }
149
-
150
- function convertTableDataToRaw(tableData) {
151
- return tableData.map(rowData => {
152
- return rowData.map(colData => {
153
- return (0, _draftJs.convertToRaw)(colData.getCurrentContent());
154
- });
155
- });
156
- }
157
-
158
- const Table = _styledComponents.default.div`
159
- display: table;
160
- width: 95%;
161
- border-collapse: collapse;
162
- `;
163
- const Tr = _styledComponents.default.div`
164
- display: table-row;
165
- `;
166
- const Td = _styledComponents.default.div`
167
- display: table-cell;
168
- border-width: 1px;
169
- min-width: 100px;
170
- min-height: 40px;
171
- padding: 10px;
172
- `;
173
- const StyledFirstRow = _styledComponents.default.div`
174
- display: table-row;
175
- height: 10px;
176
-
177
- div {
178
- display: table-cell;
179
- position: relative;
180
- }
181
-
182
- span {
183
- cursor: pointer;
184
- line-height: 10px;
185
- }
186
-
187
- span:first-child {
188
- position: absolute;
189
- right: 50%;
190
- transform: translateX(50%);
191
- }
192
-
193
- span:first-child:before {
194
- content: '•';
195
- }
196
-
197
- span:first-child:hover:before {
198
- content: '➖';
199
- }
200
-
201
- span:last-child {
202
- position: absolute;
203
- right: -5px;
204
- }
205
-
206
- span:last-child:before {
207
- content: '•';
208
- }
209
-
210
- span:last-child:hover:before {
211
- content: '➕';
212
- }
213
- `;
214
- const StyledFirstColumn = _styledComponents.default.div`
215
- display: table-cell;
216
- width: 10px;
217
- position: relative;
218
-
219
- span {
220
- cursor: pointer;
221
- }
222
-
223
- span:first-child {
224
- position: absolute;
225
- bottom: 50%;
226
- right: 0px;
227
- transform: translateY(50%);
228
- }
229
-
230
- span:first-child:before {
231
- content: '•';
232
- }
233
-
234
- span:first-child:hover:before {
235
- content: '➖';
236
- }
237
-
238
- span:last-child {
239
- position: absolute;
240
- bottom: -10px;
241
- right: 0px;
242
- }
243
-
244
- span:last-child:before {
245
- content: '•';
246
- }
247
-
248
- span:last-child:hover:before {
249
- content: '➕';
250
- }
251
- `;
252
- const TableBlockContainer = _styledComponents.default.div`
253
- margin: 15px 0;
254
- position: relative;
255
- overflow: scroll;
256
- padding: 15px;
257
- `;
258
- const StyledTable = _styledComponents.default.div`
259
- display: table;
260
- width: 95%;
261
- border-collapse: collapse;
262
- `;
263
- const StyledTr = _styledComponents.default.div`
264
- display: table-row;
265
- `;
266
- const StyledTd = _styledComponents.default.div`
267
- display: table-cell;
268
- border: 1px solid #e1e5e9;
269
- min-width: 100px;
270
- min-height: 40px;
271
- padding: 10px;
272
- `;
273
-
274
- const TableEditorBlock = props => {
275
- var _tableData$2;
276
-
277
- const {
278
- block,
279
- blockProps,
280
- contentState
281
- } = props;
282
- const {
283
- onEditStart,
284
- onEditFinish,
285
- getMainEditorReadOnly
286
- } = blockProps;
287
- const entityKey = block.getEntityAt(0);
288
- const entity = contentState.getEntity(entityKey);
289
- const {
290
- tableData: rawTableData,
291
- tableStyles: _tableStyles
292
- } = entity.getData();
293
- const [tableData, setTableData] = (0, _react.useState)(convertTableDataFromRaw(rawTableData)); // deep clone `_tableStyles` to prevent updating the entity data directly
294
-
295
- const [tableStyles, setTableStyles] = (0, _react.useState)(_.cloneDeep(_tableStyles));
296
- const tableRef = (0, _react.useRef)(null); // `TableBlock` will render other inner/nested DraftJS Editors inside the main Editor.
297
- // However, main Editor's `readOnly` needs to be mutually exclusive with nested Editors' `readOnly`.
298
- // If the main Editor and nested Editor are editable (`readOnly={false}`) at the same time,
299
- // there will be a DraftJS Edtior Selection bug.
300
-
301
- const [cellEditorReadOnly, setCellEditorReadOnly] = (0, _react.useState)(!getMainEditorReadOnly()); // The user clicks the table for editing
302
-
303
- const onTableClick = () => {
304
- // call `onEditStart` function to tell the main DraftJS Editor
305
- // that we are going to interact with the custom atomic block.
306
- onEditStart(); // make nested DraftJS Editors editable
307
-
308
- setCellEditorReadOnly(false);
309
- };
310
-
311
- (0, _react.useEffect)(() => {
312
- // The user clicks other places except the table,
313
- // so we think he/she doesn't want to edit the table anymore.
314
- // Therefore, we call `onEditFinish` function to pass modified table data
315
- // back to the main DraftJS Edtior.
316
- function handleClickOutside(event) {
317
- // `!cellEditorReadOnly` condition is needed.
318
- // If there are two tables in the main Editor,
319
- // this `handleClickOutside` will only handle the just updated one.
320
- if (tableRef.current && !tableRef.current.contains(event.target) && !cellEditorReadOnly) {
321
- // make inner DraftJS Editors NOT editable
322
- setCellEditorReadOnly(true); // call `onEditFinish` function tell the main DraftJS Editor
323
- // that we are finishing interacting with the custom atomic block.
324
-
325
- onEditFinish({
326
- entityKey,
327
- entityData: {
328
- tableData: convertTableDataToRaw(tableData),
329
- tableStyles
330
- }
331
- });
332
- }
333
- }
334
-
335
- console.debug('(rich-text-editor/table): add click outside event listener');
336
- document.addEventListener('mousedown', handleClickOutside);
337
- return () => {
338
- // Unbind the event listener on clean up
339
- console.debug('(rich-text-editor/table): remove click outside event listener');
340
- document.removeEventListener('mousedown', handleClickOutside);
341
- };
342
- }, // Skip running effect if `tableData` and `cellEditorReadOnly` are not changed.
343
- [tableData, cellEditorReadOnly]);
344
- return /*#__PURE__*/_react.default.createElement(TableBlockContainer, null, /*#__PURE__*/_react.default.createElement(Table, {
345
- key: entityKey,
346
- onClick: onTableClick,
347
- ref: tableRef
348
- }, /*#__PURE__*/_react.default.createElement(StyledFirstRow, null, /*#__PURE__*/_react.default.createElement("div", null), tableData === null || tableData === void 0 ? void 0 : (_tableData$2 = tableData[0]) === null || _tableData$2 === void 0 ? void 0 : _tableData$2.map((colData, cIndex) => {
349
- return /*#__PURE__*/_react.default.createElement("div", {
350
- key: `col_${cIndex + 1}`
351
- }, /*#__PURE__*/_react.default.createElement("span", {
352
- onClick: () => {
353
- const deleteColumn = {
354
- type: ActionType.Delete,
355
- target: TableEnum.Column,
356
- index: cIndex
357
- };
358
- const updatedTableData = resolveTableData(deleteColumn, tableData);
359
- setTableData(updatedTableData);
360
- }
361
- }), /*#__PURE__*/_react.default.createElement("span", {
362
- onClick: () => {
363
- const insertColumn = {
364
- type: ActionType.Insert,
365
- target: TableEnum.Column,
366
- index: cIndex + 1
367
- };
368
- const updatedTableData = resolveTableData(insertColumn, tableData);
369
- setTableData(updatedTableData);
370
- }
371
- }));
372
- })), tableData.map((rowData, rIndex) => {
373
- var _tableStyles$rows;
374
-
375
- const colsJsx = rowData.map((colData, cIndex) => {
376
- return /*#__PURE__*/_react.default.createElement(Td, {
377
- key: `col_${cIndex}`
378
- }, /*#__PURE__*/_react.default.createElement(_draftJs.Editor, {
379
- onChange: editorState => {
380
- const updateAction = {
381
- type: ActionType.Update,
382
- cIndex,
383
- rIndex,
384
- value: editorState
385
- };
386
- const updatedTableData = resolveTableData(updateAction, tableData);
387
- setTableData(updatedTableData);
388
- },
389
- editorState: colData,
390
- readOnly: cellEditorReadOnly
391
- }));
392
- });
393
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
394
- key: `row_${rIndex}`
395
- }, /*#__PURE__*/_react.default.createElement(Tr, {
396
- style: tableStyles === null || tableStyles === void 0 ? void 0 : (_tableStyles$rows = tableStyles.rows) === null || _tableStyles$rows === void 0 ? void 0 : _tableStyles$rows[rIndex]
397
- }, /*#__PURE__*/_react.default.createElement(StyledFirstColumn, null, /*#__PURE__*/_react.default.createElement("span", {
398
- onClick: () => {
399
- const deleteRowAction = {
400
- type: ActionType.Delete,
401
- target: TableEnum.Row,
402
- index: rIndex
403
- };
404
- const updatedTableData = resolveTableData(deleteRowAction, tableData);
405
- setTableData(updatedTableData);
406
- setTableStyles(resolveTableStyles(deleteRowAction, tableStyles));
407
- }
408
- }), /*#__PURE__*/_react.default.createElement("span", {
409
- onClick: () => {
410
- const addRowAction = {
411
- type: ActionType.Insert,
412
- target: TableEnum.Row,
413
- index: rIndex + 1
414
- };
415
- const updatedTableData = resolveTableData(addRowAction, tableData);
416
- setTableData(updatedTableData);
417
- setTableStyles(resolveTableStyles(addRowAction, tableStyles));
418
- }
419
- })), colsJsx));
420
- })));
421
- };
422
-
423
- exports.TableEditorBlock = TableEditorBlock;
424
-
425
- const TableBlock = props => {
426
- const {
427
- block,
428
- contentState
429
- } = props;
430
- const entityKey = block.getEntityAt(0);
431
- const entity = contentState.getEntity(entityKey);
432
- const {
433
- tableData: rawTableData
434
- } = entity.getData();
435
- const [tableData] = (0, _react.useState)(convertTableDataFromRaw(rawTableData));
436
- const tableRef = (0, _react.useRef)(null);
437
- return /*#__PURE__*/_react.default.createElement(TableBlockContainer, null, /*#__PURE__*/_react.default.createElement(StyledTable, {
438
- key: entityKey,
439
- ref: tableRef
440
- }, tableData.map((rowData, rIndex) => {
441
- const colsJsx = rowData.map((colData, cIndex) => {
442
- return /*#__PURE__*/_react.default.createElement(StyledTd, {
443
- key: `col_${cIndex}`
444
- }, /*#__PURE__*/_react.default.createElement(_draftJs.Editor, {
445
- editorState: colData,
446
- readOnly: true
447
- }));
448
- });
449
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
450
- key: `row_${rIndex}`
451
- }, /*#__PURE__*/_react.default.createElement(StyledTr, null, colsJsx));
452
- })));
453
- };
454
-
455
- exports.TableBlock = TableBlock;
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.VideoBlock = VideoBlock;
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 Video = _styledComponents.default.video`
15
- width: 100%;
16
- ${({
17
- theme
18
- }) => theme.margin.default};
19
- `;
20
-
21
- function VideoBlock(entity) {
22
- var _video$file;
23
-
24
- const {
25
- video
26
- } = entity.getData();
27
- return /*#__PURE__*/_react.default.createElement(Video, {
28
- muted: true,
29
- autoPlay: true,
30
- loop: true,
31
- controls: true
32
- }, /*#__PURE__*/_react.default.createElement("source", {
33
- src: video === null || video === void 0 ? void 0 : video.url
34
- }), /*#__PURE__*/_react.default.createElement("source", {
35
- src: video === null || video === void 0 ? void 0 : (_video$file = video.file) === null || _video$file === void 0 ? void 0 : _video$file.url
36
- }));
37
- }
@@ -1,134 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = SlideshowLightBox;
7
-
8
- var _reactImage = _interopRequireDefault(require("@readr-media/react-image"));
9
-
10
- var _react = _interopRequireDefault(require("react"));
11
-
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
13
-
14
- var _slideshowSidebar = _interopRequireDefault(require("./slideshow-sidebar"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- const defaultImage = "https://unpkg.com/@kids-reporter/draft-renderer@0.1.0/lib/public/722f90c535fa64c27555ec6ee5f22393.png";
19
- const closeCross = "https://unpkg.com/@kids-reporter/draft-renderer@0.1.0/lib/public/903cf84ef5c5ad76634c30bdc0ff8c49.png";
20
- const LightBoxWrapper = _styledComponents.default.div`
21
- display: none;
22
-
23
- ${({
24
- theme
25
- }) => theme.breakpoint.xl} {
26
- background: #000928;
27
- width: 100%;
28
- height: 100vh;
29
- position: fixed;
30
- top: 0;
31
- left: 0;
32
- color: white;
33
- padding: 0 72px 0 48px;
34
- display: flex;
35
- align-items: center;
36
- justify-content: space-between;
37
- z-index: 9999;
38
- }
39
- `;
40
- const FocusImageWrapper = _styledComponents.default.div`
41
- font-weight: 400;
42
- ${({
43
- theme
44
- }) => theme.fontSize.sm};
45
- line-height: 23px;
46
- text-align: center;
47
- color: #ffffff;
48
- `;
49
- const FocusImage = _styledComponents.default.figure`
50
- max-width: 900px;
51
- max-height: 480px;
52
- overflow: hidden;
53
- margin-bottom: 32px;
54
-
55
- ${({
56
- theme
57
- }) => theme.breakpoint.xxl} {
58
- max-width: 960px;
59
- }
60
- `;
61
- const FocusInfo = _styledComponents.default.div`
62
- .focus-desc {
63
- max-height: 46px;
64
- overflow: hidden;
65
- word-break: break-word;
66
- display: -webkit-box;
67
- -webkit-box-orient: vertical;
68
- -webkit-line-clamp: 2;
69
- opacity: 0.87;
70
- margin-bottom: 12px;
71
- }
72
-
73
- .focus-number {
74
- opacity: 0.5;
75
- margin-top: 12px;
76
- }
77
- `;
78
- const CloseButtonWrapper = _styledComponents.default.div`
79
- height: 60vh;
80
- width: 64px;
81
- position: relative;
82
- `;
83
- const CloseButton = _styledComponents.default.div`
84
- background-image: url(${closeCross});
85
- width: 64px;
86
- height: 64px;
87
- margin: auto;
88
- background-repeat: no-repeat;
89
- background-position: center center;
90
- cursor: pointer;
91
- position: absolute;
92
- top: -64px;
93
- border-radius: 50%;
94
- background-size: 64px;
95
-
96
- &:hover {
97
- background-color: rgba(255, 255, 255, 0.2);
98
- }
99
- `;
100
-
101
- function SlideshowLightBox({
102
- focusImageIndex,
103
- images,
104
- setShowLightBox,
105
- setFocusImageIndex,
106
- imagesRefs
107
- }) {
108
- const focusImageDesc = `${images[focusImageIndex].desc}`;
109
- const focusNumber = `${focusImageIndex + 1} / ${images === null || images === void 0 ? void 0 : images.length}`;
110
- return /*#__PURE__*/_react.default.createElement(LightBoxWrapper, null, /*#__PURE__*/_react.default.createElement(_slideshowSidebar.default, {
111
- focusImageIndex: focusImageIndex,
112
- images: images,
113
- setFocusImageIndex: setFocusImageIndex,
114
- imagesRefs: imagesRefs
115
- }), /*#__PURE__*/_react.default.createElement(FocusImageWrapper, null, /*#__PURE__*/_react.default.createElement(FocusImage, null, /*#__PURE__*/_react.default.createElement(_reactImage.default, {
116
- images: images[focusImageIndex].resized,
117
- defaultImage: defaultImage,
118
- alt: images[focusImageIndex].name,
119
- rwd: {
120
- desktop: '64px',
121
- default: '100%'
122
- },
123
- priority: true
124
- })), /*#__PURE__*/_react.default.createElement(FocusInfo, null, /*#__PURE__*/_react.default.createElement("p", {
125
- className: "focus-desc"
126
- }, focusImageDesc), /*#__PURE__*/_react.default.createElement("p", {
127
- className: "focus-number"
128
- }, focusNumber))), /*#__PURE__*/_react.default.createElement(CloseButtonWrapper, null, /*#__PURE__*/_react.default.createElement(CloseButton, {
129
- onClick: e => {
130
- e.preventDefault();
131
- setShowLightBox(false);
132
- }
133
- })));
134
- }