@everymatrix/blog-article-details 1.10.6
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/dist/blog-article-details/blog-article-details.esm.js +1 -0
- package/dist/blog-article-details/index.esm.js +0 -0
- package/dist/blog-article-details/p-6214f0ca.entry.js +1 -0
- package/dist/blog-article-details/p-7187d97f.js +1 -0
- package/dist/cjs/blog-article-details.cjs.entry.js +146 -0
- package/dist/cjs/blog-article-details.cjs.js +19 -0
- package/dist/cjs/index-df694837.js +1122 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/blog-article-details/blog-article-details.css +51 -0
- package/dist/collection/components/blog-article-details/blog-article-details.js +350 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +20 -0
- package/dist/collection/utils/utils.js +0 -0
- package/dist/components/blog-article-details.d.ts +11 -0
- package/dist/components/blog-article-details.js +176 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/esm/blog-article-details.entry.js +142 -0
- package/dist/esm/blog-article-details.js +17 -0
- package/dist/esm/index-c07b2186.js +1097 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.js +22 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/blog-article-details/.stencil/packages/blog-article-details/stencil.config.d.ts +2 -0
- package/dist/types/components/blog-article-details/blog-article-details.d.ts +61 -0
- package/dist/types/components.d.ts +133 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/utils/locale.utils.d.ts +1 -0
- package/dist/types/utils/utils.d.ts +0 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +23 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-df694837.js');
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
9
|
+
*/
|
|
10
|
+
const patchEsm = () => {
|
|
11
|
+
return index.promiseResolve();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const defineCustomElements = (win, options) => {
|
|
15
|
+
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
|
+
return patchEsm().then(() => {
|
|
17
|
+
return index.bootstrapLazy([["blog-article-details.cjs",[[1,"blog-article-details",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"handleClick":[1,"handle-click"],"clientStyling":[1,"client-styling"],"clientStylingurl":[1,"client-stylingurl"],"clientStylingUrlContent":[1,"client-styling-url-content"],"showPublishingDate":[4,"show-publishing-date"],"showImage":[4,"show-image"],"showTitle":[4,"show-title"],"showContent":[4,"show-content"],"postMessageEvent":[1,"post-message-event"],"postId":[2,"post-id"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32]}]]]], options);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.defineCustomElements = defineCustomElements;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.GridContainer {
|
|
6
|
+
overflow: auto;
|
|
7
|
+
margin: auto;
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding-bottom: 30px;
|
|
10
|
+
background-color: #07072A;
|
|
11
|
+
display: grid;
|
|
12
|
+
grid-template-rows: auto;
|
|
13
|
+
grid-template-columns: 30px 60px 1fr 30px;
|
|
14
|
+
gap: 10px;
|
|
15
|
+
}
|
|
16
|
+
.GridContainer .BlogBanner {
|
|
17
|
+
grid-column: 1/5;
|
|
18
|
+
grid-row: 1/3;
|
|
19
|
+
}
|
|
20
|
+
.GridContainer .BlogBanner img {
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: auto;
|
|
23
|
+
}
|
|
24
|
+
.GridContainer .BlogDate {
|
|
25
|
+
grid-column: 2/3;
|
|
26
|
+
grid-row: 2/3;
|
|
27
|
+
font-size: 12px;
|
|
28
|
+
border-radius: 5px 5px 0 0;
|
|
29
|
+
padding: 10px;
|
|
30
|
+
width: fit-content;
|
|
31
|
+
text-align: center;
|
|
32
|
+
color: #FFF;
|
|
33
|
+
background-color: #0D0D4D;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
}
|
|
36
|
+
.GridContainer .BlogTitle {
|
|
37
|
+
grid-column: 2/4;
|
|
38
|
+
font-size: 24px;
|
|
39
|
+
color: #FFF;
|
|
40
|
+
}
|
|
41
|
+
.GridContainer .BlogContent {
|
|
42
|
+
grid-column: 2/4;
|
|
43
|
+
font-size: 14px;
|
|
44
|
+
color: #FFF;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@container (max-width: 475px) {
|
|
48
|
+
.GridContainer {
|
|
49
|
+
font-size: 12px;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { Component, Prop, State, h } from '@stencil/core';
|
|
2
|
+
import { translate } from '../../utils/locale.utils';
|
|
3
|
+
export class BlogArticleDetails {
|
|
4
|
+
constructor() {
|
|
5
|
+
/**
|
|
6
|
+
* Language of the widget
|
|
7
|
+
*/
|
|
8
|
+
this.language = 'en';
|
|
9
|
+
/**
|
|
10
|
+
* Client custom styling via string
|
|
11
|
+
*/
|
|
12
|
+
this.clientStyling = '';
|
|
13
|
+
/**
|
|
14
|
+
* Client custom styling via url
|
|
15
|
+
*/
|
|
16
|
+
this.clientStylingurl = '';
|
|
17
|
+
/**
|
|
18
|
+
* Client custom styling via url content
|
|
19
|
+
*/
|
|
20
|
+
this.clientStylingUrlContent = '';
|
|
21
|
+
/**
|
|
22
|
+
* Property used to display the publishing date
|
|
23
|
+
*/
|
|
24
|
+
this.showPublishingDate = true;
|
|
25
|
+
/**
|
|
26
|
+
* Property used to display the image
|
|
27
|
+
*/
|
|
28
|
+
this.showImage = true;
|
|
29
|
+
/**
|
|
30
|
+
* Property used to display the image
|
|
31
|
+
*/
|
|
32
|
+
this.showTitle = true;
|
|
33
|
+
/**
|
|
34
|
+
* Property used to display the description
|
|
35
|
+
*/
|
|
36
|
+
this.showContent = true;
|
|
37
|
+
/**
|
|
38
|
+
* Event name to be sent when the button is clicked
|
|
39
|
+
*/
|
|
40
|
+
this.postMessageEvent = 'articleActionButton';
|
|
41
|
+
this.hasErrors = false;
|
|
42
|
+
this.limitStylingAppends = false;
|
|
43
|
+
this.isLoading = true;
|
|
44
|
+
this.setClientStyling = () => {
|
|
45
|
+
let sheet = document.createElement('style');
|
|
46
|
+
sheet.innerHTML = this.clientStyling;
|
|
47
|
+
this.stylingContainer.prepend(sheet);
|
|
48
|
+
};
|
|
49
|
+
this.setClientStylingURL = () => {
|
|
50
|
+
let url = new URL(this.clientStylingurl);
|
|
51
|
+
let cssFile = document.createElement('style');
|
|
52
|
+
fetch(url.href)
|
|
53
|
+
.then((res) => res.text())
|
|
54
|
+
.then((data) => {
|
|
55
|
+
this.clientStylingUrlContent = data;
|
|
56
|
+
cssFile.innerHTML = data;
|
|
57
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
58
|
+
})
|
|
59
|
+
.catch((err) => {
|
|
60
|
+
console.log('error ', err);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
getBlogArticleDetails() {
|
|
65
|
+
if (!this.postId && isNaN(this.postId)) {
|
|
66
|
+
this.hasErrors = true;
|
|
67
|
+
throw new Error('The postId parameter is missing!');
|
|
68
|
+
}
|
|
69
|
+
this.isLoading = true;
|
|
70
|
+
let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postId}`);
|
|
71
|
+
fetch(url.href)
|
|
72
|
+
.then((res) => {
|
|
73
|
+
if (res.status >= 300) {
|
|
74
|
+
this.hasErrors = true;
|
|
75
|
+
throw new Error('There was an error while fetching the data');
|
|
76
|
+
}
|
|
77
|
+
return res.json();
|
|
78
|
+
})
|
|
79
|
+
.then((blogContent) => {
|
|
80
|
+
this.blogData = blogContent;
|
|
81
|
+
this.isLoading = false;
|
|
82
|
+
})
|
|
83
|
+
.catch((err) => {
|
|
84
|
+
this.hasErrors = true;
|
|
85
|
+
console.log('Error', err);
|
|
86
|
+
})
|
|
87
|
+
.finally(() => this.isLoading = false);
|
|
88
|
+
}
|
|
89
|
+
componentDidRender() {
|
|
90
|
+
// start custom styling area
|
|
91
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
92
|
+
if (this.clientStyling)
|
|
93
|
+
this.setClientStyling();
|
|
94
|
+
if (this.clientStylingUrlContent)
|
|
95
|
+
this.setClientStylingURL();
|
|
96
|
+
this.limitStylingAppends = true;
|
|
97
|
+
}
|
|
98
|
+
// end custom styling area
|
|
99
|
+
}
|
|
100
|
+
componentWillLoad() {
|
|
101
|
+
this.getBlogArticleDetails();
|
|
102
|
+
}
|
|
103
|
+
render() {
|
|
104
|
+
if (this.hasErrors) {
|
|
105
|
+
return (h("div", { class: "BlogArticleDetails" },
|
|
106
|
+
h("div", { class: "Title" }, translate('error', this.language))));
|
|
107
|
+
}
|
|
108
|
+
if (!this.isLoading) {
|
|
109
|
+
return (h("div", { ref: el => this.stylingContainer = el },
|
|
110
|
+
h("div", { class: "GridContainer" },
|
|
111
|
+
this.showPublishingDate &&
|
|
112
|
+
h("div", { class: "BlogDate" }, this.blogData.publishingDate),
|
|
113
|
+
this.showImage &&
|
|
114
|
+
h("div", { class: "BlogBanner" },
|
|
115
|
+
h("img", { src: this.blogData, alt: this.blogData.title })),
|
|
116
|
+
this.showTitle &&
|
|
117
|
+
h("div", { class: "BlogTitle" }, this.blogData.title),
|
|
118
|
+
this.showContent &&
|
|
119
|
+
h("div", { class: "BlogContent", innerHTML: this.blogData.content }))));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
static get is() { return "blog-article-details"; }
|
|
123
|
+
static get encapsulation() { return "shadow"; }
|
|
124
|
+
static get originalStyleUrls() { return {
|
|
125
|
+
"$": ["blog-article-details.scss"]
|
|
126
|
+
}; }
|
|
127
|
+
static get styleUrls() { return {
|
|
128
|
+
"$": ["blog-article-details.css"]
|
|
129
|
+
}; }
|
|
130
|
+
static get properties() { return {
|
|
131
|
+
"cmsEndpoint": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"mutable": false,
|
|
134
|
+
"complexType": {
|
|
135
|
+
"original": "string",
|
|
136
|
+
"resolved": "string",
|
|
137
|
+
"references": {}
|
|
138
|
+
},
|
|
139
|
+
"required": false,
|
|
140
|
+
"optional": false,
|
|
141
|
+
"docs": {
|
|
142
|
+
"tags": [],
|
|
143
|
+
"text": "Endpoint URL for the source of data"
|
|
144
|
+
},
|
|
145
|
+
"attribute": "cms-endpoint",
|
|
146
|
+
"reflect": false
|
|
147
|
+
},
|
|
148
|
+
"language": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"mutable": false,
|
|
151
|
+
"complexType": {
|
|
152
|
+
"original": "string",
|
|
153
|
+
"resolved": "string",
|
|
154
|
+
"references": {}
|
|
155
|
+
},
|
|
156
|
+
"required": false,
|
|
157
|
+
"optional": false,
|
|
158
|
+
"docs": {
|
|
159
|
+
"tags": [],
|
|
160
|
+
"text": "Language of the widget"
|
|
161
|
+
},
|
|
162
|
+
"attribute": "language",
|
|
163
|
+
"reflect": false,
|
|
164
|
+
"defaultValue": "'en'"
|
|
165
|
+
},
|
|
166
|
+
"handleClick": {
|
|
167
|
+
"type": "string",
|
|
168
|
+
"mutable": false,
|
|
169
|
+
"complexType": {
|
|
170
|
+
"original": "string",
|
|
171
|
+
"resolved": "string",
|
|
172
|
+
"references": {}
|
|
173
|
+
},
|
|
174
|
+
"required": false,
|
|
175
|
+
"optional": false,
|
|
176
|
+
"docs": {
|
|
177
|
+
"tags": [],
|
|
178
|
+
"text": "Handle when you click on show more button"
|
|
179
|
+
},
|
|
180
|
+
"attribute": "handle-click",
|
|
181
|
+
"reflect": false
|
|
182
|
+
},
|
|
183
|
+
"clientStyling": {
|
|
184
|
+
"type": "string",
|
|
185
|
+
"mutable": false,
|
|
186
|
+
"complexType": {
|
|
187
|
+
"original": "string",
|
|
188
|
+
"resolved": "string",
|
|
189
|
+
"references": {}
|
|
190
|
+
},
|
|
191
|
+
"required": false,
|
|
192
|
+
"optional": false,
|
|
193
|
+
"docs": {
|
|
194
|
+
"tags": [],
|
|
195
|
+
"text": "Client custom styling via string"
|
|
196
|
+
},
|
|
197
|
+
"attribute": "client-styling",
|
|
198
|
+
"reflect": false,
|
|
199
|
+
"defaultValue": "''"
|
|
200
|
+
},
|
|
201
|
+
"clientStylingurl": {
|
|
202
|
+
"type": "string",
|
|
203
|
+
"mutable": false,
|
|
204
|
+
"complexType": {
|
|
205
|
+
"original": "string",
|
|
206
|
+
"resolved": "string",
|
|
207
|
+
"references": {}
|
|
208
|
+
},
|
|
209
|
+
"required": false,
|
|
210
|
+
"optional": false,
|
|
211
|
+
"docs": {
|
|
212
|
+
"tags": [],
|
|
213
|
+
"text": "Client custom styling via url"
|
|
214
|
+
},
|
|
215
|
+
"attribute": "client-stylingurl",
|
|
216
|
+
"reflect": false,
|
|
217
|
+
"defaultValue": "''"
|
|
218
|
+
},
|
|
219
|
+
"clientStylingUrlContent": {
|
|
220
|
+
"type": "string",
|
|
221
|
+
"mutable": false,
|
|
222
|
+
"complexType": {
|
|
223
|
+
"original": "string",
|
|
224
|
+
"resolved": "string",
|
|
225
|
+
"references": {}
|
|
226
|
+
},
|
|
227
|
+
"required": false,
|
|
228
|
+
"optional": false,
|
|
229
|
+
"docs": {
|
|
230
|
+
"tags": [],
|
|
231
|
+
"text": "Client custom styling via url content"
|
|
232
|
+
},
|
|
233
|
+
"attribute": "client-styling-url-content",
|
|
234
|
+
"reflect": false,
|
|
235
|
+
"defaultValue": "''"
|
|
236
|
+
},
|
|
237
|
+
"showPublishingDate": {
|
|
238
|
+
"type": "boolean",
|
|
239
|
+
"mutable": false,
|
|
240
|
+
"complexType": {
|
|
241
|
+
"original": "boolean",
|
|
242
|
+
"resolved": "boolean",
|
|
243
|
+
"references": {}
|
|
244
|
+
},
|
|
245
|
+
"required": false,
|
|
246
|
+
"optional": false,
|
|
247
|
+
"docs": {
|
|
248
|
+
"tags": [],
|
|
249
|
+
"text": "Property used to display the publishing date"
|
|
250
|
+
},
|
|
251
|
+
"attribute": "show-publishing-date",
|
|
252
|
+
"reflect": false,
|
|
253
|
+
"defaultValue": "true"
|
|
254
|
+
},
|
|
255
|
+
"showImage": {
|
|
256
|
+
"type": "boolean",
|
|
257
|
+
"mutable": false,
|
|
258
|
+
"complexType": {
|
|
259
|
+
"original": "boolean",
|
|
260
|
+
"resolved": "boolean",
|
|
261
|
+
"references": {}
|
|
262
|
+
},
|
|
263
|
+
"required": false,
|
|
264
|
+
"optional": false,
|
|
265
|
+
"docs": {
|
|
266
|
+
"tags": [],
|
|
267
|
+
"text": "Property used to display the image"
|
|
268
|
+
},
|
|
269
|
+
"attribute": "show-image",
|
|
270
|
+
"reflect": false,
|
|
271
|
+
"defaultValue": "true"
|
|
272
|
+
},
|
|
273
|
+
"showTitle": {
|
|
274
|
+
"type": "boolean",
|
|
275
|
+
"mutable": false,
|
|
276
|
+
"complexType": {
|
|
277
|
+
"original": "boolean",
|
|
278
|
+
"resolved": "boolean",
|
|
279
|
+
"references": {}
|
|
280
|
+
},
|
|
281
|
+
"required": false,
|
|
282
|
+
"optional": false,
|
|
283
|
+
"docs": {
|
|
284
|
+
"tags": [],
|
|
285
|
+
"text": "Property used to display the image"
|
|
286
|
+
},
|
|
287
|
+
"attribute": "show-title",
|
|
288
|
+
"reflect": false,
|
|
289
|
+
"defaultValue": "true"
|
|
290
|
+
},
|
|
291
|
+
"showContent": {
|
|
292
|
+
"type": "boolean",
|
|
293
|
+
"mutable": false,
|
|
294
|
+
"complexType": {
|
|
295
|
+
"original": "boolean",
|
|
296
|
+
"resolved": "boolean",
|
|
297
|
+
"references": {}
|
|
298
|
+
},
|
|
299
|
+
"required": false,
|
|
300
|
+
"optional": false,
|
|
301
|
+
"docs": {
|
|
302
|
+
"tags": [],
|
|
303
|
+
"text": "Property used to display the description"
|
|
304
|
+
},
|
|
305
|
+
"attribute": "show-content",
|
|
306
|
+
"reflect": false,
|
|
307
|
+
"defaultValue": "true"
|
|
308
|
+
},
|
|
309
|
+
"postMessageEvent": {
|
|
310
|
+
"type": "string",
|
|
311
|
+
"mutable": false,
|
|
312
|
+
"complexType": {
|
|
313
|
+
"original": "string",
|
|
314
|
+
"resolved": "string",
|
|
315
|
+
"references": {}
|
|
316
|
+
},
|
|
317
|
+
"required": false,
|
|
318
|
+
"optional": false,
|
|
319
|
+
"docs": {
|
|
320
|
+
"tags": [],
|
|
321
|
+
"text": "Event name to be sent when the button is clicked"
|
|
322
|
+
},
|
|
323
|
+
"attribute": "post-message-event",
|
|
324
|
+
"reflect": false,
|
|
325
|
+
"defaultValue": "'articleActionButton'"
|
|
326
|
+
},
|
|
327
|
+
"postId": {
|
|
328
|
+
"type": "number",
|
|
329
|
+
"mutable": false,
|
|
330
|
+
"complexType": {
|
|
331
|
+
"original": "number",
|
|
332
|
+
"resolved": "number",
|
|
333
|
+
"references": {}
|
|
334
|
+
},
|
|
335
|
+
"required": true,
|
|
336
|
+
"optional": false,
|
|
337
|
+
"docs": {
|
|
338
|
+
"tags": [],
|
|
339
|
+
"text": "Showing post ID parameter"
|
|
340
|
+
},
|
|
341
|
+
"attribute": "post-id",
|
|
342
|
+
"reflect": false
|
|
343
|
+
}
|
|
344
|
+
}; }
|
|
345
|
+
static get states() { return {
|
|
346
|
+
"hasErrors": {},
|
|
347
|
+
"limitStylingAppends": {},
|
|
348
|
+
"isLoading": {}
|
|
349
|
+
}; }
|
|
350
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar'];
|
|
3
|
+
const TRANSLATIONS = {
|
|
4
|
+
en: {
|
|
5
|
+
error: 'Error',
|
|
6
|
+
},
|
|
7
|
+
ro: {
|
|
8
|
+
error: 'Eroare',
|
|
9
|
+
},
|
|
10
|
+
fr: {
|
|
11
|
+
error: 'Error',
|
|
12
|
+
},
|
|
13
|
+
ar: {
|
|
14
|
+
error: 'خطأ',
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const translate = (key, customLang) => {
|
|
18
|
+
const lang = customLang;
|
|
19
|
+
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
20
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface BlogArticleDetails extends Components.BlogArticleDetails, HTMLElement {}
|
|
4
|
+
export const BlogArticleDetails: {
|
|
5
|
+
prototype: BlogArticleDetails;
|
|
6
|
+
new (): BlogArticleDetails;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
4
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar'];
|
|
5
|
+
const TRANSLATIONS = {
|
|
6
|
+
en: {
|
|
7
|
+
error: 'Error',
|
|
8
|
+
},
|
|
9
|
+
ro: {
|
|
10
|
+
error: 'Eroare',
|
|
11
|
+
},
|
|
12
|
+
fr: {
|
|
13
|
+
error: 'Error',
|
|
14
|
+
},
|
|
15
|
+
ar: {
|
|
16
|
+
error: 'خطأ',
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const translate = (key, customLang) => {
|
|
20
|
+
const lang = customLang;
|
|
21
|
+
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const blogArticleDetailsCss = ":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";
|
|
25
|
+
|
|
26
|
+
const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
this.__registerHost();
|
|
30
|
+
this.__attachShadow();
|
|
31
|
+
/**
|
|
32
|
+
* Language of the widget
|
|
33
|
+
*/
|
|
34
|
+
this.language = 'en';
|
|
35
|
+
/**
|
|
36
|
+
* Client custom styling via string
|
|
37
|
+
*/
|
|
38
|
+
this.clientStyling = '';
|
|
39
|
+
/**
|
|
40
|
+
* Client custom styling via url
|
|
41
|
+
*/
|
|
42
|
+
this.clientStylingurl = '';
|
|
43
|
+
/**
|
|
44
|
+
* Client custom styling via url content
|
|
45
|
+
*/
|
|
46
|
+
this.clientStylingUrlContent = '';
|
|
47
|
+
/**
|
|
48
|
+
* Property used to display the publishing date
|
|
49
|
+
*/
|
|
50
|
+
this.showPublishingDate = true;
|
|
51
|
+
/**
|
|
52
|
+
* Property used to display the image
|
|
53
|
+
*/
|
|
54
|
+
this.showImage = true;
|
|
55
|
+
/**
|
|
56
|
+
* Property used to display the image
|
|
57
|
+
*/
|
|
58
|
+
this.showTitle = true;
|
|
59
|
+
/**
|
|
60
|
+
* Property used to display the description
|
|
61
|
+
*/
|
|
62
|
+
this.showContent = true;
|
|
63
|
+
/**
|
|
64
|
+
* Event name to be sent when the button is clicked
|
|
65
|
+
*/
|
|
66
|
+
this.postMessageEvent = 'articleActionButton';
|
|
67
|
+
this.hasErrors = false;
|
|
68
|
+
this.limitStylingAppends = false;
|
|
69
|
+
this.isLoading = true;
|
|
70
|
+
this.setClientStyling = () => {
|
|
71
|
+
let sheet = document.createElement('style');
|
|
72
|
+
sheet.innerHTML = this.clientStyling;
|
|
73
|
+
this.stylingContainer.prepend(sheet);
|
|
74
|
+
};
|
|
75
|
+
this.setClientStylingURL = () => {
|
|
76
|
+
let url = new URL(this.clientStylingurl);
|
|
77
|
+
let cssFile = document.createElement('style');
|
|
78
|
+
fetch(url.href)
|
|
79
|
+
.then((res) => res.text())
|
|
80
|
+
.then((data) => {
|
|
81
|
+
this.clientStylingUrlContent = data;
|
|
82
|
+
cssFile.innerHTML = data;
|
|
83
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
84
|
+
})
|
|
85
|
+
.catch((err) => {
|
|
86
|
+
console.log('error ', err);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
getBlogArticleDetails() {
|
|
91
|
+
if (!this.postId && isNaN(this.postId)) {
|
|
92
|
+
this.hasErrors = true;
|
|
93
|
+
throw new Error('The postId parameter is missing!');
|
|
94
|
+
}
|
|
95
|
+
this.isLoading = true;
|
|
96
|
+
let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postId}`);
|
|
97
|
+
fetch(url.href)
|
|
98
|
+
.then((res) => {
|
|
99
|
+
if (res.status >= 300) {
|
|
100
|
+
this.hasErrors = true;
|
|
101
|
+
throw new Error('There was an error while fetching the data');
|
|
102
|
+
}
|
|
103
|
+
return res.json();
|
|
104
|
+
})
|
|
105
|
+
.then((blogContent) => {
|
|
106
|
+
this.blogData = blogContent;
|
|
107
|
+
this.isLoading = false;
|
|
108
|
+
})
|
|
109
|
+
.catch((err) => {
|
|
110
|
+
this.hasErrors = true;
|
|
111
|
+
console.log('Error', err);
|
|
112
|
+
})
|
|
113
|
+
.finally(() => this.isLoading = false);
|
|
114
|
+
}
|
|
115
|
+
componentDidRender() {
|
|
116
|
+
// start custom styling area
|
|
117
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
118
|
+
if (this.clientStyling)
|
|
119
|
+
this.setClientStyling();
|
|
120
|
+
if (this.clientStylingUrlContent)
|
|
121
|
+
this.setClientStylingURL();
|
|
122
|
+
this.limitStylingAppends = true;
|
|
123
|
+
}
|
|
124
|
+
// end custom styling area
|
|
125
|
+
}
|
|
126
|
+
componentWillLoad() {
|
|
127
|
+
this.getBlogArticleDetails();
|
|
128
|
+
}
|
|
129
|
+
render() {
|
|
130
|
+
if (this.hasErrors) {
|
|
131
|
+
return (h("div", { class: "BlogArticleDetails" }, h("div", { class: "Title" }, translate('error', this.language))));
|
|
132
|
+
}
|
|
133
|
+
if (!this.isLoading) {
|
|
134
|
+
return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "GridContainer" }, this.showPublishingDate &&
|
|
135
|
+
h("div", { class: "BlogDate" }, this.blogData.publishingDate), this.showImage &&
|
|
136
|
+
h("div", { class: "BlogBanner" }, h("img", { src: this.blogData, alt: this.blogData.title })), this.showTitle &&
|
|
137
|
+
h("div", { class: "BlogTitle" }, this.blogData.title), this.showContent &&
|
|
138
|
+
h("div", { class: "BlogContent", innerHTML: this.blogData.content }))));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
static get style() { return blogArticleDetailsCss; }
|
|
142
|
+
}, [1, "blog-article-details", {
|
|
143
|
+
"cmsEndpoint": [1, "cms-endpoint"],
|
|
144
|
+
"language": [1],
|
|
145
|
+
"handleClick": [1, "handle-click"],
|
|
146
|
+
"clientStyling": [1, "client-styling"],
|
|
147
|
+
"clientStylingurl": [1, "client-stylingurl"],
|
|
148
|
+
"clientStylingUrlContent": [1, "client-styling-url-content"],
|
|
149
|
+
"showPublishingDate": [4, "show-publishing-date"],
|
|
150
|
+
"showImage": [4, "show-image"],
|
|
151
|
+
"showTitle": [4, "show-title"],
|
|
152
|
+
"showContent": [4, "show-content"],
|
|
153
|
+
"postMessageEvent": [1, "post-message-event"],
|
|
154
|
+
"postId": [2, "post-id"],
|
|
155
|
+
"hasErrors": [32],
|
|
156
|
+
"limitStylingAppends": [32],
|
|
157
|
+
"isLoading": [32]
|
|
158
|
+
}]);
|
|
159
|
+
function defineCustomElement$1() {
|
|
160
|
+
if (typeof customElements === "undefined") {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const components = ["blog-article-details"];
|
|
164
|
+
components.forEach(tagName => { switch (tagName) {
|
|
165
|
+
case "blog-article-details":
|
|
166
|
+
if (!customElements.get(tagName)) {
|
|
167
|
+
customElements.define(tagName, BlogArticleDetails$1);
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
} });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const BlogArticleDetails = BlogArticleDetails$1;
|
|
174
|
+
const defineCustomElement = defineCustomElement$1;
|
|
175
|
+
|
|
176
|
+
export { BlogArticleDetails, defineCustomElement };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* BlogArticleDetails custom elements */
|
|
2
|
+
|
|
3
|
+
import type { Components, JSX } from "../types/components";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Used to manually set the base path where assets can be found.
|
|
7
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
8
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
9
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
10
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
11
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
12
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
13
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
14
|
+
*/
|
|
15
|
+
export declare const setAssetPath: (path: string) => void;
|
|
16
|
+
|
|
17
|
+
export interface SetPlatformOptions {
|
|
18
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
19
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
20
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
23
|
+
|
|
24
|
+
export type { Components, JSX };
|
|
25
|
+
|
|
26
|
+
export * from '../types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
|