@openlettermarketing/olc-react-sdk 0.0.17 → 0.0.19

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.
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import type { StoreType } from 'polotno/model/store';
3
3
  interface Props {
4
4
  store: StoreType;
5
+ currentTemplateType: string;
5
6
  }
6
7
  declare const SidePanel: React.FC<Props>;
7
8
  export default SidePanel;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openlettermarketing/olc-react-sdk",
3
3
  "private": false,
4
- "version": "0.0.17",
4
+ "version": "0.0.19",
5
5
  "type": "module",
6
6
  "description": "Simplify template builder integration for any product.",
7
7
  "main": "build/index.js",
@@ -55,7 +55,7 @@ const templateHeadingStyles: React.CSSProperties = {
55
55
  color: `var(--primaryColor)`,
56
56
  fontSize: `24px`,
57
57
  fontStyle: `normal`,
58
- fontWeight: `700`,
58
+ fontWeight: `600`,
59
59
  lineHeight: `normal`,
60
60
  marginBottom: `20px`,
61
61
  };
@@ -64,7 +64,7 @@ const templateTextStyles: React.CSSProperties = {
64
64
  color: `var(--textColor)`,
65
65
  fontSize: `14px`,
66
66
  fontStyle: `normal`,
67
- fontWeight: `500`,
67
+ fontWeight: `400`,
68
68
  lineHeight: `normal`,
69
69
  marginBottom: `16px`,
70
70
  };
@@ -78,6 +78,8 @@ const footerButtonStyles: React.CSSProperties = {
78
78
  borderRadius: '3px',
79
79
  backgroundColor: 'var(--secondaryButtonBgColor)',
80
80
  color: `var(--secondaryButtonTextColor)`,
81
+ fontSize: `14px`,
82
+ fontWeight: `500`,
81
83
  };
82
84
 
83
85
  const Images: Record<string, ReactElement> = {
@@ -172,7 +172,7 @@
172
172
  color: var(--primaryColor);
173
173
  font-size: 16px;
174
174
  font-style: normal;
175
- font-weight: 600;
175
+ font-weight: 500;
176
176
  line-height: normal;
177
177
  margin: 0;
178
178
  }
@@ -273,7 +273,7 @@
273
273
  color: var(--primaryColor);
274
274
  font-size: 16px;
275
275
  font-style: normal;
276
- font-weight: 600;
276
+ font-weight: 500;
277
277
  line-height: normal;
278
278
  margin: 0;
279
279
  }
@@ -36,13 +36,13 @@ const buttonStyles: CSSProperties = {
36
36
  const heading: CSSProperties = {
37
37
  fontSize: '22px',
38
38
  color: 'var(--dialogModalHeadingColor)',
39
- fontWeight: '700',
39
+ fontWeight: '600',
40
40
  };
41
41
 
42
42
  const subHeadingStyle: CSSProperties = {
43
43
  fontSize: '16px',
44
- color: 'var(--dialogModalTextColor',
45
- fontWeight: '700',
44
+ color: 'var(--dialogModalTextColor)',
45
+ fontWeight: '600',
46
46
  textAlign: 'center',
47
47
  };
48
48
 
@@ -94,7 +94,7 @@ const Dialog: React.FC<DialogProps> = ({
94
94
  {description && (
95
95
  <Typography
96
96
  variant="p"
97
- style={{...subHeadingStyle, fontWeight: '400'}}
97
+ style={{...subHeadingStyle, fontWeight: '400', fontSize: '14px'}}
98
98
  >
99
99
  {description}
100
100
  </Typography>
@@ -27,8 +27,8 @@
27
27
  padding: 5px 20px;
28
28
  background: transparent;
29
29
  font-size: 14px;
30
- font-family: 'Inter', sans-serif !important;
31
- font-weight: 500;
30
+ font-family: 'Inter' !important;
31
+ font-weight: 400;
32
32
  line-height: 24px;
33
33
  color: var(--inputTextColor);
34
34
  border: none;
@@ -52,12 +52,23 @@ const customFieldSection: SideSection = {
52
52
  dispatch(fetchCustomFields());
53
53
  }, [dispatch]);
54
54
 
55
- const handleAddElementOnScreen = (event: any, value: any, type: any) => {
56
- event.preventDefault();
57
55
 
58
- if (currentTemplateType === 'Real Penned Letter') {
56
+ const copyCustomFieldText = (value: string) => {
57
+ if (currentTemplateType === "Real Penned Letter") {
58
+ let modifiedString = value.replace(/{{/g, "((").replace(/}}/g, "))");
59
+ copyToClipboard(modifiedString);
60
+ dispatch(success(`${modifiedString} Copied`));
61
+ } else {
59
62
  copyToClipboard(value);
60
63
  dispatch(success(`${value} Copied`));
64
+ }
65
+ };
66
+
67
+ const handleAddElementOnScreen = (event: any, value: any, type: any) => {
68
+ event.preventDefault();
69
+
70
+ if (currentTemplateType === "Real Penned Letter") {
71
+ copyCustomFieldText(value);
61
72
  return;
62
73
  }
63
74
 
@@ -111,7 +122,7 @@ const customFieldSection: SideSection = {
111
122
  </span>
112
123
  <Button
113
124
  style={iconButtonStyles}
114
- onClick={() => copyToClipboard(key)}
125
+ onClick={() => copyCustomFieldText(key)}
115
126
  >
116
127
  <ContentCopyIcon className="copy" />
117
128
  </Button>
@@ -132,7 +143,7 @@ const customFieldSection: SideSection = {
132
143
  </div>
133
144
  <Button onClick={handleShowDialog}></Button>
134
145
  </div>
135
- {customFields.data?.map(
146
+ {customFields?.data?.map(
136
147
  ({key, value}: {key: string; value: string}, i: number) => (
137
148
  <div style={{display: 'flex', alignItems: 'center'}} key={i}>
138
149
  <span
@@ -145,7 +156,7 @@ const customFieldSection: SideSection = {
145
156
  </span>
146
157
  <Button
147
158
  style={iconButtonStyles}
148
- onClick={() => copyToClipboard(key)}
159
+ onClick={() => copyCustomFieldText(key)}
149
160
  >
150
161
  <ContentCopyIcon
151
162
  className="copy"
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  // Polotno Imports
4
4
  import { SidePanelWrap } from 'polotno';
5
5
  import type { StoreType } from 'polotno/model/store';
6
- import {SidePanel as PolotnoSidePanel, DEFAULT_SECTIONS} from 'polotno/side-panel';
6
+ import { SidePanel as PolotnoSidePanel, DEFAULT_SECTIONS } from 'polotno/side-panel';
7
7
 
8
8
  // Custom Sections
9
9
  import customTemplateSection from './templates/customTemplateSection';
@@ -12,16 +12,28 @@ import customFieldSection from './customFields/customFieldSection';
12
12
 
13
13
  interface Props {
14
14
  store: StoreType;
15
+ currentTemplateType: string;
15
16
  }
16
17
 
17
18
  const SidePanel: React.FC<Props> = (props) => {
18
- const sections = DEFAULT_SECTIONS.filter(
19
- (section) => !['photos', 'size', 'templates'].includes(section.name)
20
- );
21
-
19
+ const sections =
20
+ props.currentTemplateType === "Real Penned Letter"
21
+ ? DEFAULT_SECTIONS.filter((section) => section.name === "")
22
+ : DEFAULT_SECTIONS.filter(
23
+ (section) => !["photos", "size", "templates"].includes(section.name)
24
+ );
25
+
22
26
  return (
23
27
  <SidePanelWrap>
24
- <PolotnoSidePanel store={props.store} sections={[customTemplateSection, ...sections, customFieldSection]} defaultSection="text" />
28
+ <PolotnoSidePanel store={props.store}
29
+ sections={[
30
+ ...(props.currentTemplateType !== "Real Penned Letter"
31
+ ? [customTemplateSection]
32
+ : []),
33
+ ...sections,
34
+ customFieldSection,
35
+ ]}
36
+ defaultSection="text" />
25
37
  </SidePanelWrap>
26
38
  );
27
39
  };
@@ -272,9 +272,7 @@ const TemplateBuilder: React.FC<TemplateBuilderProps> = ({ store, styles, return
272
272
  <PolotnoContainer
273
273
  style={containerStyle}
274
274
  >
275
- {currentTemplateType !== "Real Penned Letter" &&
276
- <SidePanel store={store} />
277
- }
275
+ <SidePanel store={store} currentTemplateType={currentTemplateType} />
278
276
  <WorkspaceWrap>
279
277
  {currentTemplateType !== "Real Penned Letter" && (
280
278
  <Toolbar store={store} downloadButtonEnabled={false} />
@@ -23,7 +23,7 @@ import './styles.scss';
23
23
 
24
24
  const saveDialogStyles = {
25
25
  maxWidth: '433px',
26
- minHeight: '290px',
26
+ minHeight: '280px',
27
27
  };
28
28
 
29
29
  interface SaveTemplateModelProps {
@@ -61,6 +61,7 @@ const buttonStyles: React.CSSProperties = {
61
61
  color: 'var(--secondaryButtonTextColor)',
62
62
  border: '0.5px solid var(--borderColor)',
63
63
  fontSize: '15px',
64
+ fontWeight: '500'
64
65
  };
65
66
 
66
67
  const progressStyles: React.CSSProperties = {
@@ -130,7 +131,7 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
130
131
  setItem('formData', JSON.stringify(data));
131
132
  };
132
133
 
133
- const handleBackPress = () => {
134
+ const handleBackPress = () => {
134
135
  if (isStoreUpdated) {
135
136
  setShowNavigateDialog(!showNavigateDialog);
136
137
  } else {
@@ -140,7 +141,7 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
140
141
 
141
142
  const handleNavigation = async (route = '/') => {
142
143
  handleClearFilters();
143
- if (templateType === 'json') {
144
+ if (templateType === 'json' && product?.productType !== 'Real Penned Letter') {
144
145
  await store.history.clear();
145
146
  }
146
147
  navigate(route);
@@ -152,7 +153,13 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
152
153
  try {
153
154
  setDownloaingProof(true);
154
155
  const fields = [...defaultFields, ...Object.values(dynamicFields)];
155
- const json = store.toJSON();
156
+ let json = store.toJSON();
157
+ if (product?.productType === "Real Penned Letter") {
158
+ let clonedJson = JSON.stringify(json)
159
+ .replace(/\(\(/g, "{{")
160
+ .replace(/\)\)/g, "}}");
161
+ json = JSON.parse(clonedJson);
162
+ }
156
163
  let jsonString = JSON.stringify(json);
157
164
  fields.forEach(({ key, defaultValue, value }) => {
158
165
  const regex = new RegExp(key, 'g');
@@ -200,7 +207,14 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
200
207
  let selectedFields: typeof allFields = [];
201
208
  if (templateType === 'json') {
202
209
  const blob = await store.toBlob();
203
- const jsonData = store.toJSON();
210
+ let jsonData = store.toJSON();
211
+
212
+ if (product?.productType === "Real Penned Letter") {
213
+ let clonedJson = JSON.stringify(jsonData)
214
+ .replace(/\(\(/g, "{{")
215
+ .replace(/\)\)/g, "}}");
216
+ jsonData = JSON.parse(clonedJson);
217
+ }
204
218
 
205
219
  // get all fonts family from json
206
220
  const fontFamilies = extractFontFamilies(jsonData?.pages);
@@ -270,7 +284,9 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
270
284
  });
271
285
  if (response.status === 200) {
272
286
  dispatch(success(response.data.message));
273
- handleNavigation();
287
+ setTimeout(() => {
288
+ handleNavigation();
289
+ }, 2000);
274
290
  } else if (response.status == 418) {
275
291
  // nothing to do
276
292
  } else {
@@ -279,7 +295,9 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
279
295
  } catch (error) {
280
296
  handleChangeModel('', 'false');
281
297
  } finally {
282
- setIsShowModel((prev) => ({ ...prev, loading: false }));
298
+ setTimeout(() => {
299
+ setIsShowModel((prev) => ({ ...prev, loading: false }));
300
+ }, 2000);
283
301
  }
284
302
  };
285
303
 
@@ -335,7 +353,7 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
335
353
  handleSave={handleSave}
336
354
  />
337
355
  )}
338
- <GridContainer style={{alignItems: 'center'}}>
356
+ <GridContainer style={{ alignItems: 'center' }}>
339
357
  <GridItem lg={4} md={4} sm={2} xs={12}></GridItem>
340
358
  <GridItem lg={4} md={2} sm={2} xs={12}>
341
359
  <div className="middle">
@@ -348,7 +366,7 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
348
366
  <GridItem lg={4} md={6} sm={8} xs={12}>
349
367
  <div className="actionsBtnWrapper right">
350
368
  <Button
351
- style={{...buttonStyles, maxWidth: 'auto', minWidth: '100px'}}
369
+ style={{ ...buttonStyles, maxWidth: 'auto', minWidth: '100px' }}
352
370
  onClick={handleViewProofWithLamda}
353
371
  >
354
372
  {downloadingProof ? (
@@ -22,7 +22,7 @@
22
22
  text-align: center;
23
23
  margin-bottom: 0px;
24
24
  font-size: 16px;
25
- font-weight: 500;
25
+ font-weight: 400;
26
26
  text-overflow: ellipsis;
27
27
  white-space: nowrap;
28
28
  overflow: hidden;
package/src/index.scss CHANGED
@@ -70,7 +70,7 @@
70
70
  --red: #ff0000;
71
71
 
72
72
  body {
73
- font-family: 'Inter', sans-serif !important;
73
+ font-family: "Inter" !important;
74
74
  padding: 70px 0 0;
75
75
  margin: 0;
76
76
 
package/src/index.tsx CHANGED
@@ -48,16 +48,16 @@ const TemplateBuilder = ({
48
48
  setMode(mode);
49
49
  const root = ReactDOM.createRoot(container);
50
50
  root.render(
51
- <React.StrictMode>
52
- <Router>
53
- <Provider store={store}>
51
+ <>
52
+ <Provider store={store}>
53
+ <Router>
54
54
  <App
55
55
  secretKey={secretKey}
56
56
  styles={styles}
57
57
  returnRoute={returnRoute} />
58
- </Provider>
59
- </Router>
60
- </React.StrictMode>
58
+ </Router>
59
+ </Provider>
60
+ </>
61
61
  );
62
62
  };
63
63
 
@@ -84,45 +84,6 @@ export const addElementsforRealPennedLetters = (store: Store): void => {
84
84
  const page = store.pages[0];
85
85
 
86
86
  const elements: Element[] = [
87
- {
88
- id: "blocked",
89
- type: "figure",
90
- name: "",
91
- opacity: 1,
92
- visible: true,
93
- selectable: false,
94
- removable: false,
95
- alwaysOnTop: true,
96
- showInExport: true,
97
- x: -1.850472230905276e-12,
98
- y: -2.9487523534043754e-13,
99
- width: 528,
100
- height: 80.739,
101
- rotation: 0,
102
- animations: [],
103
- blurEnabled: false,
104
- blurRadius: 10,
105
- brightnessEnabled: false,
106
- brightness: 0,
107
- sepiaEnabled: false,
108
- grayscaleEnabled: false,
109
- shadowEnabled: false,
110
- shadowBlur: 5,
111
- shadowOffsetX: 0,
112
- shadowOffsetY: 0,
113
- shadowColor: "black",
114
- shadowOpacity: 1,
115
- draggable: false,
116
- resizable: false,
117
- contentEditable: false,
118
- styleEditable: true,
119
- subType: "rect",
120
- fill: "rgba(208,0,0,1)",
121
- dash: [],
122
- strokeWidth: 0,
123
- stroke: "#0c0c0c",
124
- cornerRadius: 0,
125
- },
126
87
  {
127
88
  id: 'header',
128
89
  type: 'text',
@@ -135,7 +96,7 @@ export const addElementsforRealPennedLetters = (store: Store): void => {
135
96
  showInExport: true,
136
97
  x: 25,
137
98
  y: 130,
138
- width: 300,
99
+ width: 480,
139
100
  height: 40,
140
101
  rotation: 0,
141
102
  animations: [],
@@ -155,7 +116,7 @@ export const addElementsforRealPennedLetters = (store: Store): void => {
155
116
  resizable: false,
156
117
  contentEditable: true,
157
118
  styleEditable: false,
158
- text: "Hi FirstNaame,",
119
+ text: "Hi ((C.FIRST_NAME)),",
159
120
  fontSize: 20,
160
121
  fontFamily: 'lexi Regular',
161
122
  fontStyle: 'normal',
@@ -235,9 +196,9 @@ export const addElementsforRealPennedLetters = (store: Store): void => {
235
196
  removable: false,
236
197
  alwaysOnTop: true,
237
198
  showInExport: true,
238
- x: 322.49999999499846,
199
+ x: 165.49999999499846,
239
200
  y: 651.7346179851188,
240
- width: 180,
201
+ width: 335,
241
202
  height: 75,
242
203
  rotation: 0,
243
204
  animations: [],
@@ -275,7 +236,7 @@ export const addElementsforRealPennedLetters = (store: Store): void => {
275
236
  backgroundOpacity: 1,
276
237
  backgroundCornerRadius: 0.5,
277
238
  backgroundPadding: 0.5,
278
- }
239
+ },
279
240
  ]
280
241
 
281
242
  elements.forEach(element => page.addElement(element));