@capillarytech/creatives-library 3.0.19 → 3.0.21

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.
@@ -1082,7 +1082,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1082
1082
  const updateDateTime = (moment().format('DD-MM-YYYY') === moment(template.updatedAt).format('DD-MM-YYYY')) ? moment(template.updatedAt).format('hh:mma') : moment(template.updatedAt).format('DD MMM YYYY');
1083
1083
  let content = '';
1084
1084
  temp.id = template._id;
1085
- if (this.state.channel === 'wechat') {
1085
+ if (this.state.channel === 'wechat' && template.type.toLowerCase() === 'wechat') {
1086
1086
  let path = '';
1087
1087
  if (template && template.versions && template.versions.base && !_.isEmpty(template.versions.base)) {
1088
1088
  if (template.definition && template.definition.msgcontent && template.definition.msgcontent === "RICH_MEDIA_WECHAT") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "3.0.19",
4
+ "version": "3.0.21",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -12,7 +12,7 @@ import {isEmpty} from 'lodash';
12
12
  import { connect } from 'react-redux';
13
13
  import { bindActionCreators } from 'redux';
14
14
  import { createStructuredSelector } from 'reselect';
15
- import { CapSpin, CapButton } from '@capillarytech/cap-ui-library';
15
+ import { CapSpin, CapButton, CapLabel } from '@capillarytech/cap-ui-library';
16
16
  import moment from 'moment';
17
17
  import EmailPreviewV2 from '../EmailPreviewV2';
18
18
  import messages from '../EmailPreviewV2/messages';
@@ -24,8 +24,8 @@ import * as templateActions from '../../containers/Templates/actions';
24
24
 
25
25
  const deviceAspectRatio = {
26
26
  mobile: {
27
- height: "440",
28
- width: "230",
27
+ height: "415",
28
+ width: "227",
29
29
  },
30
30
  };
31
31
 
@@ -65,9 +65,15 @@ class EmailMobilePreview extends React.Component {
65
65
  const {
66
66
  templateContent,
67
67
  enableShowAllDevices,
68
+ templateSubject,
68
69
  } = this.props;
69
70
  const { showAllDevices } = this.state;
70
71
 
72
+ const emailSubjectLabel = templateSubject && (
73
+ <CapLabel className="email-subject-mobile" type="label2">
74
+ <FormattedMessage {...messages.subject} /> {templateSubject}</CapLabel>
75
+ );
76
+
71
77
  return (
72
78
  <div className="email-mobile-preview-container">
73
79
  {showAllDevices ? (
@@ -87,8 +93,9 @@ class EmailMobilePreview extends React.Component {
87
93
  </CapButton>
88
94
  )}
89
95
  <div className={"shell align-center"}>
96
+ {emailSubjectLabel}
90
97
  <img src={mobileBody} alt="capillary" width="60%" />
91
- <div className={messageContainerName}>
98
+ <div className={`${messageContainerName} ${emailSubjectLabel ? 'with-subject' : ''}`}>
92
99
  <iframe srcDoc={templateContent} {...deviceAspectRatio.mobile} >
93
100
  <p><FormattedMessage {...messages.noIframeSupport}/></p>
94
101
  </iframe>
@@ -115,6 +122,7 @@ class EmailMobilePreview extends React.Component {
115
122
 
116
123
  EmailMobilePreview.propTypes = {
117
124
  templateContent: PropTypes.string,
125
+ templateSubject: PropTypes.string,
118
126
  templateData: PropTypes.object,
119
127
  templateActions: PropTypes.object,
120
128
  onClickShowInAllDevices: PropTypes.func,
@@ -33,15 +33,22 @@ $classPrefix: email-mobile-preview-container;
33
33
 
34
34
  }
35
35
  .email-preview-container{
36
-
36
+ .email-subject-mobile {
37
+ position: absolute;
38
+ top: 11.5%;
39
+ left: 26%;
40
+ }
37
41
  .mobile-message-container {
38
42
  position: absolute;
39
43
  top: 10.3%;
40
- left: 24%;
44
+ left: 24.8%;
41
45
  overflow: auto;
42
46
  display: -webkit-box;
43
47
  display: -ms-flexbox;
44
48
  display: flex;
49
+ &.with-subject {
50
+ top: 15%;
51
+ }
45
52
  }
46
53
  }
47
54
  padding: 0 0px 0 24px;
@@ -53,48 +53,47 @@
53
53
  // display: table;
54
54
 
55
55
  #emailPreivew-content {
56
- .device-wrapper {
57
- display: inline-flex;
58
- margin-bottom: 8px;
59
- margin-top: 16px;
60
- .device-name {
61
- padding: 6px 24px;
62
- background: #E6F0FB;
63
- border: 2px solid #E6F0FB;
64
- font-family: "open-sans";
65
- line-height: 20px;
66
- font-size: 14px;
67
- color: #4E92E5;
68
- cursor: pointer;
69
- }
70
- .active {
71
- background: #FFFFFF !important;
72
- border: 2px solid #E6F0FB;
73
- }
74
-
56
+ .email-preview-device-tabs .ant-tabs-bar {
57
+ justify-content: center;
58
+ flex-direction: none;
75
59
  }
76
60
  .email-preview-container{
61
+ .shell {
62
+ position: relative;
63
+ -webkit-transform: unset;
64
+ transform: unset;
65
+ left: unset;
66
+ padding: unset;
67
+ width: unset;
68
+ display: flex;
69
+ justify-content: center;
70
+ }
71
+ .email-subject-mobile {
72
+ width: 310px;
73
+ text-align: left;
74
+ margin: 8px 0;
75
+ margin-left: 4px;
76
+ }
77
+ .email-subject-tablet {
78
+ width: 450px;
79
+ text-align: left;
80
+ margin: 8px 0;
81
+ margin-left: 4px;
82
+ }
83
+ .email-subject-desktop {
84
+ text-align: left;
85
+ margin-bottom: 8px;
86
+ }
77
87
  .tablet-message-container {
78
88
  position: absolute;
79
89
  top: 9%;
80
- left: 10%;
81
- width: 100%;
82
90
  height: 100%;
83
91
  overflow: auto;
84
- display: -webkit-box;
85
- display: -ms-flexbox;
86
- display: flex;
87
92
  }
88
93
  .mobile-message-container {
89
94
  position: absolute;
90
95
  top: 10.3%;
91
- left: 14%;
92
- width: 100%;
93
96
  height: 100%;
94
- overflow: auto;
95
- display: -webkit-box;
96
- display: -ms-flexbox;
97
- display: flex;
98
97
  }
99
98
  }
100
99
  padding: 0 0px 0 24px;
@@ -7,6 +7,10 @@
7
7
  import PropTypes from 'prop-types';
8
8
 
9
9
  import React from 'react';
10
+ import styled from 'styled-components';
11
+ import get from 'lodash/get';
12
+ import { CapTab, CapIcon, CapLabel } from '@capillarytech/cap-ui-library';
13
+ import { CAP_G01, CAP_G06, FONT_SIZE_VL } from '@capillarytech/cap-ui-library/styled/variables';
10
14
  import { FormattedMessage } from 'react-intl';
11
15
  import moment from "moment";
12
16
  import messages from "./messages";
@@ -16,30 +20,49 @@ import mobileBody from '../../assets/mobile.png';
16
20
 
17
21
  // this component will be deprecated after replacing with the v2 component.
18
22
  const deviceAspectRatio = {
19
- desktop: {
23
+ desktop: () => ({
20
24
  height: "500",
21
25
  width: "1024",
22
- },
23
- tablet: {
24
- height: "600",
25
- width: "520",
26
- },
27
- mobile: {
28
- height: "600",
29
- width: "320",
30
- },
26
+ }),
27
+ tablet: (emailSubject) => ({
28
+ height: emailSubject ? "570" : "600",
29
+ width: "450",
30
+ }),
31
+ mobile: (emailSubject) => ({
32
+ height: emailSubject ? "570" : "600",
33
+ width: "310",
34
+ }),
31
35
  };
32
36
 
37
+ const StyledCapIcon = styled(CapIcon)`
38
+ color: ${(props) => props.active ? CAP_G01 : CAP_G06};
39
+ font-size: ${FONT_SIZE_VL};
40
+ `;
41
+
33
42
  class EmailPreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
34
43
  render() {
35
- console.log('URL tablet', tabletBody, mobileBody);
44
+ const { device, content, versions = {} } = this.props;
45
+ const emailSubject = get(versions, 'base.subject');
36
46
  let messageContainerName = '';
37
- if (this.props.device === 'tablet') {
47
+ let subjectClassName = 'email-subject-desktop';
48
+ if (device === 'tablet') {
38
49
  messageContainerName = 'tablet-message-container';
39
- } else if (this.props.device === 'mobile') {
50
+ subjectClassName = "email-subject-tablet";
51
+ } else if (device === 'mobile') {
40
52
  messageContainerName = 'mobile-message-container';
53
+ subjectClassName = "email-subject-mobile";
41
54
  }
42
55
 
56
+ const emailSubjectLabel = emailSubject && (
57
+ <CapLabel className={subjectClassName} type="label2">
58
+ <FormattedMessage {...messages.subject} /> {emailSubject}</CapLabel>
59
+ );
60
+ const iframeDiv = (<div className={`${messageContainerName}`}>
61
+ {emailSubjectLabel}
62
+ <iframe srcDoc={content} {...deviceAspectRatio[device](emailSubject)} >
63
+ <p>Your browser does not support iframes.</p>
64
+ </iframe>
65
+ </div>);
43
66
  return (
44
67
  <div className={this.props.show ? "modal-emailPreivew-wrapper show-emailPreivew" : "modal-emailPreivew-wrapper hide-emailPreivew"}>
45
68
  <div id="emailPreivew-container">
@@ -54,25 +77,41 @@ class EmailPreview extends React.Component { // eslint-disable-line react/prefer
54
77
 
55
78
  <div id="emailPreivew-content-wrapper">
56
79
  <div id="emailPreivew-content">
57
- {/* {this.props.content} */}
58
- <div className="device-wrapper">
59
- <div onClick={() => this.props.changePreviewDevice("desktop")} className={(this.props.device.toLowerCase() === "desktop") ? "device-name active" : "device-name"}>Desktop</div>
60
- <div onClick={() => this.props.changePreviewDevice("tablet")} className={(this.props.device.toLowerCase() === "tablet") ? "device-name active" : "device-name"}>Tablet</div>
61
- <div onClick={() => this.props.changePreviewDevice("mobile")} className={(this.props.device.toLowerCase() === "mobile") ? "device-name active" : "device-name"}>Mobile</div>
62
- </div>
63
- <div className="email-preview-container">
64
- <div className={this.props.device === 'desktop' ? '' : "shell align-center"}>
65
- {this.props.device === 'tablet' ?
66
- <img src={tabletBody} alt="capillary" width="520" /> : ''}
67
- {this.props.device === 'mobile' ?
68
- <img src={mobileBody} alt="capillary" width="85%" /> : ''}
69
- <div className={messageContainerName}>
70
- <iframe srcDoc={this.props.content} {...deviceAspectRatio[this.props.device]} >
71
- <p>Your browser does not support iframes.</p>
72
- </iframe>
73
- </div>
74
- </div>
75
-
80
+ <CapTab
81
+ className="email-preview-device-tabs"
82
+ activeKey={this.props.device}
83
+ onChange={this.props.changePreviewDevice}
84
+ panes={[
85
+ {
86
+ key: 'desktop',
87
+ tab: <StyledCapIcon type="desktop" active={device === 'desktop'} />,
88
+ content: <div className="email-preview-container">
89
+ {iframeDiv}
90
+ </div>,
91
+ },
92
+ {
93
+ key: 'tablet',
94
+ tab: <StyledCapIcon type="tablet" active={device === 'tablet'} />,
95
+ content: (<div className="email-preview-container">
96
+ <div className="shell align-center">
97
+ <img src={tabletBody} alt="capillary" width="520" />
98
+ {iframeDiv}
99
+ </div>
100
+ </div>),
101
+ },
102
+ {
103
+ key: 'mobile',
104
+ tab: <StyledCapIcon type="mobile" active={device === 'mobile'} />,
105
+ content: (<div className="email-preview-container">
106
+ <div className="shell align-center">
107
+ <img src={mobileBody} alt="capillary" width="350" />
108
+ {iframeDiv}
109
+ </div>
110
+ </div>),
111
+ },
112
+ ]}
113
+ />
114
+ <div>
76
115
  {(this.props.lastModified && this.props.updatedByName) ? <div>
77
116
  <p className="preview-info" style={{ marginBottom: '8px', paddingTop: '8px'}}><FormattedMessage {...messages.lastModified} />: {moment(this.props.lastModified).format('MM-DD-YYYY')}</p>
78
117
  <p style={{marginBottom: '8px'}} className="preview-info"><FormattedMessage {...messages.uploadedBy} /> : {this.props.updatedByName}</p>
@@ -101,6 +140,7 @@ EmailPreview.propTypes = {
101
140
  changePreviewDevice: PropTypes.func,
102
141
  lastModified: PropTypes.string,
103
142
  updatedByName: PropTypes.string,
143
+ versions: PropTypes.object,
104
144
  };
105
145
 
106
146
  export default EmailPreview;
@@ -14,4 +14,8 @@ export default defineMessages({
14
14
  id: 'app.components.EmailPreview.uploadedBy',
15
15
  defaultMessage: 'Last modified by',
16
16
  },
17
+ subject: {
18
+ id: 'app.components.EmailPreview.subject',
19
+ defaultMessage: 'Subject:',
20
+ },
17
21
  });
@@ -16,6 +16,10 @@ $classPrefix: email-preview-v2;
16
16
  // display: table;
17
17
 
18
18
  #emailPreivew-content {
19
+ .email-preview-device-tabs .ant-tabs-bar {
20
+ justify-content: center;
21
+ flex-direction: none;
22
+ }
19
23
  .device-wrapper {
20
24
  display: inline-flex;
21
25
  margin-bottom: 8px;
@@ -37,25 +41,42 @@ $classPrefix: email-preview-v2;
37
41
 
38
42
  }
39
43
  .email-preview-container{
44
+ .shell {
45
+ position: relative;
46
+ -webkit-transform: unset;
47
+ transform: unset;
48
+ left: unset;
49
+ padding: unset;
50
+ width: unset;
51
+ display: flex;
52
+ justify-content: center;
53
+ }
54
+ .email-subject-mobile {
55
+ width: 310px;
56
+ text-align: left;
57
+ margin: 8px 0;
58
+ margin-left: 4px;
59
+ }
60
+ .email-subject-tablet {
61
+ width: 450px;
62
+ text-align: left;
63
+ margin: 8px 0;
64
+ margin-left: 4px;
65
+ }
66
+ .email-subject-desktop {
67
+ text-align: left;
68
+ margin-bottom: 8px;
69
+ }
40
70
  .tablet-message-container {
41
71
  position: absolute;
42
72
  top: 9%;
43
- left: 10%;
44
- width: 100%;
45
73
  height: 100%;
46
74
  overflow: auto;
47
- display: -webkit-box;
48
- display: -ms-flexbox;
49
- display: flex;
50
75
  }
51
76
  .mobile-message-container {
52
77
  position: absolute;
53
78
  top: 10.3%;
54
- left: 14%;
55
- overflow: auto;
56
- display: -webkit-box;
57
- display: -ms-flexbox;
58
- display: flex;
79
+ height: 100%;
59
80
  }
60
81
  }
61
82
  padding: 0 0px 0 24px;
@@ -5,14 +5,15 @@
5
5
  */
6
6
 
7
7
  import React from 'react';
8
- // import styled from 'styled-components';
8
+ import styled from 'styled-components';
9
9
  import PropTypes from 'prop-types';
10
10
  import { FormattedMessage } from 'react-intl';
11
- import {isEmpty} from 'lodash';
11
+ import { isEmpty, get } from 'lodash';
12
12
  import { connect } from 'react-redux';
13
13
  import { bindActionCreators } from 'redux';
14
14
  import { createStructuredSelector } from 'reselect';
15
- import { CapSpin } from '@capillarytech/cap-ui-library';
15
+ import { CapSpin, CapTab, CapIcon, CapLabel } from '@capillarytech/cap-ui-library';
16
+ import { CAP_G01, CAP_G06, FONT_SIZE_VL } from '@capillarytech/cap-ui-library/styled/variables';
16
17
  import moment from 'moment';
17
18
  import messages from './messages';
18
19
  import './_emailPreviewV2.scss';
@@ -23,24 +24,30 @@ import {selectTemplateContent} from '../../v2Containers/Templates/selectors';
23
24
  import * as templateActions from '../../v2Containers/Templates/actions';
24
25
 
25
26
  const deviceAspectRatio = {
26
- desktop: {
27
+ desktop: () => ({
27
28
  height: "500",
28
29
  width: "1024",
29
- },
30
- tablet: {
31
- height: "600",
32
- width: "520",
33
- },
34
- mobile: {
35
- height: "600",
36
- width: "320",
37
- },
30
+ }),
31
+ tablet: (emailSubject) => ({
32
+ height: emailSubject ? "570" : "600",
33
+ width: "450",
34
+ }),
35
+ mobile: (emailSubject) => ({
36
+ height: emailSubject ? "570" : "600",
37
+ width: "310",
38
+ }),
38
39
  };
39
40
  const devices = {
40
41
  mobile: 'mobile',
41
42
  desktop: 'desktop',
42
43
  tablet: 'tablet',
43
44
  };
45
+
46
+ const StyledCapIcon = styled(CapIcon)`
47
+ color: ${(props) => props.active ? CAP_G01 : CAP_G06};
48
+ font-size: ${FONT_SIZE_VL};
49
+ `;
50
+
44
51
  class EmailPreviewV2 extends React.Component {
45
52
  constructor(props) {
46
53
  super(props);
@@ -57,31 +64,75 @@ class EmailPreviewV2 extends React.Component {
57
64
  componentWillUnmount() {
58
65
  this.props.templateActions.resetTemplateData();
59
66
  }
60
- changePreviewDevice = (ev) => {
61
- this.setState({currentDevice: ev.currentTarget.id});
67
+ changePreviewDevice = (device) => {
68
+ this.setState({currentDevice: device});
62
69
  }
63
70
  render() {
64
71
  let messageContainerName = '';
65
72
  const {currentDevice} = this.state;
66
- const {templateContent} = this.props;
67
-
73
+ const { templateContent, templateData = {}, templateSubject } = this.props;
74
+ let subjectClassName = 'email-subject-desktop';
68
75
  if (currentDevice === devices.tablet) {
69
76
  messageContainerName = 'tablet-message-container';
77
+ subjectClassName = "email-subject-tablet";
70
78
  } else if (currentDevice === devices.mobile) {
71
79
  messageContainerName = 'mobile-message-container';
80
+ subjectClassName = "email-subject-mobile";
72
81
  }
82
+ const emailSubject = get(templateData, 'versions.base.subject') || templateSubject;
83
+ const emailSubjectLabel = emailSubject && (
84
+ <CapLabel className={subjectClassName} type="label2">
85
+ <FormattedMessage {...messages.subject} /> {emailSubject}</CapLabel>
86
+ );
87
+ const iframeDiv = (<div className={`${messageContainerName}`}>
88
+ {emailSubjectLabel}
89
+ <iframe srcDoc={templateContent} {...deviceAspectRatio[currentDevice](emailSubject)} >
90
+ <p>Your browser does not support iframes.</p>
91
+ </iframe>
92
+ </div>);
93
+
94
+
73
95
  return (
74
96
  <div className="email-preview-v2">
75
97
  <CapSpin spinning={!templateContent}>
76
98
  <div id="emailPreivew-container">
77
99
  <div id="emailPreivew-content-wrapper">
78
100
  <div id="emailPreivew-content">
79
- <div className="device-wrapper">
80
- <div id={devices.desktop} onClick={this.changePreviewDevice} className={`device-name ${currentDevice === devices.desktop ? 'active' : ''}`}><FormattedMessage {...messages.desktop}/></div>
81
- <div id={devices.tablet} onClick={this.changePreviewDevice} className={`device-name ${currentDevice === devices.tablet ? 'active' : ''}`}><FormattedMessage {...messages.tablet}/></div>
82
- <div id={devices.mobile} onClick={this.changePreviewDevice} className={`device-name ${currentDevice === devices.mobile ? 'active' : ''}`}><FormattedMessage {...messages.mobile}/></div>
83
- </div>
84
- <div className="email-preview-container">
101
+ <CapTab
102
+ className="email-preview-device-tabs"
103
+ activeKey={currentDevice}
104
+ onChange={this.changePreviewDevice}
105
+ panes={[
106
+ {
107
+ key: 'desktop',
108
+ tab: <StyledCapIcon type="desktop" active={currentDevice === 'desktop'} />,
109
+ content: <div className="email-preview-container">
110
+ {iframeDiv}
111
+ </div>,
112
+ },
113
+ {
114
+ key: 'tablet',
115
+ tab: <StyledCapIcon type="tablet" active={currentDevice === 'tablet'} />,
116
+ content: (<div className="email-preview-container">
117
+ <div className="shell align-center">
118
+ <img src={tabletBody} alt="capillary" width="520" />
119
+ {iframeDiv}
120
+ </div>
121
+ </div>),
122
+ },
123
+ {
124
+ key: 'mobile',
125
+ tab: <StyledCapIcon type="mobile" active={currentDevice === 'mobile'} />,
126
+ content: (<div className="email-preview-container">
127
+ <div className="shell align-center">
128
+ <img src={mobileBody} alt="capillary" width="350" />
129
+ {iframeDiv}
130
+ </div>
131
+ </div>),
132
+ },
133
+ ]}
134
+ />
135
+ {/* <div className="email-preview-container">
85
136
  <div className={currentDevice === devices.desktop ? '' : "shell align-center"}>
86
137
  {currentDevice === devices.tablet ?
87
138
  <img src={tabletBody} alt="capillary" width="520" /> : ''}
@@ -95,7 +146,7 @@ class EmailPreviewV2 extends React.Component {
95
146
  </div>
96
147
 
97
148
 
98
- </div>
149
+ </div> */}
99
150
  </div>
100
151
  </div>
101
152
  </div>
@@ -115,6 +166,7 @@ class EmailPreviewV2 extends React.Component {
115
166
 
116
167
  EmailPreviewV2.propTypes = {
117
168
  templateContent: PropTypes.string,
169
+ templateSubject: PropTypes.string,
118
170
  templateData: PropTypes.object,
119
171
  templateActions: PropTypes.object,
120
172
  device: PropTypes.string,
@@ -38,4 +38,8 @@ export default defineMessages({
38
38
  id: 'app.components.PreviewSideBar.uploadedBy',
39
39
  defaultMessage: 'Last modified by',
40
40
  },
41
+ subject: {
42
+ id: 'app.components.PreviewSideBar.uploadedBy',
43
+ defaultMessage: 'Subject:',
44
+ },
41
45
  });
@@ -1716,6 +1716,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1716
1716
  device={this.state.device}
1717
1717
  handleClose={this.toggleEmailPreview}
1718
1718
  changePreviewDevice={this.changePreviewDevice}
1719
+ versions={_.get(this.state, 'previewTemplate.versions', {})}
1719
1720
  lastModified={this.state.previewTemplate ? this.state.previewTemplate.updatedAt : ''}
1720
1721
  updatedByName={commonUtil.getUserNameById(parseInt(this.state.previewTemplate.updatedBy, 10), commonUtil.getMergedUserList(this.props.Templates.userList))}
1721
1722
  />}