@everymatrix/general-stories 0.0.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/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/general-stories-34fcd4f4.js +290 -0
- package/dist/cjs/general-stories.cjs.entry.js +10 -0
- package/dist/cjs/general-stories.cjs.js +25 -0
- package/dist/cjs/index-839683a3.js +1317 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/general-stories/general-stories.css +124 -0
- package/dist/collection/components/general-stories/general-stories.js +379 -0
- package/dist/collection/components/general-stories/general-stories.types.js +1 -0
- package/dist/collection/components/general-stories/index.js +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +54 -0
- package/dist/collection/utils/utils.js +30 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/general-stories-0e155a93.js +288 -0
- package/dist/esm/general-stories.entry.js +2 -0
- package/dist/esm/general-stories.js +20 -0
- package/dist/esm/index-1b3a1a31.js +1291 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/general-stories/general-stories.esm.js +1 -0
- package/dist/general-stories/index.esm.js +1 -0
- package/dist/general-stories/p-30c1a94b.js +2 -0
- package/dist/general-stories/p-5d17c3bf.js +1 -0
- package/dist/general-stories/p-9adad3b4.entry.js +1 -0
- package/dist/general-stories/p-e1255160.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.dev.js +17 -0
- package/dist/stencil.config.js +17 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-stories/.stencil/packages/stencil/general-stories/stencil.config.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-stories/.stencil/packages/stencil/general-stories/stencil.config.dev.d.ts +2 -0
- package/dist/types/components/general-stories/general-stories.d.ts +68 -0
- package/dist/types/components/general-stories/general-stories.types.d.ts +11 -0
- package/dist/types/components/general-stories/index.d.ts +1 -0
- package/dist/types/components.d.ts +93 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/locale.utils.d.ts +2 -0
- package/dist/types/utils/utils.d.ts +3 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +26 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-839683a3.js');
|
|
6
|
+
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
|
+
|
|
8
|
+
const defineCustomElements = async (win, options) => {
|
|
9
|
+
if (typeof window === 'undefined') return undefined;
|
|
10
|
+
await appGlobals.globalScripts();
|
|
11
|
+
return index.bootstrapLazy([["general-stories.cjs",[[1,"general-stories",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"cmsEnv":[513,"cms-env"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"progressBarDuration":[514,"progress-bar-duration"],"currentStory":[32],"currentStoryId":[32],"progress":[32],"touchPosStart":[32],"touchPosEnd":[32]},[[1,"touchstart","onTouchStart"],[1,"touchmove","onTouchMove"],[1,"touchend","onTouchEnd"]],{"clientStyling":["handleStylingUpdate"],"clientStylingUrl":["handleStylingUpdate"],"translationUrl":["handleNewTranslations"],"progress":["handleTimeEnds"]}]]]], options);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.setNonce = index.setNonce;
|
|
15
|
+
exports.defineCustomElements = defineCustomElements;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
.ImageContainer {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
background-color: var(--emw--color-background, #0E1511);
|
|
5
|
+
overflow: auto;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.StoryThumbnailContainer {
|
|
9
|
+
margin: 5px;
|
|
10
|
+
position: relative;
|
|
11
|
+
display: inline-block;
|
|
12
|
+
border-radius: 50%;
|
|
13
|
+
}
|
|
14
|
+
.StoryThumbnailContainer.Highlighted::before {
|
|
15
|
+
content: "";
|
|
16
|
+
position: absolute;
|
|
17
|
+
border-radius: 50%;
|
|
18
|
+
background: linear-gradient(to bottom, var(--emw--color-primary, #22B04E), var(--emw--color-secondary, #E1A749));
|
|
19
|
+
top: -3px;
|
|
20
|
+
left: -3px;
|
|
21
|
+
width: 111%;
|
|
22
|
+
height: 103%;
|
|
23
|
+
}
|
|
24
|
+
.StoryThumbnailContainer.Viewed::before {
|
|
25
|
+
content: "";
|
|
26
|
+
position: absolute;
|
|
27
|
+
border-radius: 50%;
|
|
28
|
+
height: 50px;
|
|
29
|
+
width: 50px;
|
|
30
|
+
background: var(--emw--color-grey-150, #828282);
|
|
31
|
+
top: -3px;
|
|
32
|
+
left: -3px;
|
|
33
|
+
width: 111%;
|
|
34
|
+
height: 103%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.StoryThumbnailImage {
|
|
38
|
+
height: 50px;
|
|
39
|
+
width: 50px;
|
|
40
|
+
border-radius: 50%;
|
|
41
|
+
position: relative;
|
|
42
|
+
z-index: 1;
|
|
43
|
+
}
|
|
44
|
+
.StoryThumbnailImage.Highlighted, .StoryThumbnailImage.Viewed {
|
|
45
|
+
border: 2px solid var(--emw--color-white, #ffffff);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.FullScreenHeader {
|
|
49
|
+
position: fixed;
|
|
50
|
+
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
|
51
|
+
top: 0px;
|
|
52
|
+
width: 100%;
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
padding: 10px 0;
|
|
56
|
+
z-index: 5;
|
|
57
|
+
height: 30px;
|
|
58
|
+
}
|
|
59
|
+
.FullScreenHeader .CloseStoryButton {
|
|
60
|
+
position: absolute;
|
|
61
|
+
right: 0;
|
|
62
|
+
width: 20px;
|
|
63
|
+
margin-right: 20px;
|
|
64
|
+
margin-top: 8px;
|
|
65
|
+
z-index: 50;
|
|
66
|
+
}
|
|
67
|
+
.FullScreenHeader .ProgressBarContainer {
|
|
68
|
+
width: 90%;
|
|
69
|
+
height: 2px;
|
|
70
|
+
position: relative;
|
|
71
|
+
top: 0;
|
|
72
|
+
background-color: var(--emw--color-grey-150, #828282);
|
|
73
|
+
border-radius: 10px;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
margin: 0 auto;
|
|
76
|
+
}
|
|
77
|
+
.FullScreenHeader .ProgressBarContainer .ProgressBar {
|
|
78
|
+
height: 100%;
|
|
79
|
+
background: var(--emw--color-white, #ffffff);
|
|
80
|
+
width: 0%;
|
|
81
|
+
transition: width 0.1s linear;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.FullScreenStory {
|
|
85
|
+
position: fixed;
|
|
86
|
+
width: 100vw;
|
|
87
|
+
height: 100vh;
|
|
88
|
+
background-color: var(--emw--color-grey-400, #24211f);
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
justify-content: center;
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
z-index: 300;
|
|
94
|
+
}
|
|
95
|
+
.FullScreenStory video {
|
|
96
|
+
height: 100vh;
|
|
97
|
+
width: 100vw;
|
|
98
|
+
}
|
|
99
|
+
.FullScreenStory img {
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 100%;
|
|
102
|
+
object-fit: contain;
|
|
103
|
+
}
|
|
104
|
+
.FullScreenStory .LoadMoreButtonBackground {
|
|
105
|
+
width: 100vw;
|
|
106
|
+
height: 15%;
|
|
107
|
+
background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
|
|
108
|
+
position: absolute;
|
|
109
|
+
bottom: 0;
|
|
110
|
+
display: flex;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
}
|
|
113
|
+
.FullScreenStory .LoadMoreButtonBackground .LoadMoreButton {
|
|
114
|
+
width: auto;
|
|
115
|
+
font-size: var(--emw--font-size-small, 14px);
|
|
116
|
+
font-family: inherit;
|
|
117
|
+
background-color: var(--emw--color-grey-50, #F9F8F8);
|
|
118
|
+
box-shadow: 0px 0px 7px 1px var(--emw--color-grey-400, #24211f);
|
|
119
|
+
color: var(--emw--color-black, #000000);
|
|
120
|
+
border-radius: 50px;
|
|
121
|
+
position: absolute;
|
|
122
|
+
bottom: 15px;
|
|
123
|
+
padding: 10px 20px;
|
|
124
|
+
}
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { getDevicePlatform } from "../../utils/utils";
|
|
3
|
+
import { translate, getTranslations } from "../../utils/locale.utils";
|
|
4
|
+
export class GeneralStories {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.hasErrors = false;
|
|
7
|
+
this.isLoading = true;
|
|
8
|
+
this.isSwipe = false;
|
|
9
|
+
this.getStories = () => {
|
|
10
|
+
let url = new URL(`${this.cmsEndpoint}/${this.language}/stories`);
|
|
11
|
+
url.searchParams.append('env', this.cmsEnv);
|
|
12
|
+
url.searchParams.append('device', getDevicePlatform());
|
|
13
|
+
url.searchParams.append('language', this.language);
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
this.isLoading = true;
|
|
16
|
+
fetch(url.href)
|
|
17
|
+
.then((res) => res.json())
|
|
18
|
+
.then((data) => {
|
|
19
|
+
this.stories = data;
|
|
20
|
+
this.stories.forEach((story) => {
|
|
21
|
+
story.viewed = false;
|
|
22
|
+
});
|
|
23
|
+
this.isLoading = false;
|
|
24
|
+
resolve(true);
|
|
25
|
+
}).catch((err) => {
|
|
26
|
+
console.log(err);
|
|
27
|
+
this.isLoading = false;
|
|
28
|
+
this.hasErrors = true;
|
|
29
|
+
reject(err);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
this.setClientStyling = () => {
|
|
34
|
+
let sheet = document.createElement('style');
|
|
35
|
+
sheet.innerHTML = this.clientStyling;
|
|
36
|
+
this.stylingContainer.prepend(sheet);
|
|
37
|
+
};
|
|
38
|
+
this.setClientStylingURL = () => {
|
|
39
|
+
let url = new URL(this.clientStylingUrl);
|
|
40
|
+
let cssFile = document.createElement('style');
|
|
41
|
+
fetch(url.href)
|
|
42
|
+
.then((res) => res.text())
|
|
43
|
+
.then((data) => {
|
|
44
|
+
cssFile.innerHTML = data;
|
|
45
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
46
|
+
})
|
|
47
|
+
.catch((err) => {
|
|
48
|
+
console.log('error ', err);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
this.navigateToExternalStoryLink = () => {
|
|
52
|
+
window.postMessage({ type: 'OpenStoryLink', url: this.currentStory.storyUrl }, window.location.href);
|
|
53
|
+
};
|
|
54
|
+
this.openFullScreenStory = (id) => {
|
|
55
|
+
this.currentStoryId = id;
|
|
56
|
+
this.currentStory = this.stories.find((story) => story.id === id);
|
|
57
|
+
this.markStoryAsViewed(id);
|
|
58
|
+
this.startProgress();
|
|
59
|
+
};
|
|
60
|
+
this.closeFullScreenView = () => {
|
|
61
|
+
this.markStoryAsViewed(this.currentStoryId.toString());
|
|
62
|
+
this.currentStoryId = null;
|
|
63
|
+
this.progress = 0;
|
|
64
|
+
clearInterval(this.intervalId);
|
|
65
|
+
};
|
|
66
|
+
this.markStoryAsViewed = (storyId) => {
|
|
67
|
+
const storyIndex = this.stories.findIndex(story => story.id === storyId);
|
|
68
|
+
if (storyIndex > -1) {
|
|
69
|
+
const [viewedStory] = this.stories.splice(storyIndex, 1);
|
|
70
|
+
viewedStory.viewed = true;
|
|
71
|
+
this.stories = [...this.stories, viewedStory];
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
this.changeStory = (story, direction) => {
|
|
75
|
+
const newStoryIndex = direction === 'next' ? Number(story.index) + 1 : Number(story.index) - 1;
|
|
76
|
+
if (newStoryIndex > this.stories.length - 1 || newStoryIndex < 0) {
|
|
77
|
+
this.markStoryAsViewed(story.index);
|
|
78
|
+
this.closeFullScreenView();
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const newStory = this.stories.find((story) => story.index === newStoryIndex);
|
|
82
|
+
this.currentStory = newStory;
|
|
83
|
+
this.currentStoryId = newStory.id;
|
|
84
|
+
this.progress = 0;
|
|
85
|
+
this.markStoryAsViewed(newStory.id);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
this.startProgress = () => {
|
|
89
|
+
const interval = 100;
|
|
90
|
+
const step = (100 / (this.progressBarDuration * 1000)) * interval;
|
|
91
|
+
this.intervalId = setInterval(() => {
|
|
92
|
+
if (this.progress >= 100) {
|
|
93
|
+
clearInterval(this.intervalId);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.progress += step;
|
|
97
|
+
}
|
|
98
|
+
}, interval);
|
|
99
|
+
};
|
|
100
|
+
this.Thumbnail = ({ props }) => {
|
|
101
|
+
const open = () => this.openFullScreenStory(props.id);
|
|
102
|
+
return (h("div", { class: `StoryThumbnailContainer ${props.viewed ? 'Viewed' : 'Highlighted'}`, onTouchStart: open }, h("img", { class: `StoryThumbnailImage ${props.viewed ? 'Viewed' : 'Highlighted'}`, src: props.icon, alt: "story-icon" })));
|
|
103
|
+
};
|
|
104
|
+
this.cmsEndpoint = undefined;
|
|
105
|
+
this.language = 'en';
|
|
106
|
+
this.cmsEnv = 'stage';
|
|
107
|
+
this.clientStyling = '';
|
|
108
|
+
this.clientStylingUrl = '';
|
|
109
|
+
this.translationUrl = '';
|
|
110
|
+
this.progressBarDuration = 10;
|
|
111
|
+
this.currentStory = undefined;
|
|
112
|
+
this.currentStoryId = null;
|
|
113
|
+
this.progress = 0;
|
|
114
|
+
this.touchPosStart = undefined;
|
|
115
|
+
this.touchPosEnd = undefined;
|
|
116
|
+
}
|
|
117
|
+
handleStylingUpdate() {
|
|
118
|
+
if (this.clientStyling)
|
|
119
|
+
this.setClientStyling();
|
|
120
|
+
if (this.clientStylingUrl)
|
|
121
|
+
this.setClientStylingURL();
|
|
122
|
+
}
|
|
123
|
+
handleNewTranslations() {
|
|
124
|
+
this.isLoading = true;
|
|
125
|
+
getTranslations(this.translationUrl).then(() => {
|
|
126
|
+
this.isLoading = false;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
handleTimeEnds(newValue) {
|
|
130
|
+
if (newValue >= 100) {
|
|
131
|
+
this.changeStory(this.currentStory, 'next');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async componentWillLoad() {
|
|
135
|
+
if (this.cmsEndpoint && this.language) {
|
|
136
|
+
await this.getStories();
|
|
137
|
+
}
|
|
138
|
+
if (this.translationUrl.length > 2) {
|
|
139
|
+
await getTranslations(this.translationUrl);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
onTouchStart(e) {
|
|
143
|
+
this.touchPosStart = { clientX: e.touches[0].clientX, clientY: e.touches[0].clientY };
|
|
144
|
+
}
|
|
145
|
+
onTouchMove(e) {
|
|
146
|
+
this.touchPosEnd = { clientX: e.touches[0].clientX, clientY: e.touches[0].clientY };
|
|
147
|
+
const diffX = this.touchPosEnd.clientX - this.touchPosStart.clientX;
|
|
148
|
+
if (Math.abs(diffX) > 50) {
|
|
149
|
+
this.isSwipe = true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
onTouchEnd(e) {
|
|
153
|
+
if (this.isSwipe) {
|
|
154
|
+
this.touchPosEnd = { clientX: e.changedTouches[0].clientX, clientY: e.changedTouches[0].clientY };
|
|
155
|
+
const diffX = this.touchPosEnd.clientX - this.touchPosStart.clientX;
|
|
156
|
+
if (diffX > 0) {
|
|
157
|
+
this.changeStory(this.currentStory, 'previous');
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
this.changeStory(this.currentStory, 'next');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
const screen = window.innerWidth;
|
|
165
|
+
if (e.changedTouches[0].clientX > screen / 2) {
|
|
166
|
+
this.changeStory(this.currentStory, 'next');
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this.changeStory(this.currentStory, 'previous');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
render() {
|
|
174
|
+
if (this.hasErrors) {
|
|
175
|
+
return (h("div", { class: "GeneralStoriesError" }, h("div", { class: "Title" }, translate('error', this.language))));
|
|
176
|
+
}
|
|
177
|
+
if (this.isLoading) {
|
|
178
|
+
return (h("div", { class: "GeneralStoriesLoading" }, h("div", { class: "Title" }, translate('generalStoriesLoading', this.language))));
|
|
179
|
+
}
|
|
180
|
+
if (!this.isLoading) {
|
|
181
|
+
return (h("div", { ref: el => this.stylingContainer = el }, this.currentStoryId ?
|
|
182
|
+
h("div", { class: "FullScreenStory" }, h("div", { class: "FullScreenHeader" }, h("div", { class: "ProgressBarContainer" }, h("div", { class: "ProgressBar", style: { width: `${this.progress}%` } })), h("div", { id: "close", class: "CloseStoryButton", onTouchStart: this.closeFullScreenView }, h("svg", { fill: "none", stroke: "#ffffff", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M6 18L18 6M6 6l12 12" })))), this.currentStory.type === 'video' ?
|
|
183
|
+
h("video", { autoPlay: true }, h("source", { src: this.currentStory.url, type: "video/mp4" }))
|
|
184
|
+
:
|
|
185
|
+
h("img", { src: this.currentStory.url, alt: "story-image" }), this.currentStory.storyUrl &&
|
|
186
|
+
h("div", { class: "LoadMoreButtonBackground" }, h("button", { onTouchStart: this.navigateToExternalStoryLink, class: "LoadMoreButton" }, translate('loadMore', this.language))))
|
|
187
|
+
:
|
|
188
|
+
h("div", { class: "ImageContainer" }, this.stories.map((story) => {
|
|
189
|
+
return h(this.Thumbnail, { props: story });
|
|
190
|
+
}))));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
static get is() { return "general-stories"; }
|
|
194
|
+
static get encapsulation() { return "shadow"; }
|
|
195
|
+
static get originalStyleUrls() {
|
|
196
|
+
return {
|
|
197
|
+
"$": ["general-stories.scss"]
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
static get styleUrls() {
|
|
201
|
+
return {
|
|
202
|
+
"$": ["general-stories.css"]
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
static get properties() {
|
|
206
|
+
return {
|
|
207
|
+
"cmsEndpoint": {
|
|
208
|
+
"type": "string",
|
|
209
|
+
"mutable": false,
|
|
210
|
+
"complexType": {
|
|
211
|
+
"original": "string",
|
|
212
|
+
"resolved": "string",
|
|
213
|
+
"references": {}
|
|
214
|
+
},
|
|
215
|
+
"required": false,
|
|
216
|
+
"optional": false,
|
|
217
|
+
"docs": {
|
|
218
|
+
"tags": [],
|
|
219
|
+
"text": "Endpoint URL for the source of data"
|
|
220
|
+
},
|
|
221
|
+
"attribute": "cms-endpoint",
|
|
222
|
+
"reflect": true
|
|
223
|
+
},
|
|
224
|
+
"language": {
|
|
225
|
+
"type": "string",
|
|
226
|
+
"mutable": false,
|
|
227
|
+
"complexType": {
|
|
228
|
+
"original": "string",
|
|
229
|
+
"resolved": "string",
|
|
230
|
+
"references": {}
|
|
231
|
+
},
|
|
232
|
+
"required": false,
|
|
233
|
+
"optional": false,
|
|
234
|
+
"docs": {
|
|
235
|
+
"tags": [],
|
|
236
|
+
"text": "Language of the widget"
|
|
237
|
+
},
|
|
238
|
+
"attribute": "language",
|
|
239
|
+
"reflect": true,
|
|
240
|
+
"defaultValue": "'en'"
|
|
241
|
+
},
|
|
242
|
+
"cmsEnv": {
|
|
243
|
+
"type": "string",
|
|
244
|
+
"mutable": false,
|
|
245
|
+
"complexType": {
|
|
246
|
+
"original": "string",
|
|
247
|
+
"resolved": "string",
|
|
248
|
+
"references": {}
|
|
249
|
+
},
|
|
250
|
+
"required": false,
|
|
251
|
+
"optional": false,
|
|
252
|
+
"docs": {
|
|
253
|
+
"tags": [],
|
|
254
|
+
"text": "CMS Endpoint stage"
|
|
255
|
+
},
|
|
256
|
+
"attribute": "cms-env",
|
|
257
|
+
"reflect": true,
|
|
258
|
+
"defaultValue": "'stage'"
|
|
259
|
+
},
|
|
260
|
+
"clientStyling": {
|
|
261
|
+
"type": "string",
|
|
262
|
+
"mutable": false,
|
|
263
|
+
"complexType": {
|
|
264
|
+
"original": "string",
|
|
265
|
+
"resolved": "string",
|
|
266
|
+
"references": {}
|
|
267
|
+
},
|
|
268
|
+
"required": false,
|
|
269
|
+
"optional": false,
|
|
270
|
+
"docs": {
|
|
271
|
+
"tags": [],
|
|
272
|
+
"text": "Client custom styling via string"
|
|
273
|
+
},
|
|
274
|
+
"attribute": "client-styling",
|
|
275
|
+
"reflect": true,
|
|
276
|
+
"defaultValue": "''"
|
|
277
|
+
},
|
|
278
|
+
"clientStylingUrl": {
|
|
279
|
+
"type": "string",
|
|
280
|
+
"mutable": false,
|
|
281
|
+
"complexType": {
|
|
282
|
+
"original": "string",
|
|
283
|
+
"resolved": "string",
|
|
284
|
+
"references": {}
|
|
285
|
+
},
|
|
286
|
+
"required": false,
|
|
287
|
+
"optional": false,
|
|
288
|
+
"docs": {
|
|
289
|
+
"tags": [],
|
|
290
|
+
"text": "Client custom styling via url"
|
|
291
|
+
},
|
|
292
|
+
"attribute": "client-styling-url",
|
|
293
|
+
"reflect": true,
|
|
294
|
+
"defaultValue": "''"
|
|
295
|
+
},
|
|
296
|
+
"translationUrl": {
|
|
297
|
+
"type": "string",
|
|
298
|
+
"mutable": false,
|
|
299
|
+
"complexType": {
|
|
300
|
+
"original": "string",
|
|
301
|
+
"resolved": "string",
|
|
302
|
+
"references": {}
|
|
303
|
+
},
|
|
304
|
+
"required": false,
|
|
305
|
+
"optional": false,
|
|
306
|
+
"docs": {
|
|
307
|
+
"tags": [],
|
|
308
|
+
"text": "Translations via URL"
|
|
309
|
+
},
|
|
310
|
+
"attribute": "translation-url",
|
|
311
|
+
"reflect": true,
|
|
312
|
+
"defaultValue": "''"
|
|
313
|
+
},
|
|
314
|
+
"progressBarDuration": {
|
|
315
|
+
"type": "number",
|
|
316
|
+
"mutable": false,
|
|
317
|
+
"complexType": {
|
|
318
|
+
"original": "number",
|
|
319
|
+
"resolved": "number",
|
|
320
|
+
"references": {}
|
|
321
|
+
},
|
|
322
|
+
"required": false,
|
|
323
|
+
"optional": false,
|
|
324
|
+
"docs": {
|
|
325
|
+
"tags": [],
|
|
326
|
+
"text": "Duration of progress bar"
|
|
327
|
+
},
|
|
328
|
+
"attribute": "progress-bar-duration",
|
|
329
|
+
"reflect": true,
|
|
330
|
+
"defaultValue": "10"
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
static get states() {
|
|
335
|
+
return {
|
|
336
|
+
"currentStory": {},
|
|
337
|
+
"currentStoryId": {},
|
|
338
|
+
"progress": {},
|
|
339
|
+
"touchPosStart": {},
|
|
340
|
+
"touchPosEnd": {}
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
static get watchers() {
|
|
344
|
+
return [{
|
|
345
|
+
"propName": "clientStyling",
|
|
346
|
+
"methodName": "handleStylingUpdate"
|
|
347
|
+
}, {
|
|
348
|
+
"propName": "clientStylingUrl",
|
|
349
|
+
"methodName": "handleStylingUpdate"
|
|
350
|
+
}, {
|
|
351
|
+
"propName": "translationUrl",
|
|
352
|
+
"methodName": "handleNewTranslations"
|
|
353
|
+
}, {
|
|
354
|
+
"propName": "progress",
|
|
355
|
+
"methodName": "handleTimeEnds"
|
|
356
|
+
}];
|
|
357
|
+
}
|
|
358
|
+
static get listeners() {
|
|
359
|
+
return [{
|
|
360
|
+
"name": "touchstart",
|
|
361
|
+
"method": "onTouchStart",
|
|
362
|
+
"target": undefined,
|
|
363
|
+
"capture": false,
|
|
364
|
+
"passive": true
|
|
365
|
+
}, {
|
|
366
|
+
"name": "touchmove",
|
|
367
|
+
"method": "onTouchMove",
|
|
368
|
+
"target": undefined,
|
|
369
|
+
"capture": false,
|
|
370
|
+
"passive": true
|
|
371
|
+
}, {
|
|
372
|
+
"name": "touchend",
|
|
373
|
+
"method": "onTouchEnd",
|
|
374
|
+
"target": undefined,
|
|
375
|
+
"capture": false,
|
|
376
|
+
"passive": true
|
|
377
|
+
}];
|
|
378
|
+
}
|
|
379
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GeneralStories } from './general-stories';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/general-stories';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const TRANSLATIONS = {
|
|
3
|
+
en: {
|
|
4
|
+
error: 'Error',
|
|
5
|
+
generalStoriesLoading: 'Loading, please wait ...',
|
|
6
|
+
loadMore: 'Load More',
|
|
7
|
+
},
|
|
8
|
+
hu: {
|
|
9
|
+
error: 'Hiba',
|
|
10
|
+
generalStoriesLoading: 'Betöltés, kérjük várjon ...',
|
|
11
|
+
loadMore: 'Továbbiak betöltése',
|
|
12
|
+
},
|
|
13
|
+
ro: {
|
|
14
|
+
error: 'Eroare',
|
|
15
|
+
generalStoriesLoading: 'Se încarcă, vă rugăm așteptați ...',
|
|
16
|
+
loadMore: 'Încarcă mai multe',
|
|
17
|
+
},
|
|
18
|
+
fr: {
|
|
19
|
+
error: 'Erreur',
|
|
20
|
+
generalStoriesLoading: 'Chargement, veuillez patienter ...',
|
|
21
|
+
loadMore: 'Charger plus',
|
|
22
|
+
},
|
|
23
|
+
ar: {
|
|
24
|
+
error: 'خطأ',
|
|
25
|
+
generalStoriesLoading: 'جار التحميل، يرجى الانتظار ...',
|
|
26
|
+
loadMore: 'تحميل المزيد',
|
|
27
|
+
},
|
|
28
|
+
hr: {
|
|
29
|
+
error: 'Greška',
|
|
30
|
+
generalStoriesLoading: 'Učitavanje, molimo pričekajte ...',
|
|
31
|
+
loadMore: 'Učitaj više',
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export const getTranslations = (url) => {
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
fetch(url)
|
|
37
|
+
.then((res) => res.json())
|
|
38
|
+
.then((data) => {
|
|
39
|
+
Object.keys(data).forEach((lang) => {
|
|
40
|
+
if (!TRANSLATIONS[lang]) {
|
|
41
|
+
TRANSLATIONS[lang] = {};
|
|
42
|
+
}
|
|
43
|
+
for (let key in data[lang]) {
|
|
44
|
+
TRANSLATIONS[lang][key] = data[lang][key];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
resolve(true);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export const translate = (key, customLang) => {
|
|
52
|
+
const lang = customLang;
|
|
53
|
+
return TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
|
|
54
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function format(first, middle, last) {
|
|
2
|
+
return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
|
|
3
|
+
}
|
|
4
|
+
export const getDevice = () => {
|
|
5
|
+
let userAgent = window.navigator.userAgent;
|
|
6
|
+
if (userAgent.toLowerCase().match(/android/i)) {
|
|
7
|
+
return 'Android';
|
|
8
|
+
}
|
|
9
|
+
if (userAgent.toLowerCase().match(/iphone/i)) {
|
|
10
|
+
return 'iPhone';
|
|
11
|
+
}
|
|
12
|
+
if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
|
|
13
|
+
return 'iPad';
|
|
14
|
+
}
|
|
15
|
+
return 'PC';
|
|
16
|
+
};
|
|
17
|
+
export const getDevicePlatform = () => {
|
|
18
|
+
const device = getDevice();
|
|
19
|
+
if (device) {
|
|
20
|
+
if (device === 'PC') {
|
|
21
|
+
return 'dk';
|
|
22
|
+
}
|
|
23
|
+
else if (device === 'iPad' || device === 'iPhone') {
|
|
24
|
+
return 'mtWeb';
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return 'mtWeb';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|