@everymatrix/blog-articles-grid 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-articles-grid/blog-articles-grid.esm.js +1 -0
- package/dist/blog-articles-grid/index.esm.js +0 -0
- package/dist/blog-articles-grid/p-73f0e79a.entry.js +1 -0
- package/dist/blog-articles-grid/p-f6930cad.js +1 -0
- package/dist/cjs/blog-articles-grid.cjs.entry.js +168 -0
- package/dist/cjs/blog-articles-grid.cjs.js +19 -0
- package/dist/cjs/index-2ef46f05.js +1177 -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-articles-grid/blog-articles-grid.css +126 -0
- package/dist/collection/components/blog-articles-grid/blog-articles-grid.js +425 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +24 -0
- package/dist/collection/utils/utils.js +0 -0
- package/dist/components/blog-articles-grid.d.ts +11 -0
- package/dist/components/blog-articles-grid.js +200 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/esm/blog-articles-grid.entry.js +164 -0
- package/dist/esm/blog-articles-grid.js +17 -0
- package/dist/esm/index-3cf2add0.js +1151 -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-articles-grid/.stencil/packages/blog-articles-grid/stencil.config.d.ts +2 -0
- package/dist/types/components/blog-articles-grid/blog-articles-grid.d.ts +74 -0
- package/dist/types/components.d.ts +150 -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,200 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, 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
|
+
readmore: 'Read more',
|
|
9
|
+
},
|
|
10
|
+
ro: {
|
|
11
|
+
error: 'Eroare',
|
|
12
|
+
readmore: 'Read more',
|
|
13
|
+
},
|
|
14
|
+
fr: {
|
|
15
|
+
error: 'Error',
|
|
16
|
+
readmore: 'Read more',
|
|
17
|
+
},
|
|
18
|
+
ar: {
|
|
19
|
+
error: 'خطأ',
|
|
20
|
+
readmore: 'Read more',
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const translate = (key, customLang) => {
|
|
24
|
+
const lang = customLang;
|
|
25
|
+
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const blogArticlesGridCss = ":host {\n display: block;\n}\n\n.GridContainer {\n margin: auto;\n width: 100%;\n height: 280px;\n border-radius: 15px;\n background-color: #07072A;\n margin-bottom: 20px;\n display: grid;\n gap: 30px;\n grid-template-rows: 1fr 4fr 1fr 1fr;\n grid-template-columns: 30px 1fr 1fr 30px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/3;\n grid-row: 1/5;\n}\n.GridContainer .BlogBanner img {\n border-radius: 5px 0 0 5px;\n width: 100%;\n height: 280px;\n}\n.GridContainer .BlogDate {\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFFFFF;\n background-color: #0D0D4D;\n grid-column: 2/2;\n grid-row: 4/4;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n font-size: 24px;\n color: #FFF;\n margin-top: 20px;\n grid-column: 3/5;\n}\n.GridContainer .BlogContent {\n font-size: 14px;\n color: #FFF;\n width: 90%;\n max-height: 80px;\n overflow: hidden;\n text-overflow: ellipsis;\n grid-column: 3/5;\n}\n.GridContainer .BlogLink {\n grid-column: 3/5;\n color: #FFF;\n}\n.GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n padding: 0;\n background: none;\n color: #D0046C;\n cursor: pointer;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n margin: auto;\n width: 100%;\n min-height: 400px;\n gap: 10%;\n padding-bottom: 30px;\n border-radius: 5px;\n background-color: #07072A;\n margin-bottom: 20px;\n display: grid;\n grid-template-rows: repeat(auto-fit, minmax(50px, 1fr));\n grid-template-rows: auto auto auto 50px;\n grid-template-columns: 15px auto auto 15px;\n gap: 10px;\n }\n .GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n margin: 0;\n }\n .GridContainer .BlogBanner img {\n width: 100%;\n height: 232px;\n border-radius: 5px 5px 0 0;\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: #FFFFFF;\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 .GridContainer .BlogLink {\n grid-column: 2/4;\n color: #FFF;\n cursor: pointer;\n }\n .GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n background: none;\n color: #D0046C;\n cursor: pointer;\n }\n}";
|
|
29
|
+
|
|
30
|
+
const BlogArticlesGrid$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
this.__registerHost();
|
|
34
|
+
this.__attachShadow();
|
|
35
|
+
this.articleActionButton = createEvent(this, "articleActionButton", 7);
|
|
36
|
+
/**
|
|
37
|
+
* Language of the widget
|
|
38
|
+
*/
|
|
39
|
+
this.language = 'en';
|
|
40
|
+
/**
|
|
41
|
+
* Client custom styling via string
|
|
42
|
+
*/
|
|
43
|
+
this.clientStyling = '';
|
|
44
|
+
/**
|
|
45
|
+
* Client custom styling via url
|
|
46
|
+
*/
|
|
47
|
+
this.clientStylingurl = '';
|
|
48
|
+
/**
|
|
49
|
+
* Client custom styling via url content
|
|
50
|
+
*/
|
|
51
|
+
this.clientStylingUrlContent = '';
|
|
52
|
+
/**
|
|
53
|
+
* Property used to display the publishing date
|
|
54
|
+
*/
|
|
55
|
+
this.showPublishingDate = true;
|
|
56
|
+
/**
|
|
57
|
+
* Property used to display the image
|
|
58
|
+
*/
|
|
59
|
+
this.showImage = true;
|
|
60
|
+
/**
|
|
61
|
+
* Property used to display the image
|
|
62
|
+
*/
|
|
63
|
+
this.showTitle = true;
|
|
64
|
+
/**
|
|
65
|
+
* Property used to display the description
|
|
66
|
+
*/
|
|
67
|
+
this.showContent = true;
|
|
68
|
+
/**
|
|
69
|
+
* Property used to display the button
|
|
70
|
+
*/
|
|
71
|
+
this.showButton = true;
|
|
72
|
+
/**
|
|
73
|
+
* Property used to display the button
|
|
74
|
+
*/
|
|
75
|
+
this.showVerticalGrid = false;
|
|
76
|
+
/**
|
|
77
|
+
* Event name to be sent when the button is clicked
|
|
78
|
+
*/
|
|
79
|
+
this.postMessageEvent = 'articleActionButton';
|
|
80
|
+
this.hasErrors = false;
|
|
81
|
+
this.limitStylingAppends = false;
|
|
82
|
+
this.isLoading = true;
|
|
83
|
+
this.setClientStyling = () => {
|
|
84
|
+
let sheet = document.createElement('style');
|
|
85
|
+
sheet.innerHTML = this.clientStyling;
|
|
86
|
+
this.stylingContainer.prepend(sheet);
|
|
87
|
+
};
|
|
88
|
+
this.setClientStylingURL = () => {
|
|
89
|
+
let url = new URL(this.clientStylingurl);
|
|
90
|
+
let cssFile = document.createElement('style');
|
|
91
|
+
fetch(url.href)
|
|
92
|
+
.then((res) => res.text())
|
|
93
|
+
.then((data) => {
|
|
94
|
+
this.clientStylingUrlContent = data;
|
|
95
|
+
cssFile.innerHTML = data;
|
|
96
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
97
|
+
})
|
|
98
|
+
.catch((err) => {
|
|
99
|
+
console.log('error ', err);
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
getArticleId(postId) {
|
|
104
|
+
this.articleActionButton.emit({ postId });
|
|
105
|
+
if (this.usePostmessage) {
|
|
106
|
+
window.postMessage({ type: this.postMessageEvent, postId });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
connectedCallback() {
|
|
110
|
+
this.getBlogArticleDetails();
|
|
111
|
+
}
|
|
112
|
+
toggleClass() {
|
|
113
|
+
this.showVerticalGrid = !this.showVerticalGrid;
|
|
114
|
+
}
|
|
115
|
+
handleAction(postId) {
|
|
116
|
+
this.getArticleId(postId);
|
|
117
|
+
}
|
|
118
|
+
getBlogArticleDetails() {
|
|
119
|
+
this.isLoading = true;
|
|
120
|
+
let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);
|
|
121
|
+
fetch(url.href)
|
|
122
|
+
.then((res) => {
|
|
123
|
+
if (res.status >= 300) {
|
|
124
|
+
this.hasErrors = true;
|
|
125
|
+
throw new Error('There was an error while fetching the data');
|
|
126
|
+
}
|
|
127
|
+
return res.json();
|
|
128
|
+
})
|
|
129
|
+
.then((blogContent) => {
|
|
130
|
+
this.blogData = blogContent;
|
|
131
|
+
this.isLoading = false;
|
|
132
|
+
})
|
|
133
|
+
.catch((err) => {
|
|
134
|
+
this.hasErrors = true;
|
|
135
|
+
console.log('Error', err);
|
|
136
|
+
})
|
|
137
|
+
.finally(() => this.isLoading = false);
|
|
138
|
+
}
|
|
139
|
+
componentDidRender() {
|
|
140
|
+
// start custom styling area
|
|
141
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
142
|
+
if (this.clientStyling)
|
|
143
|
+
this.setClientStyling();
|
|
144
|
+
if (this.clientStylingUrlContent)
|
|
145
|
+
this.setClientStylingURL();
|
|
146
|
+
this.limitStylingAppends = true;
|
|
147
|
+
}
|
|
148
|
+
// end custom styling area
|
|
149
|
+
}
|
|
150
|
+
render() {
|
|
151
|
+
if (this.hasErrors) {
|
|
152
|
+
return (h("div", { class: "BlogArticleDetails" }, h("div", { class: "Title" }, translate('error', this.language))));
|
|
153
|
+
}
|
|
154
|
+
if (!this.isLoading) {
|
|
155
|
+
return (h("div", null, h("div", { ref: el => this.stylingContainer = el }, this.blogData.map((data) => h("div", { class: "GridContainer" }, this.showPublishingDate &&
|
|
156
|
+
h("div", { class: "BlogDate" }, data.publishingDate), this.showImage &&
|
|
157
|
+
h("div", { class: "BlogBanner" }, h("img", { src: data.image, alt: data.title })), this.showTitle &&
|
|
158
|
+
h("div", { class: "BlogTitle" }, data.title), this.showContent &&
|
|
159
|
+
h("div", { class: "BlogContent", innerHTML: data.content }), this.showButton &&
|
|
160
|
+
h("div", { class: "BlogLink" }, h("button", { onClick: () => this.handleAction(data.postID) }, translate('readmore', this.language))))))));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
static get style() { return blogArticlesGridCss; }
|
|
164
|
+
}, [1, "blog-articles-grid", {
|
|
165
|
+
"cmsEndpoint": [1, "cms-endpoint"],
|
|
166
|
+
"language": [1],
|
|
167
|
+
"handleClick": [1, "handle-click"],
|
|
168
|
+
"clientStyling": [1, "client-styling"],
|
|
169
|
+
"clientStylingurl": [1, "client-stylingurl"],
|
|
170
|
+
"clientStylingUrlContent": [1, "client-styling-url-content"],
|
|
171
|
+
"showPublishingDate": [4, "show-publishing-date"],
|
|
172
|
+
"showImage": [4, "show-image"],
|
|
173
|
+
"showTitle": [4, "show-title"],
|
|
174
|
+
"showContent": [4, "show-content"],
|
|
175
|
+
"showButton": [4, "show-button"],
|
|
176
|
+
"showVerticalGrid": [4, "show-vertical-grid"],
|
|
177
|
+
"usePostmessage": [4, "use-postmessage"],
|
|
178
|
+
"postMessageEvent": [1, "post-message-event"],
|
|
179
|
+
"hasErrors": [32],
|
|
180
|
+
"limitStylingAppends": [32],
|
|
181
|
+
"isLoading": [32]
|
|
182
|
+
}]);
|
|
183
|
+
function defineCustomElement$1() {
|
|
184
|
+
if (typeof customElements === "undefined") {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const components = ["blog-articles-grid"];
|
|
188
|
+
components.forEach(tagName => { switch (tagName) {
|
|
189
|
+
case "blog-articles-grid":
|
|
190
|
+
if (!customElements.get(tagName)) {
|
|
191
|
+
customElements.define(tagName, BlogArticlesGrid$1);
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
} });
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const BlogArticlesGrid = BlogArticlesGrid$1;
|
|
198
|
+
const defineCustomElement = defineCustomElement$1;
|
|
199
|
+
|
|
200
|
+
export { BlogArticlesGrid, defineCustomElement };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* BlogArticlesGrid 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';
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './index-3cf2add0.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
4
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar'];
|
|
5
|
+
const TRANSLATIONS = {
|
|
6
|
+
en: {
|
|
7
|
+
error: 'Error',
|
|
8
|
+
readmore: 'Read more',
|
|
9
|
+
},
|
|
10
|
+
ro: {
|
|
11
|
+
error: 'Eroare',
|
|
12
|
+
readmore: 'Read more',
|
|
13
|
+
},
|
|
14
|
+
fr: {
|
|
15
|
+
error: 'Error',
|
|
16
|
+
readmore: 'Read more',
|
|
17
|
+
},
|
|
18
|
+
ar: {
|
|
19
|
+
error: 'خطأ',
|
|
20
|
+
readmore: 'Read more',
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const translate = (key, customLang) => {
|
|
24
|
+
const lang = customLang;
|
|
25
|
+
return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const blogArticlesGridCss = ":host {\n display: block;\n}\n\n.GridContainer {\n margin: auto;\n width: 100%;\n height: 280px;\n border-radius: 15px;\n background-color: #07072A;\n margin-bottom: 20px;\n display: grid;\n gap: 30px;\n grid-template-rows: 1fr 4fr 1fr 1fr;\n grid-template-columns: 30px 1fr 1fr 30px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/3;\n grid-row: 1/5;\n}\n.GridContainer .BlogBanner img {\n border-radius: 5px 0 0 5px;\n width: 100%;\n height: 280px;\n}\n.GridContainer .BlogDate {\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFFFFF;\n background-color: #0D0D4D;\n grid-column: 2/2;\n grid-row: 4/4;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n font-size: 24px;\n color: #FFF;\n margin-top: 20px;\n grid-column: 3/5;\n}\n.GridContainer .BlogContent {\n font-size: 14px;\n color: #FFF;\n width: 90%;\n max-height: 80px;\n overflow: hidden;\n text-overflow: ellipsis;\n grid-column: 3/5;\n}\n.GridContainer .BlogLink {\n grid-column: 3/5;\n color: #FFF;\n}\n.GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n padding: 0;\n background: none;\n color: #D0046C;\n cursor: pointer;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n margin: auto;\n width: 100%;\n min-height: 400px;\n gap: 10%;\n padding-bottom: 30px;\n border-radius: 5px;\n background-color: #07072A;\n margin-bottom: 20px;\n display: grid;\n grid-template-rows: repeat(auto-fit, minmax(50px, 1fr));\n grid-template-rows: auto auto auto 50px;\n grid-template-columns: 15px auto auto 15px;\n gap: 10px;\n }\n .GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n margin: 0;\n }\n .GridContainer .BlogBanner img {\n width: 100%;\n height: 232px;\n border-radius: 5px 5px 0 0;\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: #FFFFFF;\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 .GridContainer .BlogLink {\n grid-column: 2/4;\n color: #FFF;\n cursor: pointer;\n }\n .GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n background: none;\n color: #D0046C;\n cursor: pointer;\n }\n}";
|
|
29
|
+
|
|
30
|
+
const BlogArticlesGrid = class {
|
|
31
|
+
constructor(hostRef) {
|
|
32
|
+
registerInstance(this, hostRef);
|
|
33
|
+
this.articleActionButton = createEvent(this, "articleActionButton", 7);
|
|
34
|
+
/**
|
|
35
|
+
* Language of the widget
|
|
36
|
+
*/
|
|
37
|
+
this.language = 'en';
|
|
38
|
+
/**
|
|
39
|
+
* Client custom styling via string
|
|
40
|
+
*/
|
|
41
|
+
this.clientStyling = '';
|
|
42
|
+
/**
|
|
43
|
+
* Client custom styling via url
|
|
44
|
+
*/
|
|
45
|
+
this.clientStylingurl = '';
|
|
46
|
+
/**
|
|
47
|
+
* Client custom styling via url content
|
|
48
|
+
*/
|
|
49
|
+
this.clientStylingUrlContent = '';
|
|
50
|
+
/**
|
|
51
|
+
* Property used to display the publishing date
|
|
52
|
+
*/
|
|
53
|
+
this.showPublishingDate = true;
|
|
54
|
+
/**
|
|
55
|
+
* Property used to display the image
|
|
56
|
+
*/
|
|
57
|
+
this.showImage = true;
|
|
58
|
+
/**
|
|
59
|
+
* Property used to display the image
|
|
60
|
+
*/
|
|
61
|
+
this.showTitle = true;
|
|
62
|
+
/**
|
|
63
|
+
* Property used to display the description
|
|
64
|
+
*/
|
|
65
|
+
this.showContent = true;
|
|
66
|
+
/**
|
|
67
|
+
* Property used to display the button
|
|
68
|
+
*/
|
|
69
|
+
this.showButton = true;
|
|
70
|
+
/**
|
|
71
|
+
* Property used to display the button
|
|
72
|
+
*/
|
|
73
|
+
this.showVerticalGrid = false;
|
|
74
|
+
/**
|
|
75
|
+
* Event name to be sent when the button is clicked
|
|
76
|
+
*/
|
|
77
|
+
this.postMessageEvent = 'articleActionButton';
|
|
78
|
+
this.hasErrors = false;
|
|
79
|
+
this.limitStylingAppends = false;
|
|
80
|
+
this.isLoading = true;
|
|
81
|
+
this.setClientStyling = () => {
|
|
82
|
+
let sheet = document.createElement('style');
|
|
83
|
+
sheet.innerHTML = this.clientStyling;
|
|
84
|
+
this.stylingContainer.prepend(sheet);
|
|
85
|
+
};
|
|
86
|
+
this.setClientStylingURL = () => {
|
|
87
|
+
let url = new URL(this.clientStylingurl);
|
|
88
|
+
let cssFile = document.createElement('style');
|
|
89
|
+
fetch(url.href)
|
|
90
|
+
.then((res) => res.text())
|
|
91
|
+
.then((data) => {
|
|
92
|
+
this.clientStylingUrlContent = data;
|
|
93
|
+
cssFile.innerHTML = data;
|
|
94
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
95
|
+
})
|
|
96
|
+
.catch((err) => {
|
|
97
|
+
console.log('error ', err);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
getArticleId(postId) {
|
|
102
|
+
this.articleActionButton.emit({ postId });
|
|
103
|
+
if (this.usePostmessage) {
|
|
104
|
+
window.postMessage({ type: this.postMessageEvent, postId });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
connectedCallback() {
|
|
108
|
+
this.getBlogArticleDetails();
|
|
109
|
+
}
|
|
110
|
+
toggleClass() {
|
|
111
|
+
this.showVerticalGrid = !this.showVerticalGrid;
|
|
112
|
+
}
|
|
113
|
+
handleAction(postId) {
|
|
114
|
+
this.getArticleId(postId);
|
|
115
|
+
}
|
|
116
|
+
getBlogArticleDetails() {
|
|
117
|
+
this.isLoading = true;
|
|
118
|
+
let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);
|
|
119
|
+
fetch(url.href)
|
|
120
|
+
.then((res) => {
|
|
121
|
+
if (res.status >= 300) {
|
|
122
|
+
this.hasErrors = true;
|
|
123
|
+
throw new Error('There was an error while fetching the data');
|
|
124
|
+
}
|
|
125
|
+
return res.json();
|
|
126
|
+
})
|
|
127
|
+
.then((blogContent) => {
|
|
128
|
+
this.blogData = blogContent;
|
|
129
|
+
this.isLoading = false;
|
|
130
|
+
})
|
|
131
|
+
.catch((err) => {
|
|
132
|
+
this.hasErrors = true;
|
|
133
|
+
console.log('Error', err);
|
|
134
|
+
})
|
|
135
|
+
.finally(() => this.isLoading = false);
|
|
136
|
+
}
|
|
137
|
+
componentDidRender() {
|
|
138
|
+
// start custom styling area
|
|
139
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
140
|
+
if (this.clientStyling)
|
|
141
|
+
this.setClientStyling();
|
|
142
|
+
if (this.clientStylingUrlContent)
|
|
143
|
+
this.setClientStylingURL();
|
|
144
|
+
this.limitStylingAppends = true;
|
|
145
|
+
}
|
|
146
|
+
// end custom styling area
|
|
147
|
+
}
|
|
148
|
+
render() {
|
|
149
|
+
if (this.hasErrors) {
|
|
150
|
+
return (h("div", { class: "BlogArticleDetails" }, h("div", { class: "Title" }, translate('error', this.language))));
|
|
151
|
+
}
|
|
152
|
+
if (!this.isLoading) {
|
|
153
|
+
return (h("div", null, h("div", { ref: el => this.stylingContainer = el }, this.blogData.map((data) => h("div", { class: "GridContainer" }, this.showPublishingDate &&
|
|
154
|
+
h("div", { class: "BlogDate" }, data.publishingDate), this.showImage &&
|
|
155
|
+
h("div", { class: "BlogBanner" }, h("img", { src: data.image, alt: data.title })), this.showTitle &&
|
|
156
|
+
h("div", { class: "BlogTitle" }, data.title), this.showContent &&
|
|
157
|
+
h("div", { class: "BlogContent", innerHTML: data.content }), this.showButton &&
|
|
158
|
+
h("div", { class: "BlogLink" }, h("button", { onClick: () => this.handleAction(data.postID) }, translate('readmore', this.language))))))));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
BlogArticlesGrid.style = blogArticlesGridCss;
|
|
163
|
+
|
|
164
|
+
export { BlogArticlesGrid as blog_articles_grid };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { p as promiseResolve, b as bootstrapLazy } from './index-3cf2add0.js';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
5
|
+
*/
|
|
6
|
+
const patchBrowser = () => {
|
|
7
|
+
const importMeta = import.meta.url;
|
|
8
|
+
const opts = {};
|
|
9
|
+
if (importMeta !== '') {
|
|
10
|
+
opts.resourcesUrl = new URL('.', importMeta).href;
|
|
11
|
+
}
|
|
12
|
+
return promiseResolve(opts);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
patchBrowser().then(options => {
|
|
16
|
+
return bootstrapLazy([["blog-articles-grid",[[1,"blog-articles-grid",{"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"],"showButton":[4,"show-button"],"showVerticalGrid":[4,"show-vertical-grid"],"usePostmessage":[4,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32]}]]]], options);
|
|
17
|
+
});
|