@capillarytech/creatives-library 6.7.1 → 6.8.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.
- package/assets/line-image-placeholder.svg +14 -0
- package/assets/line.png +0 -0
- package/assets/smiley-placeholder.svg +11 -0
- package/components/TemplatePreview/index.js +185 -8
- package/index.js +3 -3
- package/package.json +1 -1
- package/routes.js +2 -2
- package/services/api.js +3 -0
- package/styles/vendor/semantic/src/definitions/modules/accordion.less +219 -219
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +1 -1
- package/v2Components/TemplatePreview/index.js +164 -12
- package/v2Components/TemplatePreview/messages.js +8 -0
- package/v2Containers/Assets/Gallery/index.js +3 -0
- package/v2Containers/Assets/Gallery/selectors.js +12 -5
- package/v2Containers/CreativesContainer/SlideBoxContent.js +51 -17
- package/v2Containers/CreativesContainer/index.js +23 -17
- package/v2Containers/Line/Container/Drawer/index.js +93 -0
- package/v2Containers/Line/Container/Image/constants.js +3 -0
- package/v2Containers/Line/Container/Image/index.js +460 -0
- package/v2Containers/Line/Container/Image/messages.js +86 -0
- package/v2Containers/Line/Container/Image/style.js +32 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/custom.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateEight.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateFive.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateFour.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateOne.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateSeven.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateSix.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateThree.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/hover/templateTwo.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/custom.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateEight.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateFive.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateFour.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateOne.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateSeven.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateSix.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateThree.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/selected/templateTwo.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/custom.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateEight.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateFive.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateFour.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateOne.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateSeven.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateSix.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateThree.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates/templateTwo.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/custom.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateEight.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateFive.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateFour.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateOne.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateSeven.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateSix.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateThree.png +0 -0
- package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateTwo.png +0 -0
- package/v2Containers/Line/Container/ImageMap/constants.js +19 -0
- package/v2Containers/Line/Container/ImageMap/index.js +603 -0
- package/v2Containers/Line/Container/ImageMap/messages.js +126 -0
- package/v2Containers/Line/Container/ImageMap/style.js +94 -0
- package/v2Containers/Line/Container/ImageMap/templates.json +195 -0
- package/v2Containers/Line/Container/Sticker/index.js +224 -0
- package/v2Containers/Line/Container/Sticker/messages.js +34 -0
- package/v2Containers/Line/Container/Sticker/style.js +36 -0
- package/v2Containers/Line/Container/Sticker/utils.js +68 -0
- package/v2Containers/Line/Container/Text/index.js +338 -0
- package/v2Containers/Line/Container/Text/messages.js +74 -0
- package/v2Containers/Line/Container/Text/style.js +37 -0
- package/v2Containers/Line/Container/Wrapper/index.js +152 -0
- package/v2Containers/Line/Container/Wrapper/messages.js +46 -0
- package/v2Containers/Line/Container/Wrapper/style.js +44 -0
- package/v2Containers/Line/Container/Wrapper/utils.js +67 -0
- package/v2Containers/Line/Container/_lineCreate.scss +108 -0
- package/v2Containers/Line/Container/actions.js +99 -0
- package/v2Containers/Line/Container/constants.js +48 -0
- package/v2Containers/Line/Container/index.js +581 -0
- package/v2Containers/Line/Container/messages.js +66 -0
- package/v2Containers/Line/Container/reducer.js +103 -0
- package/v2Containers/Line/Container/sagas.js +137 -0
- package/v2Containers/Line/Container/selectors.js +30 -0
- package/v2Containers/Line/Container/style.js +57 -0
- package/v2Containers/Line/Create/index.js +1 -1
- package/v2Containers/Templates/index.js +40 -22
- package/v2Containers/Templates/messages.js +8 -0
- package/v2Containers/TemplatesV2/index.js +13 -0
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { injectIntl, FormattedMessage } from 'react-intl';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import CapInput from '@capillarytech/cap-ui-library/CapInput';
|
|
5
|
+
import CapUploader from '@capillarytech/cap-ui-library/CapUploader';
|
|
6
|
+
import CapHeading from '@capillarytech/cap-ui-library/CapHeading';
|
|
7
|
+
import CapButton from '@capillarytech/cap-ui-library/CapButton';
|
|
8
|
+
import CapDrawer from '@capillarytech/cap-ui-library/CapDrawer';
|
|
9
|
+
import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
|
|
10
|
+
import CapImage from '@capillarytech/cap-ui-library/CapImage';
|
|
11
|
+
import CapHeader from '@capillarytech/cap-ui-library/CapHeader';
|
|
12
|
+
import LabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
|
|
13
|
+
import LineDrawer from '../Drawer';
|
|
14
|
+
import { CAP_SPACE_12, CAP_SPACE_08, FONT_COLOR_05, FONT_COLOR_04 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
15
|
+
import Gallery from '../../../Assets/Gallery';
|
|
16
|
+
import style from './style';
|
|
17
|
+
import { CAP_G06, CAP_G09 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
18
|
+
import withStyles from '../../../../hoc/withStyles';
|
|
19
|
+
|
|
20
|
+
import messages from './messages';
|
|
21
|
+
import {
|
|
22
|
+
LINE_IMG_HEIGHT,
|
|
23
|
+
LINE_IMG_WIDTH,
|
|
24
|
+
LINE_IMG_SIZE,
|
|
25
|
+
} from './constants';
|
|
26
|
+
|
|
27
|
+
export const LineImage = ({
|
|
28
|
+
className,
|
|
29
|
+
id,
|
|
30
|
+
intl: { formatMessage },
|
|
31
|
+
isFullMode,
|
|
32
|
+
inheritedTitleStyle,
|
|
33
|
+
supportedExtensions,
|
|
34
|
+
actions = {},
|
|
35
|
+
Line,
|
|
36
|
+
index,
|
|
37
|
+
updateMessageState,
|
|
38
|
+
content,
|
|
39
|
+
activeKey,
|
|
40
|
+
Templates,
|
|
41
|
+
getAllTemplates,
|
|
42
|
+
}) => {
|
|
43
|
+
if (activeKey !== 'image') {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const [errorMessageTitle, updateErrorMessageTitle] = useState(false);
|
|
48
|
+
const [isCreateNew, updateCreateNew] = useState(isFullMode);
|
|
49
|
+
const [messageTitle, updateTextMessageTitle] = useState('');
|
|
50
|
+
const [isDrawerRequired, updateDrawerRequirement] = useState(false);
|
|
51
|
+
const [isImage, updateImageStatus] = useState(false);
|
|
52
|
+
const [isImageError, updateImageErrorMessage] = useState(false);
|
|
53
|
+
const [imageSrc, updateImageSrc] = useState();
|
|
54
|
+
const [imagePreview, updateImagePreview] = useState();
|
|
55
|
+
const [isTemplateDrawerRequired, updateTemplateDrawerRequirement] = useState(false);
|
|
56
|
+
const [selectedTemplate, updateSelectedTemplate] = useState();
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const { messageTitle = '', originalContentUrl = '', previewImageUrl = '', type } = content;
|
|
60
|
+
if (originalContentUrl && type === 'image') {
|
|
61
|
+
updateImageStatus(true);
|
|
62
|
+
updateCreateNew(true);
|
|
63
|
+
updateImageSrc(originalContentUrl);
|
|
64
|
+
updateTextMessageTitle(messageTitle);
|
|
65
|
+
updateImagePreview(previewImageUrl);
|
|
66
|
+
}
|
|
67
|
+
}, [content]);
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (imageSrc && (isFullMode ? messageTitle: true) && imagePreview) {
|
|
71
|
+
updateMessageState({
|
|
72
|
+
isError: !imageSrc || !(isFullMode ? messageTitle : true) || (isImageError && errorMessageTitle),
|
|
73
|
+
originalContentUrl: imageSrc,
|
|
74
|
+
previewImageUrl: imagePreview,
|
|
75
|
+
messageTitle,
|
|
76
|
+
index,
|
|
77
|
+
type: 'image',
|
|
78
|
+
messageType: 'originalContentUrl',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}, [errorMessageTitle, imageSrc, messageTitle, isImageError]);
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const imgSrc = get(Line, 'uploadedAssetData.metaInfo.secure_file_path', '');
|
|
85
|
+
const imgPreview = get(Line, 'uploadedAssetData.metaInfo.secure_file_path_preview', '');
|
|
86
|
+
|
|
87
|
+
if (imgSrc) {
|
|
88
|
+
updateImageSrc(imgSrc);
|
|
89
|
+
updateImageStatus(true);
|
|
90
|
+
}
|
|
91
|
+
if (imgPreview) {
|
|
92
|
+
updateImagePreview(imgPreview);
|
|
93
|
+
}
|
|
94
|
+
}, [Line]);
|
|
95
|
+
|
|
96
|
+
const submitAction = (data, incorrectFile) => {
|
|
97
|
+
const {
|
|
98
|
+
file: {
|
|
99
|
+
size,
|
|
100
|
+
},
|
|
101
|
+
fileParams: {
|
|
102
|
+
height,
|
|
103
|
+
width,
|
|
104
|
+
},
|
|
105
|
+
type,
|
|
106
|
+
} = data;
|
|
107
|
+
if (incorrectFile || size > LINE_IMG_SIZE || height > LINE_IMG_HEIGHT || width > LINE_IMG_WIDTH) {
|
|
108
|
+
updateImageErrorMessage(formatMessage(messages.lineImageIncorrectSize))
|
|
109
|
+
} else {
|
|
110
|
+
data.fileParams.isGeneratePreview = true;
|
|
111
|
+
actions.uploadAsset(
|
|
112
|
+
data.file,
|
|
113
|
+
data.type,
|
|
114
|
+
data.fileParams,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const onTextTitleChange = ({ target: { value } }) => {
|
|
120
|
+
updateTextMessageTitle(value);
|
|
121
|
+
let errorMessage = false;
|
|
122
|
+
if (value === '') {
|
|
123
|
+
errorMessage = formatMessage(messages.emptyTitleErrorMessage);
|
|
124
|
+
updateMessageState({
|
|
125
|
+
isError: true,
|
|
126
|
+
originalContentUrl: imageSrc,
|
|
127
|
+
previewImageUrl: imagePreview,
|
|
128
|
+
messageTitle: '',
|
|
129
|
+
index,
|
|
130
|
+
type: 'image',
|
|
131
|
+
messageType: 'originalContentUrl',
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
updateErrorMessageTitle(errorMessage);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const uploadImages = (e, {files}) => {
|
|
138
|
+
if (e) {
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
}
|
|
141
|
+
const _URL = window.URL || window.webkitURL;
|
|
142
|
+
let incorrectFile = false;
|
|
143
|
+
const file = files[0];
|
|
144
|
+
if (supportedExtensions) {
|
|
145
|
+
const allowedExtensions = /(\.bmp|\.jpeg|\.png|\.gif|\.jpg)$/i;
|
|
146
|
+
if (!allowedExtensions.exec(file.name)) {
|
|
147
|
+
incorrectFile = true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const img = new Image();
|
|
151
|
+
img.src = _URL.createObjectURL(file);
|
|
152
|
+
img.onload = () => {
|
|
153
|
+
const fileParams = {
|
|
154
|
+
width: img.width,
|
|
155
|
+
height: img.height,
|
|
156
|
+
error: file && (file.size / (1e+6) > 3),
|
|
157
|
+
};
|
|
158
|
+
submitAction({file, type: 'image', fileParams}, incorrectFile);
|
|
159
|
+
};
|
|
160
|
+
if (e) {
|
|
161
|
+
const event = e;
|
|
162
|
+
event.target.value = null;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const capUploaderCustomRequest = (uploadData) => {
|
|
167
|
+
uploadImages(undefined, {files: [uploadData.file]});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const setDrawerVisibility = (drawervisibleFlag) => updateDrawerRequirement(drawervisibleFlag);
|
|
171
|
+
|
|
172
|
+
const onGalleryClick = (event) => {
|
|
173
|
+
event.stopPropagation();
|
|
174
|
+
setDrawerVisibility(true);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const ImageComponent = (props) => (
|
|
178
|
+
<div key={`${id}_imgComponent`}>
|
|
179
|
+
<CapHeading type="label3" style={{ marginBotton: 20, color: 'unset' }}>
|
|
180
|
+
<FormattedMessage {...messages.uploadImageLabel} />
|
|
181
|
+
</CapHeading>
|
|
182
|
+
<div
|
|
183
|
+
className={`image-container ${props.ifError ? 'error' : ''}`}
|
|
184
|
+
style={{
|
|
185
|
+
marginTop: isImage ? 20 : 8,
|
|
186
|
+
backgroundColor: CAP_G09,
|
|
187
|
+
}}
|
|
188
|
+
>
|
|
189
|
+
{isImage
|
|
190
|
+
? (
|
|
191
|
+
<CapImage src={imageSrc} alt="line-image-src" style={props.style} height="400"/>
|
|
192
|
+
)
|
|
193
|
+
: (
|
|
194
|
+
<div style={{width: "100%", textAlign: "center"}}>
|
|
195
|
+
<span className="image-placeholder">{props.placeholder}</span>
|
|
196
|
+
</div>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const WithLabel = LabelHOC(ImageComponent);
|
|
204
|
+
|
|
205
|
+
const onReUpload = () => {
|
|
206
|
+
updateImageStatus(false);
|
|
207
|
+
if (!isFullMode) {
|
|
208
|
+
updateCreateNew(false);
|
|
209
|
+
}
|
|
210
|
+
updateImageSrc('');
|
|
211
|
+
updateImagePreview('');
|
|
212
|
+
updateMessageState({
|
|
213
|
+
isError: true,
|
|
214
|
+
originalContentUrl: '',
|
|
215
|
+
previewImageUrl: '',
|
|
216
|
+
messageTitle,
|
|
217
|
+
index,
|
|
218
|
+
type: 'image',
|
|
219
|
+
messageType: 'originalContentUrl',
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const onSelectTemplate = (event) => {
|
|
224
|
+
event.stopPropagation();
|
|
225
|
+
updateTemplateDrawerRequirement(true);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const getLineImageSection = (isImage) => {
|
|
229
|
+
if (!isCreateNew) {
|
|
230
|
+
return (
|
|
231
|
+
<div className="form-builder-dragger" style={{
|
|
232
|
+
textAlign: 'center',
|
|
233
|
+
border: `1px dashed ${CAP_G06}`,
|
|
234
|
+
minHeight: 120,
|
|
235
|
+
padding: 60
|
|
236
|
+
}}>
|
|
237
|
+
<CapHeader
|
|
238
|
+
className="choice-title"
|
|
239
|
+
size="regular"
|
|
240
|
+
title={formatMessage(messages.textMessageAddLabel)}
|
|
241
|
+
style={{ marginBottom: 12 }}
|
|
242
|
+
/>
|
|
243
|
+
|
|
244
|
+
<CapButton
|
|
245
|
+
className="dragger-button create-button"
|
|
246
|
+
type="secondary"
|
|
247
|
+
style={{marginRight: CAP_SPACE_08}}
|
|
248
|
+
onClick={setNewContent}
|
|
249
|
+
isAddBtn
|
|
250
|
+
>
|
|
251
|
+
<FormattedMessage {...messages.textMessageCreateNew} />
|
|
252
|
+
</CapButton>
|
|
253
|
+
|
|
254
|
+
<CapHeading className="dragger-or" type="label6" style={{ display: 'inline-block' }}>
|
|
255
|
+
<FormattedMessage {...messages.textMessageORLabel} />
|
|
256
|
+
</CapHeading>
|
|
257
|
+
|
|
258
|
+
<CapButton
|
|
259
|
+
className="dragger-button select-template-button"
|
|
260
|
+
type="secondary"
|
|
261
|
+
style={{marginLeft: CAP_SPACE_08}}
|
|
262
|
+
onClick={onSelectTemplate}
|
|
263
|
+
>
|
|
264
|
+
<FormattedMessage {...messages.textMessageSelectTemplate} />
|
|
265
|
+
</CapButton>
|
|
266
|
+
</div>);
|
|
267
|
+
} else {
|
|
268
|
+
if (!isImage) {
|
|
269
|
+
return (
|
|
270
|
+
<>
|
|
271
|
+
<CapUploader.CapDragger
|
|
272
|
+
customRequest={(data) => capUploaderCustomRequest(data)}
|
|
273
|
+
className="form-builder-dragger"
|
|
274
|
+
>
|
|
275
|
+
<CapHeading className="dragger-title" type="h7">
|
|
276
|
+
<FormattedMessage {...messages.dragAndDrop} />
|
|
277
|
+
</CapHeading>
|
|
278
|
+
<CapHeading className="dragger-or" type="label6">
|
|
279
|
+
<FormattedMessage {...messages.or} />
|
|
280
|
+
</CapHeading>
|
|
281
|
+
<CapButton className="dragger-button" type="secondary" style={{marginRight: CAP_SPACE_08}}>
|
|
282
|
+
<FormattedMessage {...messages.uploadComputer} />
|
|
283
|
+
</CapButton>
|
|
284
|
+
<CapButton
|
|
285
|
+
className="dragger-button"
|
|
286
|
+
type="secondary"
|
|
287
|
+
style={{marginLeft: CAP_SPACE_08}}
|
|
288
|
+
onClick={onGalleryClick}
|
|
289
|
+
>
|
|
290
|
+
<FormattedMessage {...messages.uploadGallery} />
|
|
291
|
+
</CapButton>
|
|
292
|
+
</CapUploader.CapDragger>
|
|
293
|
+
<CapHeading type="h6" style={{marginTop: CAP_SPACE_12 }}>
|
|
294
|
+
<FormattedMessage {...messages.imageDimenstionDescription} />
|
|
295
|
+
</CapHeading>
|
|
296
|
+
</>);
|
|
297
|
+
}
|
|
298
|
+
return (
|
|
299
|
+
<CapButton
|
|
300
|
+
className="dragger-button"
|
|
301
|
+
type="flat"
|
|
302
|
+
style={{
|
|
303
|
+
top: isFullMode ? 60 : -8,
|
|
304
|
+
position: 'absolute',
|
|
305
|
+
right: 0, color:
|
|
306
|
+
FONT_COLOR_05
|
|
307
|
+
}}
|
|
308
|
+
onClick={onReUpload}
|
|
309
|
+
>
|
|
310
|
+
<FormattedMessage {...messages.imageReUpload} />
|
|
311
|
+
</CapButton>
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const setNewContent = () => updateCreateNew(true);
|
|
317
|
+
|
|
318
|
+
const onTemplateSelection = (template) => {
|
|
319
|
+
const originalContentUrl = get(template, 'versions.base.content.messages[0].originalContentUrl', '');
|
|
320
|
+
const previewImageUrl = get(template, 'versions.base.content.messages[0].previewImageUrl', '');
|
|
321
|
+
updateSelectedTemplate(template);
|
|
322
|
+
updateImageSrc(originalContentUrl);
|
|
323
|
+
updateImagePreview(previewImageUrl || originalContentUrl);
|
|
324
|
+
updateImageStatus(true);
|
|
325
|
+
updateTemplateDrawerRequirement(false);
|
|
326
|
+
updateCreateNew(true);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const getLineImageDrawerContent = () => {
|
|
330
|
+
const lineTextTemplates = Templates.templates;
|
|
331
|
+
if (!lineTextTemplates) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const cardDataList = [];
|
|
336
|
+
lineTextTemplates.forEach(template => {
|
|
337
|
+
let templateData = {};
|
|
338
|
+
const {
|
|
339
|
+
content: {
|
|
340
|
+
messages: [{
|
|
341
|
+
originalContentUrl = '',
|
|
342
|
+
}] = [{}],
|
|
343
|
+
} = {},
|
|
344
|
+
} = template.versions.base;
|
|
345
|
+
templateData.url = originalContentUrl;
|
|
346
|
+
templateData.title = template.name;
|
|
347
|
+
templateData.key = template.name;
|
|
348
|
+
templateData.hoverOption = (
|
|
349
|
+
<CapButton onClick={() => onTemplateSelection(template)}>
|
|
350
|
+
<FormattedMessage {...messages.select} />
|
|
351
|
+
</CapButton>
|
|
352
|
+
);
|
|
353
|
+
if (originalContentUrl) {
|
|
354
|
+
cardDataList.push(templateData);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
return (
|
|
358
|
+
<>
|
|
359
|
+
<CapHeading type="h3" className="drawer-head">
|
|
360
|
+
{formatMessage(messages.lineTemplateImage)}
|
|
361
|
+
</CapHeading>
|
|
362
|
+
<LineDrawer
|
|
363
|
+
getAllTemplates={getAllTemplates}
|
|
364
|
+
cardDataList={cardDataList}
|
|
365
|
+
isDrawer={isTemplateDrawerRequired}
|
|
366
|
+
searchPlaceholder={formatMessage(messages.searchImages)}
|
|
367
|
+
/>
|
|
368
|
+
</>
|
|
369
|
+
);
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
const onGalleryImageSelect = (imageTemplate) => {
|
|
373
|
+
const image = get(imageTemplate, 'metaInfo.secure_file_path');
|
|
374
|
+
const imagePreview = get(imageTemplate, 'metaInfo.secure_file_path_preview');
|
|
375
|
+
updateDrawerRequirement(false);
|
|
376
|
+
updateImageStatus(true);
|
|
377
|
+
updateImageSrc(image);
|
|
378
|
+
updateImagePreview(imagePreview);
|
|
379
|
+
updateMessageState({
|
|
380
|
+
isError: !image || !(isFullMode ? messageTitle : true) || (isImageError && errorMessageTitle),
|
|
381
|
+
originalContentUrl: image,
|
|
382
|
+
previewImageUrl: imagePreview,
|
|
383
|
+
messageTitle,
|
|
384
|
+
index,
|
|
385
|
+
type: 'image',
|
|
386
|
+
messageType: 'originalContentUrl',
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const getGalleryDrawerContent = () => {
|
|
391
|
+
const location = {
|
|
392
|
+
pathname: `/assets`,
|
|
393
|
+
search: '',
|
|
394
|
+
query: !isFullMode ? {type: 'embedded', module: 'library'} : {},
|
|
395
|
+
};
|
|
396
|
+
return (
|
|
397
|
+
<>
|
|
398
|
+
<CapHeading type="h3">
|
|
399
|
+
{formatMessage(messages.imageGallery)}
|
|
400
|
+
</CapHeading>
|
|
401
|
+
<Gallery
|
|
402
|
+
location={location}
|
|
403
|
+
isFullMode={isFullMode}
|
|
404
|
+
isLineAsset
|
|
405
|
+
onGalleryImageSelect={onGalleryImageSelect}
|
|
406
|
+
/>
|
|
407
|
+
</>
|
|
408
|
+
);
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
return (
|
|
413
|
+
<div className={className}>
|
|
414
|
+
{
|
|
415
|
+
isFullMode
|
|
416
|
+
? (
|
|
417
|
+
<CapInput
|
|
418
|
+
id={`${id}_input`}
|
|
419
|
+
onChange={onTextTitleChange}
|
|
420
|
+
errorMessage={errorMessageTitle}
|
|
421
|
+
className="image-template-title"
|
|
422
|
+
style={inheritedTitleStyle || {}}
|
|
423
|
+
placeholder={formatMessage(messages.textMessageTitlePlaceholder)}
|
|
424
|
+
defaultValue={messageTitle || ''}
|
|
425
|
+
value={messageTitle || ''}
|
|
426
|
+
size="default"
|
|
427
|
+
label={formatMessage(messages.textMessageTitleLabel)}
|
|
428
|
+
/>
|
|
429
|
+
)
|
|
430
|
+
: null
|
|
431
|
+
}
|
|
432
|
+
<WithLabel key={`${id}-with-label`} errorMessage={isImageError} ifError={!!isImageError}/>
|
|
433
|
+
<form encType="multipart/form-data" id={`${id}_form`}>
|
|
434
|
+
<input
|
|
435
|
+
key={`${id}_imgFile`}
|
|
436
|
+
style={{ display: 'none'}}
|
|
437
|
+
id="fileName"
|
|
438
|
+
type="file"
|
|
439
|
+
onChange={(e) => uploadImages(e, {files: e.target.files})}
|
|
440
|
+
accept={supportedExtensions ? supportedExtensions : "image/*"}
|
|
441
|
+
/>
|
|
442
|
+
{getLineImageSection(isImage)}
|
|
443
|
+
<CapDrawer
|
|
444
|
+
content={getGalleryDrawerContent()}
|
|
445
|
+
visible={isDrawerRequired}
|
|
446
|
+
width={430}
|
|
447
|
+
onClose={() => updateDrawerRequirement(false)}
|
|
448
|
+
/>
|
|
449
|
+
<CapDrawer
|
|
450
|
+
content={getLineImageDrawerContent()}
|
|
451
|
+
visible={isTemplateDrawerRequired}
|
|
452
|
+
width={624}
|
|
453
|
+
onClose={() => updateTemplateDrawerRequirement(false)}
|
|
454
|
+
/>
|
|
455
|
+
</form>
|
|
456
|
+
</div>
|
|
457
|
+
)
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export default injectIntl(withStyles(LineImage, style));
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* LineImage Messages
|
|
3
|
+
*
|
|
4
|
+
* This contains all the text for the LineImage component.
|
|
5
|
+
*/
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
const scope = `creatives.containersV2.LineImage`;
|
|
8
|
+
|
|
9
|
+
export default defineMessages({
|
|
10
|
+
"textMessageAddLabel": {
|
|
11
|
+
id: `${scope}.textMessageAddLabel`,
|
|
12
|
+
defaultMessage: 'How do you want to upload the image?',
|
|
13
|
+
},
|
|
14
|
+
"textMessageCreateNew": {
|
|
15
|
+
id: `${scope}.textMessageCreateNew`,
|
|
16
|
+
defaultMessage: 'Create new',
|
|
17
|
+
},
|
|
18
|
+
"textMessageSelectTemplate": {
|
|
19
|
+
id: `${scope}.textMessageSelectTemplate`,
|
|
20
|
+
defaultMessage: 'Select template',
|
|
21
|
+
},
|
|
22
|
+
"textMessageORLabel": {
|
|
23
|
+
id: `${scope}.textMessageORLabel`,
|
|
24
|
+
defaultMessage: 'OR',
|
|
25
|
+
},
|
|
26
|
+
"textMessageTitlePlaceholder": {
|
|
27
|
+
id: `${scope}.textMessageTitlePlaceholder`,
|
|
28
|
+
defaultMessage: 'Enter template name',
|
|
29
|
+
},
|
|
30
|
+
"textMessageTitleLabel": {
|
|
31
|
+
id: `${scope}.textMessageTitleLabel`,
|
|
32
|
+
defaultMessage: 'Template name',
|
|
33
|
+
},
|
|
34
|
+
"emptyTitleErrorMessage": {
|
|
35
|
+
id: `${scope}.emptyTitleErrorMessage`,
|
|
36
|
+
defaultMessage: 'Template title can not be empty',
|
|
37
|
+
},
|
|
38
|
+
"imageDimenstionDescription": {
|
|
39
|
+
id: `${scope}.imageDimenstionDescription`,
|
|
40
|
+
defaultMessage: 'Dimensions: 300px x 400px Size: 30mb',
|
|
41
|
+
},
|
|
42
|
+
"imageReUpload": {
|
|
43
|
+
id: `${scope}.imageReUpload`,
|
|
44
|
+
defaultMessage: 'Re upload',
|
|
45
|
+
},
|
|
46
|
+
"uploadGallery": {
|
|
47
|
+
id: `${scope}.uploadGallery`,
|
|
48
|
+
defaultMessage: 'Gallery',
|
|
49
|
+
},
|
|
50
|
+
"uploadComputer": {
|
|
51
|
+
id: `${scope}.uploadComputer`,
|
|
52
|
+
defaultMessage: 'Your computer',
|
|
53
|
+
},
|
|
54
|
+
"or": {
|
|
55
|
+
id: `${scope}.or`,
|
|
56
|
+
defaultMessage: 'OR',
|
|
57
|
+
},
|
|
58
|
+
"dragAndDrop": {
|
|
59
|
+
id: `${scope}.dragAndDrop`,
|
|
60
|
+
defaultMessage: 'Drag and drop image here',
|
|
61
|
+
},
|
|
62
|
+
"lineImageIncorrectSize": {
|
|
63
|
+
id: `${scope}.lineImageIncorrectSize`,
|
|
64
|
+
defaultMessage: 'Please upload the image with correct type, size and dimension',
|
|
65
|
+
},
|
|
66
|
+
"imageGallery": {
|
|
67
|
+
id: `${scope}.imageGallery`,
|
|
68
|
+
defaultMessage: 'Gallery',
|
|
69
|
+
},
|
|
70
|
+
"uploadImageLabel": {
|
|
71
|
+
id: `${scope}.uploadImageLabel`,
|
|
72
|
+
defaultMessage: 'Upload Image',
|
|
73
|
+
},
|
|
74
|
+
"select": {
|
|
75
|
+
id: `${scope}.select`,
|
|
76
|
+
defaultMessage: 'Select',
|
|
77
|
+
},
|
|
78
|
+
"lineTemplateImage": {
|
|
79
|
+
id: `${scope}.lineTemplateImage`,
|
|
80
|
+
defaultMessage: 'Line templates - Image',
|
|
81
|
+
},
|
|
82
|
+
"searchImages": {
|
|
83
|
+
id: `${scope}.searchImages`,
|
|
84
|
+
defaultMessage: 'Search Images',
|
|
85
|
+
}
|
|
86
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { css } from 'styled-components';
|
|
2
|
+
import {
|
|
3
|
+
CAP_SPACE_44,
|
|
4
|
+
CAP_SPACE_28,
|
|
5
|
+
CAP_SPACE_20,
|
|
6
|
+
CAP_SPACE_12,
|
|
7
|
+
CAP_SPACE_08,
|
|
8
|
+
CAP_G07,
|
|
9
|
+
CAP_G12,
|
|
10
|
+
CAP_G06,
|
|
11
|
+
FONT_COLOR_05,
|
|
12
|
+
CAP_SPACE_16,
|
|
13
|
+
CAP_SECONDARY,
|
|
14
|
+
CAP_SPACE_24,
|
|
15
|
+
FONT_COLOR_02,
|
|
16
|
+
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
17
|
+
|
|
18
|
+
export default css`
|
|
19
|
+
padding: 0 ${CAP_SPACE_16} ${CAP_SPACE_16};
|
|
20
|
+
position: relative;
|
|
21
|
+
|
|
22
|
+
.image-container {
|
|
23
|
+
background-color: ${CAP_G06};
|
|
24
|
+
margin-top: 20px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.choice-title {
|
|
28
|
+
margin-bottom: ${CAP_SPACE_24};
|
|
29
|
+
color: ${FONT_COLOR_02};
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateEight.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateSeven.png
ADDED
|
Binary file
|
|
Binary file
|