@everymatrix/gamification-dropdown 1.40.0
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/gamification-dropdown.cjs.js +19 -0
- package/dist/cjs/gamification-dropdown_4.cjs.entry.js +751 -0
- package/dist/cjs/index-afa95f63.js +1704 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/cjs/player-elevate-card-items-37501652.js +2376 -0
- package/dist/cjs/player-elevate-card.cjs.entry.js +85 -0
- package/dist/cjs/player-elevate-pointcard.cjs.entry.js +92 -0
- package/dist/collection/collection-manifest.json +28 -0
- package/dist/collection/components/gamification-dropdown/gamification-dropdown.css +47 -0
- package/dist/collection/components/gamification-dropdown/gamification-dropdown.js +259 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +48 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/components/gamification-dropdown.d.ts +11 -0
- package/dist/components/gamification-dropdown.js +229 -0
- package/dist/components/general-styling-wrapper.js +6 -0
- package/dist/components/general-styling-wrapper2.js +103 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/player-elevate-card-data.js +6 -0
- package/dist/components/player-elevate-card-data2.js +632 -0
- package/dist/components/player-elevate-card-items.js +2149 -0
- package/dist/components/player-elevate-card.js +126 -0
- package/dist/components/player-elevate-loyaltycard.js +6 -0
- package/dist/components/player-elevate-loyaltycard2.js +129 -0
- package/dist/components/player-elevate-pointcard.js +135 -0
- package/dist/esm/gamification-dropdown.js +17 -0
- package/dist/esm/gamification-dropdown_4.entry.js +744 -0
- package/dist/esm/index-76ec399c.js +1675 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/player-elevate-card-items-5d6e44ca.js +2363 -0
- package/dist/esm/player-elevate-card.entry.js +81 -0
- package/dist/esm/player-elevate-pointcard.entry.js +88 -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/gamification-dropdown/gamification-dropdown.esm.js +1 -0
- package/dist/gamification-dropdown/index.esm.js +0 -0
- package/dist/gamification-dropdown/p-2d5bddc0.js +1 -0
- package/dist/gamification-dropdown/p-4eba8e43.entry.js +1 -0
- package/dist/gamification-dropdown/p-5e3064ce.js +1 -0
- package/dist/gamification-dropdown/p-62327671.entry.js +1 -0
- package/dist/gamification-dropdown/p-bbd6d5a3.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/static/button-default.svg +42 -0
- package/dist/static/button-disabled.svg +4 -0
- package/dist/static/button-hover.svg +4 -0
- package/dist/static/button-level.svg +27 -0
- package/dist/static/button-pressed.svg +18 -0
- package/dist/static/button-redeem.svg +36 -0
- package/dist/static/card-ground-over.png +0 -0
- package/dist/static/card-ground-over.svg +903 -0
- package/dist/static/card-ground.png +0 -0
- package/dist/static/card-ground.svg +34 -0
- package/dist/static/info.svg +4 -0
- package/dist/static/level-badge.png +0 -0
- package/dist/static/level-percent.svg +80 -0
- package/dist/static/tips-info.svg +21 -0
- package/dist/static/user.svg +3 -0
- package/dist/stencil.config.js +22 -0
- package/dist/types/Users/sebastian.strulea/Documents/work/widgets-stencil/packages/gamification-dropdown/.stencil/packages/gamification-dropdown/stencil.config.d.ts +2 -0
- package/dist/types/components/gamification-dropdown/gamification-dropdown.d.ts +41 -0
- package/dist/types/components.d.ts +85 -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 +2 -0
- package/dist/types/utils/utils.d.ts +1 -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 +22 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-afa95f63.js');
|
|
6
|
+
const playerElevateCardItems = require('./player-elevate-card-items-37501652.js');
|
|
7
|
+
|
|
8
|
+
const playerElevateCardCss = "@container (max-width: 270px) {\n .Card .Inner {\n flex-direction: column;\n }\n .Card .Inner .Content {\n padding: 9px;\n }\n\n .Inner .Row .ExpirationPoints {\n order: 1;\n }\n}\n.Card .PlayerImg {\n order: 0;\n}\n.Card .ExpirationPoints {\n order: 3;\n}\n.Card .LevelInfo {\n order: 2;\n}\n.Card .Inner .Row .PlayerImg {\n flex-direction: column;\n}\n.Card .Inner .Row .PointsInfo {\n width: 100%;\n text-align: center;\n display: flex;\n flex-direction: column;\n max-height: 50%;\n}\n.Card .Inner .PlayerAvatar .Badge {\n background-size: contain;\n background-repeat: no-repeat;\n position: absolute;\n right: 5px;\n bottom: -5px;\n width: 40%;\n height: 40%;\n overflow: visible;\n}\n.Card .Inner .Row .ExpirationPoints {\n text-align: left;\n color: var(--emfe-w-color-red, red);\n}\n.Card .Inner .Row .Points {\n text-wrap: nowrap;\n}\n.Card .Inner .LevelInfo .ElevateLevel {\n flex-direction: column;\n}\n.Card .Inner .LevelInfo .ElevateLevel .LevelName {\n width: calc(100% - 20px);\n text-align: left;\n font-size: 13px;\n padding-left: 20px;\n margin: 10px 0;\n}\n.Card .Inner .LevelInfo .ElevateLevel .ExpirationDate {\n text-align: center;\n font-size: smaller;\n}\n.Card .Inner .LevelInfo .ElevateLevel .ExpireTime {\n margin-left: 5px;\n}";
|
|
9
|
+
|
|
10
|
+
const PlayerElevateCard = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
/**
|
|
14
|
+
* The style that widget shows,available value: Dark, Light
|
|
15
|
+
* Default: Dark
|
|
16
|
+
*/
|
|
17
|
+
this.theme = 'Dark';
|
|
18
|
+
/**
|
|
19
|
+
* Widget Language to show
|
|
20
|
+
*/
|
|
21
|
+
this.language = 'en';
|
|
22
|
+
/**
|
|
23
|
+
* datePattern
|
|
24
|
+
*/
|
|
25
|
+
this.dateFormat = 'yyyy-MM-dd';
|
|
26
|
+
/**
|
|
27
|
+
* Client custom styling via inline styles
|
|
28
|
+
*/
|
|
29
|
+
this.clientStyling = '';
|
|
30
|
+
/**
|
|
31
|
+
* Client custom styling via url
|
|
32
|
+
*/
|
|
33
|
+
this.clientStylingUrl = '';
|
|
34
|
+
/**
|
|
35
|
+
* Translation via url
|
|
36
|
+
*/
|
|
37
|
+
this.translationUrl = '';
|
|
38
|
+
this.playerLevelFlag = 0;
|
|
39
|
+
}
|
|
40
|
+
onSessionOrEndpointChange() {
|
|
41
|
+
this.paramProxy = Object.assign(Object.assign({}, this.paramProxy), { session: this.session, endpoint: this.endpoint, language: this.language });
|
|
42
|
+
}
|
|
43
|
+
playerElevateLeveLoadedHandler(event) {
|
|
44
|
+
if (!event.detail) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (event.detail['elevateLevelWalletTotal']) {
|
|
48
|
+
this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
|
|
49
|
+
}
|
|
50
|
+
if (event.detail['elevateLevel']) {
|
|
51
|
+
this.playerElevateLevel = event.detail['elevateLevel'];
|
|
52
|
+
}
|
|
53
|
+
if (event.detail['pointExpireString']) {
|
|
54
|
+
this.pointExpireString = event.detail.xpExpireString;
|
|
55
|
+
}
|
|
56
|
+
if (event.detail.calculatedLevelFlag) {
|
|
57
|
+
this.playerLevelFlag = event.detail.calculatedLevelFlag;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
onRedeemClick() {
|
|
61
|
+
window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
|
|
62
|
+
}
|
|
63
|
+
componentWillLoad() {
|
|
64
|
+
this.paramProxy = {
|
|
65
|
+
endpoint: this.endpoint,
|
|
66
|
+
session: this.session,
|
|
67
|
+
language: this.language,
|
|
68
|
+
calculateLevelFlag: true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
render() {
|
|
72
|
+
const backgroundOuterImagePath = index.getAssetPath('../static/card-ground.svg');
|
|
73
|
+
const backgroundInnerImagePath = index.getAssetPath('../static/card-ground-over.svg');
|
|
74
|
+
return (index.h("div", { class: `ElevateCardWrapper ${this.theme}` }, index.h("div", { class: "Card Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, index.h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: playerElevateCardItems.TRANSLATIONS, translationUrl: this.translationUrl }), index.h("player-elevate-card-data", { params: this.paramProxy }), index.h("div", { class: "OuterCover Inner", style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, this.playerElevateLevel && (index.h(index.Fragment, null, index.h("div", { class: 'Content Row' }, index.h("div", { class: "PlayerImg" }, index.h(playerElevateCardItems.PlayerAvatar, { playerAvatarUrl: this.playerAvatarUrl, loyaltyIconUrl: this.playerElevateLevel.presentation.asset }), index.h(playerElevateCardItems.PlayerPoints, { loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language })), this.pointExpireString && (index.h("div", { class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), index.h("div", { class: `LevelInfo Level${this.playerLevelFlag} ${this.playerElevateLevel.presentation.displayName}` }, index.h(playerElevateCardItems.PlayerNameDiv, { playerName: this.playerName }), index.h(playerElevateCardItems.PlayerElevateLoyaltyLevel, { hideInfo: true, level: this.playerElevateLevel.name, expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat }), index.h(playerElevateCardItems.PlayerLoyaltyProcess, null), index.h(playerElevateCardItems.PlayerElevateCardRedeem, { onRedeemClick: this.onRedeemClick, language: this.language })))))))));
|
|
75
|
+
}
|
|
76
|
+
static get assetsDirs() { return ["../static"]; }
|
|
77
|
+
static get watchers() { return {
|
|
78
|
+
"session": ["onSessionOrEndpointChange"],
|
|
79
|
+
"endpoint": ["onSessionOrEndpointChange"],
|
|
80
|
+
"language": ["onSessionOrEndpointChange"]
|
|
81
|
+
}; }
|
|
82
|
+
};
|
|
83
|
+
PlayerElevateCard.style = playerElevateCardCss;
|
|
84
|
+
|
|
85
|
+
exports.player_elevate_card = PlayerElevateCard;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-afa95f63.js');
|
|
6
|
+
const playerElevateCardItems = require('./player-elevate-card-items-37501652.js');
|
|
7
|
+
|
|
8
|
+
const playerElevatePointcardCss = ":host{display:block}.PointsCard .Inner .Row .ExpirationPoints{text-align:left}.PointsCard .Inner .PlayerAvatar .Avatar{display:none}.PointsCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%;position:inherit}.PointsCard .Inner .PointsTxt{display:flex;flex-direction:row;justify-content:space-between}.PointsCard .Inner .DetailButton{background:linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%), linear-gradient(0deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6));border-radius:5px;box-shadow:0px 4px 4px 0px rgba(0, 0, 0, 0.25);border:2px solid;font-size:11px;width:108px;padding:4px;cursor:pointer;margin-top:5px;height:16px;min-width:45px;text-align:center}.PointsCard .Inner .DetailButton span{color:var(--emfe-w-color-gray-150, #6D6D6D)}.PointsCard .Inner .DetailButton span{display:inline-block;vertical-align:middle}.PointsCard .Inner .DetailButton:hover span{color:var(--emfe-w-color-gray-150, #6D6D6D)}.PointsCard .Inner .LevelInfo{gap:15px;width:70%}.PointsCard .Inner .LevelInfo .PointsTxt{font-size:15px}.PointsCard .Inner .LevelInfo .PointsTxt.Label{display:none}.PointsCard .Inner .LevelInfo .PointsTxt.SPPoints{padding-top:15px}.PointsCard .Inner .LevelInfo .PointsTxt .TC{font-size:x-small;color:var(--emw--color-gray-300, #58586B);display:flex;align-content:center;height:100%;flex-wrap:wrap;text-decoration:underline;cursor:pointer;display:none}";
|
|
9
|
+
|
|
10
|
+
const PlayerElevatePointcard = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
/**
|
|
14
|
+
* The style that widget shows,available value: Dark, Light
|
|
15
|
+
* Default: Dark
|
|
16
|
+
*/
|
|
17
|
+
this.theme = 'Dark';
|
|
18
|
+
/**
|
|
19
|
+
* Widget Language to show
|
|
20
|
+
*/
|
|
21
|
+
this.language = 'en';
|
|
22
|
+
/**
|
|
23
|
+
* Check if the card used in points details widget, default: 'earningRule'
|
|
24
|
+
* value: 'details'/'earningRule'
|
|
25
|
+
* It effected the button in card
|
|
26
|
+
* 'earningRule': button text, 'earning rules', post 'BEEPointRulesClicked' when clicked
|
|
27
|
+
* 'details': button text, 'details', post 'BEEDetailsClicked' when clicked
|
|
28
|
+
*/
|
|
29
|
+
this.buttonType = 'earningRule';
|
|
30
|
+
/**
|
|
31
|
+
* datePattern
|
|
32
|
+
*/
|
|
33
|
+
this.dateFormat = 'yyyy-MM-dd';
|
|
34
|
+
/**
|
|
35
|
+
* Client custom styling via inline styles
|
|
36
|
+
*/
|
|
37
|
+
this.clientStyling = '';
|
|
38
|
+
/**
|
|
39
|
+
* Client custom styling via url
|
|
40
|
+
*/
|
|
41
|
+
this.clientStylingUrl = '';
|
|
42
|
+
/**
|
|
43
|
+
* Translation via url
|
|
44
|
+
*/
|
|
45
|
+
this.translationUrl = '';
|
|
46
|
+
this.isPointDetailCard = this.buttonType === 'earningRule';
|
|
47
|
+
}
|
|
48
|
+
onSessionOrEndpointChange() {
|
|
49
|
+
this.paramProxy = Object.assign(Object.assign({}, this.paramProxy), { session: this.session, endpoint: this.endpoint, language: this.language });
|
|
50
|
+
}
|
|
51
|
+
playerElevateLeveLoadedHandler(event) {
|
|
52
|
+
if (!event.detail) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (event.detail['elevateLevelWalletTotal']) {
|
|
56
|
+
this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
|
|
57
|
+
this.elevateSPTotal = event.detail['loyaltyWalletTotal'];
|
|
58
|
+
}
|
|
59
|
+
if (event.detail['elevateLevel']) {
|
|
60
|
+
this.playerElevateLevel = event.detail['elevateLevel'];
|
|
61
|
+
}
|
|
62
|
+
if (event.detail['pointExpireString']) {
|
|
63
|
+
this.pointExpireString = event.detail.pointExpireString;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
onDetailsClick() {
|
|
67
|
+
window.postMessage({ type: this.isPointDetailCard ? 'BEEPointRulesClicked' : 'BEEDetailsClicked',
|
|
68
|
+
path: this.isPointDetailCard ? 'player-elevate-level' : 'player-elevate-point-details' }, window.location.href);
|
|
69
|
+
}
|
|
70
|
+
componentWillLoad() {
|
|
71
|
+
this.paramProxy = {
|
|
72
|
+
endpoint: this.endpoint,
|
|
73
|
+
session: this.session,
|
|
74
|
+
language: this.language,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
const backgroundOuterImagePath = index.getAssetPath('../static/card-ground.svg');
|
|
79
|
+
const backgroundInnerImagePath = index.getAssetPath('../static/card-ground-over.svg');
|
|
80
|
+
return (index.h("div", { class: `ElevateCardWrapper ${this.theme}` }, index.h("div", { class: "PointsCard Outer ", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, index.h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: playerElevateCardItems.TRANSLATIONS, translationUrl: this.translationUrl }), index.h("player-elevate-card-data", { params: this.paramProxy }), index.h("div", { class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, index.h("div", { class: 'Content Row' }, this.playerElevateLevel && (index.h(index.Fragment, null, index.h("div", { class: "PlayerImg" }, index.h(playerElevateCardItems.PlayerAvatar, { onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), index.h("div", { class: `LevelInfo ${this.playerElevateLevel.name}` }, index.h("div", { class: "PointsTxt Label" }, this.cardTitle ? this.cardTitle : playerElevateCardItems.translate('spendablePoints')), index.h("div", { class: 'PointsTxt SPPoints' }, index.h(playerElevateCardItems.PlayerPoints, { spendablePoints: this.playerElevateLevel.spendablePoints, language: this.language }), index.h("a", { class: "TC", onClick: () => {
|
|
81
|
+
this.onDetailsClick();
|
|
82
|
+
} }, playerElevateCardItems.translate('termAndConditions', this.language))), this.pointExpireString && (index.h("div", { class: 'ExpirationPoints' }, this.pointExpireString, " "))))))))));
|
|
83
|
+
}
|
|
84
|
+
static get watchers() { return {
|
|
85
|
+
"session": ["onSessionOrEndpointChange"],
|
|
86
|
+
"endpoint": ["onSessionOrEndpointChange"],
|
|
87
|
+
"language": ["onSessionOrEndpointChange"]
|
|
88
|
+
}; }
|
|
89
|
+
};
|
|
90
|
+
PlayerElevatePointcard.style = playerElevatePointcardCss;
|
|
91
|
+
|
|
92
|
+
exports.player_elevate_pointcard = PlayerElevatePointcard;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entries": [
|
|
3
|
+
"./components/gamification-dropdown/gamification-dropdown.js"
|
|
4
|
+
],
|
|
5
|
+
"compiler": {
|
|
6
|
+
"name": "@stencil/core",
|
|
7
|
+
"version": "2.15.2",
|
|
8
|
+
"typescriptVersion": "4.5.4"
|
|
9
|
+
},
|
|
10
|
+
"collections": [
|
|
11
|
+
{
|
|
12
|
+
"name": "@everymatrix/general-styling-wrapper",
|
|
13
|
+
"tags": [
|
|
14
|
+
"general-styling-wrapper"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "@everymatrix/player-elevate-card",
|
|
19
|
+
"tags": [
|
|
20
|
+
"player-elevate-card",
|
|
21
|
+
"player-elevate-card-data",
|
|
22
|
+
"player-elevate-loyaltycard",
|
|
23
|
+
"player-elevate-pointcard"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"bundles": []
|
|
28
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.GamificationDropdownContainer {
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
.GamificationDropdownContainer .GamificationDropdown {
|
|
9
|
+
position: absolute;
|
|
10
|
+
left: 0;
|
|
11
|
+
z-index: 999;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.GamificationDropdownButton {
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
font-size: 14px;
|
|
18
|
+
height: 20px;
|
|
19
|
+
background-color: unset;
|
|
20
|
+
color: var(--emw--color-typography, #FFFFFF);
|
|
21
|
+
padding: 0;
|
|
22
|
+
border: none;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
white-space: nowrap;
|
|
25
|
+
text-overflow: ellipsis;
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
line-height: 0;
|
|
30
|
+
}
|
|
31
|
+
.GamificationDropdownButton:hover {
|
|
32
|
+
color: var(--emw--color-primary, #52d004);
|
|
33
|
+
}
|
|
34
|
+
.GamificationDropdownButton:hover svg {
|
|
35
|
+
fill: var(--emw--color-primary, #52d004);
|
|
36
|
+
}
|
|
37
|
+
.GamificationDropdownButton.IsOpen {
|
|
38
|
+
color: var(--emw--color-primary, #52d004);
|
|
39
|
+
}
|
|
40
|
+
.GamificationDropdownButton.IsOpen svg {
|
|
41
|
+
fill: var(--emw--color-primary, #52d004);
|
|
42
|
+
}
|
|
43
|
+
.GamificationDropdownButton svg {
|
|
44
|
+
fill: var(--emw--color-typography, #FFFFFF);
|
|
45
|
+
margin-left: 8px;
|
|
46
|
+
width: 16px;
|
|
47
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { Component, h, State, Prop, Watch } from '@stencil/core';
|
|
2
|
+
import { getTranslations, translate } from '../../utils/locale.utils';
|
|
3
|
+
import '@everymatrix/player-elevate-card';
|
|
4
|
+
export class GamificationDropdown {
|
|
5
|
+
constructor() {
|
|
6
|
+
/**
|
|
7
|
+
* Language of the widget
|
|
8
|
+
*/
|
|
9
|
+
this.language = 'en';
|
|
10
|
+
/**
|
|
11
|
+
* Session of the user
|
|
12
|
+
*/
|
|
13
|
+
this.session = '';
|
|
14
|
+
/**
|
|
15
|
+
* Client custom styling via string
|
|
16
|
+
*/
|
|
17
|
+
this.clientStyling = '';
|
|
18
|
+
/**
|
|
19
|
+
* Client custom styling via url
|
|
20
|
+
*/
|
|
21
|
+
this.clientStylingUrl = '';
|
|
22
|
+
/**
|
|
23
|
+
* Translations via URL
|
|
24
|
+
*/
|
|
25
|
+
this.translationUrl = '';
|
|
26
|
+
this.isLoading = false;
|
|
27
|
+
this.stylingAppends = false;
|
|
28
|
+
this.setClientStyling = () => {
|
|
29
|
+
let sheet = document.createElement('style');
|
|
30
|
+
sheet.innerHTML = this.clientStyling;
|
|
31
|
+
this.stylingContainer.prepend(sheet);
|
|
32
|
+
};
|
|
33
|
+
this.setClientStylingURL = () => {
|
|
34
|
+
let url = new URL(this.clientStylingUrl);
|
|
35
|
+
let cssFile = document.createElement('style');
|
|
36
|
+
fetch(url.href)
|
|
37
|
+
.then((res) => res.text())
|
|
38
|
+
.then((data) => {
|
|
39
|
+
cssFile.innerHTML = data;
|
|
40
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
41
|
+
})
|
|
42
|
+
.catch((err) => {
|
|
43
|
+
console.log('error ', err);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
this.handleOutsideClick = (event) => {
|
|
47
|
+
const dropdownElement = document.querySelector('gamification-dropdown');
|
|
48
|
+
if (dropdownElement && !dropdownElement.contains(event.target)) {
|
|
49
|
+
this.isOpen = false;
|
|
50
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
this.handleDropdownClick = () => {
|
|
54
|
+
this.isOpen = !this.isOpen;
|
|
55
|
+
if (this.isOpen) {
|
|
56
|
+
document.addEventListener('click', this.handleOutsideClick);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
handleNewTranslations() {
|
|
64
|
+
this.isLoading = true;
|
|
65
|
+
getTranslations(this.translationUrl).then(() => {
|
|
66
|
+
this.isLoading = false;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async componentWillLoad() {
|
|
70
|
+
if (this.translationUrl.length > 2) {
|
|
71
|
+
await getTranslations(this.translationUrl);
|
|
72
|
+
}
|
|
73
|
+
if (this.endpoint && this.language) {
|
|
74
|
+
return this.fetchPointsData();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
componentDidRender() {
|
|
78
|
+
// start custom styling area
|
|
79
|
+
if (!this.stylingAppends && this.stylingContainer) {
|
|
80
|
+
if (this.clientStyling)
|
|
81
|
+
this.setClientStyling();
|
|
82
|
+
if (this.clientStylingUrl)
|
|
83
|
+
this.setClientStylingURL();
|
|
84
|
+
this.stylingAppends = true;
|
|
85
|
+
}
|
|
86
|
+
// end custom styling area
|
|
87
|
+
}
|
|
88
|
+
fetchPointsData() {
|
|
89
|
+
let url = new URL(`${this.endpoint}/v1/elevate/playerInfo`);
|
|
90
|
+
url.searchParams.append('language', this.language);
|
|
91
|
+
const headers = new Headers();
|
|
92
|
+
headers.append('X-SessionId', this.session);
|
|
93
|
+
const options = {
|
|
94
|
+
method: 'GET',
|
|
95
|
+
headers
|
|
96
|
+
};
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
this.isLoading = true;
|
|
99
|
+
fetch(url.href, options)
|
|
100
|
+
.then((res) => res.json())
|
|
101
|
+
.then((data) => {
|
|
102
|
+
var _a, _b;
|
|
103
|
+
this.loyaltyPoints = (_b = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.level) === null || _b === void 0 ? void 0 : _b.loyaltyPoints;
|
|
104
|
+
resolve(true);
|
|
105
|
+
}).catch((err) => {
|
|
106
|
+
console.error(err);
|
|
107
|
+
reject(err);
|
|
108
|
+
}).finally(() => {
|
|
109
|
+
this.isLoading = false;
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
render() {
|
|
114
|
+
if (this.isLoading) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return (h("div", { class: "GamificationDropdownContainer" },
|
|
119
|
+
h("button", { class: `GamificationDropdownButton ${this.isOpen ? 'IsOpen' : ''}`, type: "button", onClick: this.handleDropdownClick, title: typeof this.loyaltyPoints === 'number'
|
|
120
|
+
? String(this.loyaltyPoints)
|
|
121
|
+
: translate('gamificationNoPoints', this.language) },
|
|
122
|
+
typeof this.loyaltyPoints === 'number'
|
|
123
|
+
? `${Math.floor(this.loyaltyPoints)} XP`
|
|
124
|
+
: '...',
|
|
125
|
+
h("span", null,
|
|
126
|
+
h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "6.835", viewBox: "0 0 14 6.835" },
|
|
127
|
+
h("path", { id: "arrow", d: "M281.541,447.921a.488.488,0,0,0,.295-.122l6.5-5.851a.488.488,0,1,0-.65-.726l-6.176,5.556-6.176-5.556h0a.488.488,0,1,0-.65.726l6.5,5.851a.488.488,0,0,0,.355.122Z", transform: "translate(-274.511 -441.088)" })))),
|
|
128
|
+
this.isOpen && (h("div", { class: "GamificationDropdown" },
|
|
129
|
+
h("player-elevate-loyaltycard", { endpoint: this.endpoint, session: this.session, language: this.language, "client-styling-url": this.clientStylingUrl, "client-styling": this.clientStyling })))));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
static get is() { return "gamification-dropdown"; }
|
|
133
|
+
static get encapsulation() { return "shadow"; }
|
|
134
|
+
static get originalStyleUrls() { return {
|
|
135
|
+
"$": ["gamification-dropdown.scss"]
|
|
136
|
+
}; }
|
|
137
|
+
static get styleUrls() { return {
|
|
138
|
+
"$": ["gamification-dropdown.css"]
|
|
139
|
+
}; }
|
|
140
|
+
static get properties() { return {
|
|
141
|
+
"endpoint": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"mutable": false,
|
|
144
|
+
"complexType": {
|
|
145
|
+
"original": "string",
|
|
146
|
+
"resolved": "string",
|
|
147
|
+
"references": {}
|
|
148
|
+
},
|
|
149
|
+
"required": false,
|
|
150
|
+
"optional": false,
|
|
151
|
+
"docs": {
|
|
152
|
+
"tags": [],
|
|
153
|
+
"text": "Endpoint URL for the source of data"
|
|
154
|
+
},
|
|
155
|
+
"attribute": "endpoint",
|
|
156
|
+
"reflect": true
|
|
157
|
+
},
|
|
158
|
+
"language": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"mutable": false,
|
|
161
|
+
"complexType": {
|
|
162
|
+
"original": "string",
|
|
163
|
+
"resolved": "string",
|
|
164
|
+
"references": {}
|
|
165
|
+
},
|
|
166
|
+
"required": false,
|
|
167
|
+
"optional": false,
|
|
168
|
+
"docs": {
|
|
169
|
+
"tags": [],
|
|
170
|
+
"text": "Language of the widget"
|
|
171
|
+
},
|
|
172
|
+
"attribute": "language",
|
|
173
|
+
"reflect": true,
|
|
174
|
+
"defaultValue": "'en'"
|
|
175
|
+
},
|
|
176
|
+
"session": {
|
|
177
|
+
"type": "string",
|
|
178
|
+
"mutable": false,
|
|
179
|
+
"complexType": {
|
|
180
|
+
"original": "string",
|
|
181
|
+
"resolved": "string",
|
|
182
|
+
"references": {}
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"optional": false,
|
|
186
|
+
"docs": {
|
|
187
|
+
"tags": [],
|
|
188
|
+
"text": "Session of the user"
|
|
189
|
+
},
|
|
190
|
+
"attribute": "session",
|
|
191
|
+
"reflect": true,
|
|
192
|
+
"defaultValue": "''"
|
|
193
|
+
},
|
|
194
|
+
"clientStyling": {
|
|
195
|
+
"type": "string",
|
|
196
|
+
"mutable": false,
|
|
197
|
+
"complexType": {
|
|
198
|
+
"original": "string",
|
|
199
|
+
"resolved": "string",
|
|
200
|
+
"references": {}
|
|
201
|
+
},
|
|
202
|
+
"required": false,
|
|
203
|
+
"optional": false,
|
|
204
|
+
"docs": {
|
|
205
|
+
"tags": [],
|
|
206
|
+
"text": "Client custom styling via string"
|
|
207
|
+
},
|
|
208
|
+
"attribute": "client-styling",
|
|
209
|
+
"reflect": true,
|
|
210
|
+
"defaultValue": "''"
|
|
211
|
+
},
|
|
212
|
+
"clientStylingUrl": {
|
|
213
|
+
"type": "string",
|
|
214
|
+
"mutable": false,
|
|
215
|
+
"complexType": {
|
|
216
|
+
"original": "string",
|
|
217
|
+
"resolved": "string",
|
|
218
|
+
"references": {}
|
|
219
|
+
},
|
|
220
|
+
"required": false,
|
|
221
|
+
"optional": false,
|
|
222
|
+
"docs": {
|
|
223
|
+
"tags": [],
|
|
224
|
+
"text": "Client custom styling via url"
|
|
225
|
+
},
|
|
226
|
+
"attribute": "client-styling-url",
|
|
227
|
+
"reflect": true,
|
|
228
|
+
"defaultValue": "''"
|
|
229
|
+
},
|
|
230
|
+
"translationUrl": {
|
|
231
|
+
"type": "string",
|
|
232
|
+
"mutable": false,
|
|
233
|
+
"complexType": {
|
|
234
|
+
"original": "string",
|
|
235
|
+
"resolved": "string",
|
|
236
|
+
"references": {}
|
|
237
|
+
},
|
|
238
|
+
"required": false,
|
|
239
|
+
"optional": false,
|
|
240
|
+
"docs": {
|
|
241
|
+
"tags": [],
|
|
242
|
+
"text": "Translations via URL"
|
|
243
|
+
},
|
|
244
|
+
"attribute": "translation-url",
|
|
245
|
+
"reflect": true,
|
|
246
|
+
"defaultValue": "''"
|
|
247
|
+
}
|
|
248
|
+
}; }
|
|
249
|
+
static get states() { return {
|
|
250
|
+
"isOpen": {},
|
|
251
|
+
"isLoading": {},
|
|
252
|
+
"stylingAppends": {},
|
|
253
|
+
"loyaltyPoints": {}
|
|
254
|
+
}; }
|
|
255
|
+
static get watchers() { return [{
|
|
256
|
+
"propName": "translationUrl",
|
|
257
|
+
"methodName": "handleNewTranslations"
|
|
258
|
+
}]; }
|
|
259
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const SUPPORTED_LANGUAGES = ['de', 'en', 'hr'];
|
|
3
|
+
let TRANSLATIONS = {
|
|
4
|
+
en: {
|
|
5
|
+
gamificationNoPoints: "No points"
|
|
6
|
+
},
|
|
7
|
+
de: {
|
|
8
|
+
gamificationNoPoints: "No points"
|
|
9
|
+
},
|
|
10
|
+
ro: {
|
|
11
|
+
gamificationNoPoints: "No points"
|
|
12
|
+
},
|
|
13
|
+
fr: {
|
|
14
|
+
gamificationNoPoints: "No points"
|
|
15
|
+
},
|
|
16
|
+
ar: {
|
|
17
|
+
gamificationNoPoints: "No points"
|
|
18
|
+
},
|
|
19
|
+
hr: {
|
|
20
|
+
gamificationNoPoints: "No points"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export const getTranslations = (url) => {
|
|
24
|
+
// fetch url, get the data, replace the TRANSLATIONS content
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
fetch(url)
|
|
27
|
+
.then((res) => res.json())
|
|
28
|
+
.then((data) => {
|
|
29
|
+
Object.keys(data).forEach((item) => {
|
|
30
|
+
for (let key in data[item]) {
|
|
31
|
+
TRANSLATIONS[item][key] = data[item][key];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
resolve(true);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export const translate = (key, customLang, values) => {
|
|
39
|
+
const lang = customLang;
|
|
40
|
+
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
41
|
+
if (values !== undefined) {
|
|
42
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
43
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
44
|
+
translation = translation.replace(regex, value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return translation;
|
|
48
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface GamificationDropdown extends Components.GamificationDropdown, HTMLElement {}
|
|
4
|
+
export const GamificationDropdown: {
|
|
5
|
+
prototype: GamificationDropdown;
|
|
6
|
+
new (): GamificationDropdown;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|