@everymatrix/casino-tournaments-slider-controller 0.0.262
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/README.md +30 -0
- package/dist/casino-tournaments-slider-controller.js +6469 -0
- package/dist/casino-tournaments-slider-controller.js.map +1 -0
- package/index.html +47 -0
- package/index.js +1 -0
- package/package.json +41 -0
- package/public/favicon.png +0 -0
- package/public/reset.css +48 -0
- package/rollup.config.js +61 -0
- package/src/CasinoTournamentsSliderController.svelte +342 -0
- package/src/i18n.js +27 -0
- package/src/index.ts +4 -0
- package/src/translations.js +17 -0
- package/stories/CasinoTournamentsSliderConstroller.stories.js +13 -0
- package/tsconfig.json +6 -0
package/index.html
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset='utf-8'>
|
|
5
|
+
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
|
6
|
+
|
|
7
|
+
<title>
|
|
8
|
+
casino-tournaments-slider-controller
|
|
9
|
+
</title>
|
|
10
|
+
<link rel="stylesheet" href="public/reset.css">
|
|
11
|
+
<script src='dist/casino-tournaments-slider-controller.js'></script>
|
|
12
|
+
</head>
|
|
13
|
+
|
|
14
|
+
<body>
|
|
15
|
+
<style>
|
|
16
|
+
html,body { margin: 0; padding: 0; height: 100%; font-family: "Helvetica Neue", "Helvetica", sans-serif; }
|
|
17
|
+
.header { display: flex; justify-content: center; align-items: center; padding: 10px 20px; margin-bottom: 20px; background: #42a3e2; box-shadow: 3px 4px 5px 0px rgba(0,0,0, .2); }
|
|
18
|
+
.header__logo svg { height: 50px; width: 50px; margin-right: 5px; }
|
|
19
|
+
.header__name { color: #fff; }
|
|
20
|
+
.header__name span { margin-right: 10px; font-weight: bold; }
|
|
21
|
+
.webcomponent { padding: 10px 20px; }
|
|
22
|
+
.webcomponent{
|
|
23
|
+
width: 128px;
|
|
24
|
+
height: 80px;
|
|
25
|
+
position: absolute;
|
|
26
|
+
right: 5px;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
29
|
+
<header class="header">
|
|
30
|
+
<div class="header__logo">
|
|
31
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="161" height="132" viewBox="0 0 161 132"><defs><linearGradient x1="0%" y1="50%" y2="50%" id="a"><stop stop-color="#2A3B8F" offset="0%"/><stop stop-color="#29ABE2" offset="100%"/></linearGradient><linearGradient x1="100%" y1="50%" x2="0%" y2="50%" id="c"><stop stop-color="#B4D44E" offset="0%"/><stop stop-color="#E7F716" offset="100%"/></linearGradient></defs><g fill="none" fill-rule="evenodd"><path fill="#166DA5" d="M160.6 65.9l-17.4 29.3-24.4-29.7 24.4-28.9z"/><path fill="#8FDB69" d="M141.3 100.2l-26.5-31.7-15.9 26.6 24.7 36.1z"/><path fill="#166DA5" d="M141 31.4l-26.2 31.8-15.9-26.6L123.6.9z"/><path fill="url(#a)" opacity=".95" d="M61.1 31.4H141L123.4.7H78.7z M114.8 63.3H159l-15.9-26.8H98.8"/><path fill="url(#c)" opacity=".95" d="M141.3 100.3H61l17.6 30.5h45z M114.8 68.4H159l-15.9 26.8H98.8"/><path fill="#010101" d="M78.6 130.8L41 65.8 79.1.8H37.9L.4 65.8l37.5 65z"/></g></svg>
|
|
32
|
+
</div>
|
|
33
|
+
<h1 class="header__name">
|
|
34
|
+
<span>WEBCOMPONENT:</span> casino-tournaments-slider-controller
|
|
35
|
+
</h1>
|
|
36
|
+
</header>
|
|
37
|
+
|
|
38
|
+
<div class="webcomponent">
|
|
39
|
+
<casino-tournaments-slider-controller
|
|
40
|
+
session="fb9725c6-67eb-4e36-84e5-456d8b9f85ed" userid="3657535"
|
|
41
|
+
endpoint="https://jetbull-api.stage.norway.everymatrix.com/v1"
|
|
42
|
+
tournamentsshownnumber="4" lang="en"
|
|
43
|
+
></casino-tournaments-slider-controller>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
</body>
|
|
47
|
+
</html>
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './dist/casino-tournaments-slider-controller.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@everymatrix/casino-tournaments-slider-controller",
|
|
3
|
+
"version": "0.0.262",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"svelte": "src/index.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "sirv public",
|
|
8
|
+
"build": "cross-env NODE_ENV=\"production\" && rollup -c",
|
|
9
|
+
"dev": "cross-env NODE_ENV=\"development\" rollup -c -w",
|
|
10
|
+
"validate": "svelte-check",
|
|
11
|
+
"test": "echo"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
15
|
+
"@rollup/plugin-commonjs": "^16.0.0",
|
|
16
|
+
"@rollup/plugin-node-resolve": "^10.0.0",
|
|
17
|
+
"@rollup/plugin-typescript": "^6.0.0",
|
|
18
|
+
"@tsconfig/svelte": "^1.0.0",
|
|
19
|
+
"node-sass": "^5.0.0",
|
|
20
|
+
"rollup": "^2.3.4",
|
|
21
|
+
"rollup-plugin-dev-server": "^0.4.3",
|
|
22
|
+
"rollup-plugin-livereload": "^2.0.0",
|
|
23
|
+
"rollup-plugin-svelte": "^7.0.0",
|
|
24
|
+
"rollup-plugin-terser": "^7.0.0",
|
|
25
|
+
"rollup-plugin-uglify": "^6.0.4",
|
|
26
|
+
"svelte-check": "^1.0.0",
|
|
27
|
+
"svelte-preprocess": "^4.0.0",
|
|
28
|
+
"tslib": "^2.0.0",
|
|
29
|
+
"typescript": "^3.9.3"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@everymatrix/casino-tournaments-rank": "^0.0.262",
|
|
33
|
+
"cross-env": "^7.0.3",
|
|
34
|
+
"sirv-cli": "^1.0.0",
|
|
35
|
+
"svelte": "^3.0.0"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "63a3c79f8f47451d7ca7f8c1dc77bb78bee91df2"
|
|
41
|
+
}
|
|
Binary file
|
package/public/reset.css
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* http://meyerweb.com/eric/tools/css/reset/
|
|
2
|
+
v2.0 | 20110126
|
|
3
|
+
License: none (public domain)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
html, body, div, span, applet, object, iframe,
|
|
7
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
|
8
|
+
a, abbr, acronym, address, big, cite, code,
|
|
9
|
+
del, dfn, em, img, ins, kbd, q, s, samp,
|
|
10
|
+
small, strike, strong, sub, sup, tt, var,
|
|
11
|
+
b, u, i, center,
|
|
12
|
+
dl, dt, dd, ol, ul, li,
|
|
13
|
+
fieldset, form, label, legend,
|
|
14
|
+
table, caption, tbody, tfoot, thead, tr, th, td,
|
|
15
|
+
article, aside, canvas, details, embed,
|
|
16
|
+
figure, figcaption, footer, header, hgroup,
|
|
17
|
+
menu, nav, output, ruby, section, summary,
|
|
18
|
+
time, mark, audio, video {
|
|
19
|
+
margin: 0;
|
|
20
|
+
padding: 0;
|
|
21
|
+
border: 0;
|
|
22
|
+
font-size: 100%;
|
|
23
|
+
font: inherit;
|
|
24
|
+
vertical-align: baseline;
|
|
25
|
+
}
|
|
26
|
+
/* HTML5 display-role reset for older browsers */
|
|
27
|
+
article, aside, details, figcaption, figure,
|
|
28
|
+
footer, header, hgroup, menu, nav, section {
|
|
29
|
+
display: block;
|
|
30
|
+
}
|
|
31
|
+
body {
|
|
32
|
+
line-height: 1;
|
|
33
|
+
}
|
|
34
|
+
ol, ul {
|
|
35
|
+
list-style: none;
|
|
36
|
+
}
|
|
37
|
+
blockquote, q {
|
|
38
|
+
quotes: none;
|
|
39
|
+
}
|
|
40
|
+
blockquote:before, blockquote:after,
|
|
41
|
+
q:before, q:after {
|
|
42
|
+
content: '';
|
|
43
|
+
content: none;
|
|
44
|
+
}
|
|
45
|
+
table {
|
|
46
|
+
border-collapse: collapse;
|
|
47
|
+
border-spacing: 0;
|
|
48
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import svelte from 'rollup-plugin-svelte';
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
4
|
+
import serve from 'rollup-plugin-dev-server';
|
|
5
|
+
import livereload from 'rollup-plugin-livereload';
|
|
6
|
+
import { terser } from 'rollup-plugin-terser';
|
|
7
|
+
import sveltePreprocess from 'svelte-preprocess';
|
|
8
|
+
import typescript from '@rollup/plugin-typescript';
|
|
9
|
+
import image from '@rollup/plugin-image';
|
|
10
|
+
const production = process.env.NODE_ENV === 'production';
|
|
11
|
+
const dev = process.env.NODE_ENV === 'development';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
input: 'src/index.ts',
|
|
15
|
+
output: {
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
format: 'umd',
|
|
18
|
+
name: 'app',
|
|
19
|
+
file: 'dist/casino-tournaments-slider-controller.js'
|
|
20
|
+
},
|
|
21
|
+
plugins: [
|
|
22
|
+
svelte({
|
|
23
|
+
preprocess: sveltePreprocess(),
|
|
24
|
+
compilerOptions: {
|
|
25
|
+
// enable run-time checks when not in production
|
|
26
|
+
customElement: true,
|
|
27
|
+
dev: !production
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
image(),
|
|
31
|
+
commonjs(),
|
|
32
|
+
resolve({
|
|
33
|
+
browser: true,
|
|
34
|
+
dedupe: ['svelte']
|
|
35
|
+
}),
|
|
36
|
+
dev && serve({
|
|
37
|
+
open: true,
|
|
38
|
+
verbose: true,
|
|
39
|
+
allowCrossOrigin: true,
|
|
40
|
+
historyApiFallback: false,
|
|
41
|
+
host: 'localhost',
|
|
42
|
+
port: 5050,
|
|
43
|
+
}),
|
|
44
|
+
dev && livereload({ watch: ['', 'dist'] }),
|
|
45
|
+
typescript({
|
|
46
|
+
sourceMap: !production,
|
|
47
|
+
inlineSources: !production,
|
|
48
|
+
}),
|
|
49
|
+
// If we're building for production (npm run build
|
|
50
|
+
// instead of npm run dev), minify
|
|
51
|
+
production &&
|
|
52
|
+
terser({
|
|
53
|
+
output: {
|
|
54
|
+
comments: "all"
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
],
|
|
58
|
+
watch: {
|
|
59
|
+
clearScreen: false
|
|
60
|
+
}
|
|
61
|
+
};
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
<svelte:options tag={null} />
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import {onMount} from "svelte";
|
|
4
|
+
import { getDevice } from 'rvhelper';
|
|
5
|
+
import { _, addNewMessages, setLocale, setupI18n } from './i18n';
|
|
6
|
+
import { TournamentsSliderTranslations } from './translations';
|
|
7
|
+
import { EventSourcePolyfill } from 'event-source-polyfill';
|
|
8
|
+
|
|
9
|
+
import "@everymatrix/casino-tournaments-rank";
|
|
10
|
+
|
|
11
|
+
export let session:string = '';
|
|
12
|
+
export let endpoint:string = '';
|
|
13
|
+
export let lang:string = 'en';
|
|
14
|
+
export let tournamentsshownnumber:number=5;
|
|
15
|
+
|
|
16
|
+
const sortByStatus:string = '""|type1';
|
|
17
|
+
let userAgent:string = window.navigator.userAgent;
|
|
18
|
+
let tournamentList:any =[];
|
|
19
|
+
let currentTournament:any;
|
|
20
|
+
let currentTournamentIdx:number = 0;
|
|
21
|
+
let isFirst:boolean = true;
|
|
22
|
+
let isLast:boolean = false;
|
|
23
|
+
let isLoading:boolean = false;
|
|
24
|
+
let isLoggedIn:boolean =false;
|
|
25
|
+
let sessionID:string;
|
|
26
|
+
let tournamentsUpdateEventSource:any;
|
|
27
|
+
|
|
28
|
+
let tourSlider:HTMLElement;
|
|
29
|
+
let xDown:any = null;
|
|
30
|
+
let yDown:any = null;
|
|
31
|
+
|
|
32
|
+
setupI18n({ withLocale: 'en', translations: {}});
|
|
33
|
+
Object.keys(TournamentsSliderTranslations).forEach((item) => {
|
|
34
|
+
addNewMessages(item, TournamentsSliderTranslations[item]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const messageHandler = (e:any)=>{
|
|
38
|
+
if(!e.data){
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if(e.data.type == 'TournamentList'){
|
|
43
|
+
tournamentList = e.data.tournamentList;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
const setSession = () => {
|
|
48
|
+
if (session.length > 0 && session != 'false') {
|
|
49
|
+
isLoggedIn = true;
|
|
50
|
+
isLoading = true;
|
|
51
|
+
sessionID = session;
|
|
52
|
+
} else {
|
|
53
|
+
isLoggedIn = false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const setActiveLanguage = ():void => {
|
|
57
|
+
setLocale(lang);
|
|
58
|
+
}
|
|
59
|
+
const slideTo = (idxTo) =>{
|
|
60
|
+
if(idxTo > 0 && isLast || (idxTo < 0 && isFirst)){
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
currentTournamentIdx = currentTournamentIdx+ idxTo;
|
|
64
|
+
}
|
|
65
|
+
const transformTournamentItem = (item:any)=>{
|
|
66
|
+
let briefTournament = {
|
|
67
|
+
id: item.tournament.id,
|
|
68
|
+
name: item.tournament.nameOrTitle,
|
|
69
|
+
rank: item.leaderBoard ? item.leaderBoard.rank : '-',
|
|
70
|
+
overallRank: item.endRank,
|
|
71
|
+
prize: item.leaderBoard && item.leaderBoard.prizeName ? item.leaderBoard.prizeName : '-'
|
|
72
|
+
};
|
|
73
|
+
return briefTournament;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const detailsAction = (tournamentId:any) => {
|
|
77
|
+
window.postMessage({ type: 'MyTournamentFromNavClicked', tournamentid: tournamentId, showLeaderboard: true}, window.location.href);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const setTournamentsSearchParams = (urlSearchParams: URLSearchParams, offset:number, limit:number)=>{
|
|
81
|
+
urlSearchParams.append('pagination', `offset=${offset},limit=${limit}`);
|
|
82
|
+
urlSearchParams.append('sortField', 'StartTime');
|
|
83
|
+
urlSearchParams.append('sortOrder', 'desc');
|
|
84
|
+
urlSearchParams.append('fields', 'id,nameOrTitle,state');
|
|
85
|
+
urlSearchParams.append('language', lang);
|
|
86
|
+
urlSearchParams.append('filter', `state=Running`);
|
|
87
|
+
return urlSearchParams;
|
|
88
|
+
}
|
|
89
|
+
const tournamentsUpdateMessageHandler = (message:any)=>{
|
|
90
|
+
if(!message.data){
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
try{
|
|
94
|
+
let messageData:any = message.data;
|
|
95
|
+
let updateInfo:any = JSON.parse(messageData);
|
|
96
|
+
let newTournamentList = [];
|
|
97
|
+
if(updateInfo.messageType=='PlayerLeaderBoardsUpdate' && updateInfo.items){
|
|
98
|
+
updateInfo.items.forEach((item:any, idx: number)=>{
|
|
99
|
+
let briefTournamentInfo = transformTournamentItem(item);
|
|
100
|
+
if(currentTournament && currentTournament.id == briefTournamentInfo.id && currentTournament.rank != briefTournamentInfo.rank){
|
|
101
|
+
window.postMessage({type: `TournamentRankInfo_${briefTournamentInfo.id}}`, rankInfo:{
|
|
102
|
+
rank: briefTournamentInfo.rank,
|
|
103
|
+
overallRank: briefTournamentInfo.overallRank,
|
|
104
|
+
prize: briefTournamentInfo.prize
|
|
105
|
+
}});
|
|
106
|
+
}
|
|
107
|
+
newTournamentList.push(briefTournamentInfo);
|
|
108
|
+
})
|
|
109
|
+
tournamentList = newTournamentList;
|
|
110
|
+
if(currentTournamentIdx >= updateInfo.items.length ){
|
|
111
|
+
currentTournamentIdx = updateInfo.items.length - 1;
|
|
112
|
+
}
|
|
113
|
+
currentTournament = newTournamentList[currentTournamentIdx];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if(updateInfo.messageType=='PlayerLeaderBoardUpdate' && updateInfo.item){
|
|
117
|
+
let briefTournamentInfo = transformTournamentItem(updateInfo.item);
|
|
118
|
+
let tournamentIdx = tournamentList.findIndex((item)=>{
|
|
119
|
+
return item.id == briefTournamentInfo.id;
|
|
120
|
+
})
|
|
121
|
+
if(currentTournamentIdx == tournamentIdx){
|
|
122
|
+
window.postMessage({type: `TournamentRankInfo_${briefTournamentInfo.id}}`, rankInfo:{
|
|
123
|
+
rank: briefTournamentInfo.rank,
|
|
124
|
+
overallRank: briefTournamentInfo.overallRank,
|
|
125
|
+
prize: briefTournamentInfo.prize
|
|
126
|
+
}});
|
|
127
|
+
}
|
|
128
|
+
tournamentList[tournamentIdx] = briefTournamentInfo;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
}catch(err){
|
|
132
|
+
console.log(err);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const getTouches = (evt:any) => {
|
|
138
|
+
return evt.touches || evt.originalEvent.touches;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const handleTouchStart = (evt:any) => {
|
|
142
|
+
const firstTouch = getTouches(evt)[0];
|
|
143
|
+
|
|
144
|
+
xDown = firstTouch.clientX;
|
|
145
|
+
yDown = firstTouch.clientY;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const handleTouchMove = (evt:any) => {
|
|
149
|
+
if (!xDown || !yDown) return;
|
|
150
|
+
|
|
151
|
+
let xUp = evt.touches[0].clientX;
|
|
152
|
+
let yUp = evt.touches[0].clientY;
|
|
153
|
+
|
|
154
|
+
let xDiff = xDown - xUp;
|
|
155
|
+
let yDiff = yDown - yUp;
|
|
156
|
+
|
|
157
|
+
if (Math.abs(xDiff) > Math.abs(yDiff)) {
|
|
158
|
+
if (xDiff > 0) {
|
|
159
|
+
slideTo(1);
|
|
160
|
+
} else {
|
|
161
|
+
slideTo(-1);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
xDown = null;
|
|
166
|
+
yDown = null;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const addEventListeners = () => {
|
|
170
|
+
tourSlider.addEventListener('touchstart', handleTouchStart, {passive: true});
|
|
171
|
+
tourSlider.addEventListener('touchmove', handleTouchMove, {passive: true});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const startupUpdateListener=()=>{
|
|
175
|
+
if(!endpoint){
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
let tournamentsUrl:URL = new URL(`${endpoint}/tournaments/leaderboard/player/updates?XSessionId=${session}`);
|
|
179
|
+
setTournamentsSearchParams(tournamentsUrl.searchParams, 0, tournamentsshownnumber);
|
|
180
|
+
if(!EventSource){
|
|
181
|
+
tournamentsUpdateEventSource = new EventSourcePolyfill(tournamentsUrl.href, {headers: {'accept': 'text/event-stream'}});
|
|
182
|
+
}else{
|
|
183
|
+
tournamentsUpdateEventSource = new EventSource(tournamentsUrl.href);
|
|
184
|
+
}
|
|
185
|
+
if(typeof(tournamentsUpdateEventSource) != "undefined"){
|
|
186
|
+
tournamentsUpdateEventSource.addEventListener('message', tournamentsUpdateMessageHandler);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const resetSliderListener= ()=>{
|
|
190
|
+
if(!tournamentsUpdateEventSource){
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
tournamentsUpdateEventSource.removeEventListener('message', tournamentsUpdateMessageHandler);
|
|
194
|
+
tournamentsUpdateEventSource.close();
|
|
195
|
+
startupUpdateListener();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
onMount(()=>{
|
|
200
|
+
startupUpdateListener();
|
|
201
|
+
window.addEventListener("message", messageHandler, false);
|
|
202
|
+
return ()=>{
|
|
203
|
+
window.removeEventListener("message", messageHandler);
|
|
204
|
+
if( tournamentsUpdateEventSource){
|
|
205
|
+
tournamentsUpdateEventSource.removeEventListener('message', tournamentsUpdateMessageHandler);
|
|
206
|
+
}
|
|
207
|
+
tourSlider.removeEventListener('touchstart', handleTouchStart);
|
|
208
|
+
tourSlider.removeEventListener('touchmove', handleTouchMove);
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
$: endpoint && startupUpdateListener();
|
|
212
|
+
$: tourSlider && addEventListeners();
|
|
213
|
+
$: session && setSession();
|
|
214
|
+
$: lang && setActiveLanguage();
|
|
215
|
+
$: currentTournament = tournamentList[currentTournamentIdx];
|
|
216
|
+
$: isLast = currentTournamentIdx == tournamentList.length - 1;
|
|
217
|
+
$: isFirst = currentTournamentIdx == 0;
|
|
218
|
+
$: tournamentsshownnumber && lang && resetSliderListener();
|
|
219
|
+
</script>
|
|
220
|
+
|
|
221
|
+
<div part="Tournaments" class="casino-tournaments-slider-controller" bind:this={tourSlider}>
|
|
222
|
+
<div part="Tournaments_ArrowLeft" class="ArrowLeft {isFirst ? 'Disabled':''}" on:click="{()=>slideTo(-1)}">
|
|
223
|
+
<svg width="6" height="10" viewBox="0 0 6 10" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
224
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.861997 5.75848L0 4.89648L4.30998 0.586501L5.17198 1.4485L1.7241 4.89638L5.17255 8.34484L4.31055 9.20683L0.862099 5.75838L0.861997 5.75848Z"/>
|
|
225
|
+
</svg>
|
|
226
|
+
</div>
|
|
227
|
+
{#if (!tournamentList )}
|
|
228
|
+
<div part="TournamentLoading" class="TournamentInfo SearchLoading" style="height: 200px">
|
|
229
|
+
<div part="TournamentInfo_Name" class="name"><span part="TournamentInfo_Name_link" >{$_(`tournamentsSlider.loading`)}</span></div>
|
|
230
|
+
<div part="TournamentInfo_Rank" class="rank">
|
|
231
|
+
<casino-tournaments-rank displayin="col" showicon="false" userrank="-" prize='-' overallrank="-" tournamentid=""></casino-tournaments-rank>
|
|
232
|
+
</div>
|
|
233
|
+
<div part="TournamentInfo_Points" class="circle">
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
{/if}
|
|
237
|
+
{#if (tournamentList && tournamentList.length > 0)}
|
|
238
|
+
<div part="TournamentInfo" class="TournamentInfo">
|
|
239
|
+
<div part="TournamentInfo_Name" class="name"><span part="TournamentInfo_Name_link" on:click={() => detailsAction(currentTournament.id)}>{currentTournament.name}</span></div>
|
|
240
|
+
<div part="TournamentInfo_Rank" class="rank">
|
|
241
|
+
<casino-tournaments-rank displayin="col" showicon="false" userrank="{currentTournament.rank}"
|
|
242
|
+
prize='{currentTournament.prize}' overallrank="{currentTournament.overallRank}"
|
|
243
|
+
tournamentid="{currentTournament.id}"></casino-tournaments-rank>
|
|
244
|
+
</div>
|
|
245
|
+
<div part="TournamentInfo_Points" class="circle">
|
|
246
|
+
{#each tournamentList as item, idx}
|
|
247
|
+
<svg class="{currentTournamentIdx == idx ? 'active' : ''}" width="6" height="5" viewBox="0 0 6 5" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
248
|
+
<circle cx="2.77888" cy="2.50837" r="2.28571" fill="currentColor" stroke="currentColor" />
|
|
249
|
+
</svg>
|
|
250
|
+
{/each}
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
{/if}
|
|
254
|
+
<div part="Tournaments_ArrowRight" class="ArrowRight {isLast ? 'Disabled':''}" on:click="{()=>slideTo(1)}">
|
|
255
|
+
<svg width="6" height="10" fill="currentColor" viewBox="0 0 6 10" xmlns="http://www.w3.org/2000/svg">
|
|
256
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.93488 5.75848L5.79688 4.89648L1.48689 0.586501L0.624894 1.4485L4.07278 4.89638L0.624326 8.34484L1.48632 9.20683L4.93478 5.75838L4.93488 5.75848Z"/>
|
|
257
|
+
</svg>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
|
|
261
|
+
<style lang="scss">
|
|
262
|
+
::host{
|
|
263
|
+
}
|
|
264
|
+
.casino-tournaments-slider-controller {
|
|
265
|
+
position: relative;
|
|
266
|
+
width: 100%;
|
|
267
|
+
background: #212223;
|
|
268
|
+
color: #fff;
|
|
269
|
+
display: inline-flex;
|
|
270
|
+
padding: 10px 5px;
|
|
271
|
+
border: 1px solid #ff8364;
|
|
272
|
+
border-radius: 5px;
|
|
273
|
+
min-height: 70px;
|
|
274
|
+
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,.5);
|
|
275
|
+
}
|
|
276
|
+
.TournamentInfo{
|
|
277
|
+
width: calc(100% - 4px);
|
|
278
|
+
padding: 2px;
|
|
279
|
+
.name{
|
|
280
|
+
white-space: nowrap;
|
|
281
|
+
overflow: auto;
|
|
282
|
+
width: 99%;
|
|
283
|
+
text-align: center;
|
|
284
|
+
text-transform: capitalize;
|
|
285
|
+
font-size: 0.8rem;
|
|
286
|
+
margin-bottom: 5px;
|
|
287
|
+
cursor: pointer;
|
|
288
|
+
}
|
|
289
|
+
.circle{text-align: center; height: 7px;
|
|
290
|
+
height: 5px;
|
|
291
|
+
margin-top: 3px;
|
|
292
|
+
svg{color: #C4C4C4; margin: 0 2px; vertical-align: top; margin-top: 3px;}
|
|
293
|
+
svg.active{color: white}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
.ArrowLeft{
|
|
297
|
+
left: 1px;
|
|
298
|
+
}
|
|
299
|
+
.ArrowRight{
|
|
300
|
+
right: 1px;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.ArrowLeft, .ArrowRight{
|
|
304
|
+
&.Disabled svg{color: darkgrey}
|
|
305
|
+
position: absolute;
|
|
306
|
+
cursor: pointer;
|
|
307
|
+
top: calc(50% - 7px);
|
|
308
|
+
svg{
|
|
309
|
+
vertical-align: middle;
|
|
310
|
+
width: 11px;
|
|
311
|
+
height: 11px;
|
|
312
|
+
color: #FF8364;
|
|
313
|
+
}
|
|
314
|
+
margin: 0px;
|
|
315
|
+
display: flex;
|
|
316
|
+
width: 7px;
|
|
317
|
+
}
|
|
318
|
+
casino-tournaments-rank::part(Rank), casino-tournaments-rank::part(Prize){
|
|
319
|
+
background-color: transparent;
|
|
320
|
+
padding: 0px;
|
|
321
|
+
margin: 0px;
|
|
322
|
+
line-height: 14px;
|
|
323
|
+
}
|
|
324
|
+
casino-tournaments-rank::part(RankText), casino-tournaments-rank::part(PrizeText){
|
|
325
|
+
line-height: 16px;
|
|
326
|
+
margin: auto;
|
|
327
|
+
}
|
|
328
|
+
casino-tournaments-rank::part(Rank_Arror_UP), casino-tournaments-rank::part(Rank_Arror_Down){
|
|
329
|
+
padding: 0px 3px;
|
|
330
|
+
}
|
|
331
|
+
casino-tournaments-rank::part(PrizeText){
|
|
332
|
+
font-weight: normal;
|
|
333
|
+
}
|
|
334
|
+
casino-tournaments-rank::part(Rank){
|
|
335
|
+
color: #ff8364;
|
|
336
|
+
font-size: 0.75rem;
|
|
337
|
+
}
|
|
338
|
+
casino-tournaments-rank::part(Prize){
|
|
339
|
+
color: #fdd500;
|
|
340
|
+
font-size: 0.7rem;
|
|
341
|
+
}
|
|
342
|
+
</style>
|
package/src/i18n.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dictionary,
|
|
3
|
+
locale,
|
|
4
|
+
addMessages,
|
|
5
|
+
_
|
|
6
|
+
} from 'svelte-i18n';
|
|
7
|
+
|
|
8
|
+
function setupI18n({ withLocale: _locale, translations }) {
|
|
9
|
+
locale.subscribe((data) => {
|
|
10
|
+
if (data == null) {
|
|
11
|
+
dictionary.set(translations);
|
|
12
|
+
locale.set(_locale);
|
|
13
|
+
}
|
|
14
|
+
}); // maybe we will need this to make sure that the i18n is set up only once
|
|
15
|
+
/*dictionary.set(translations);
|
|
16
|
+
locale.set(_locale);*/
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function addNewMessages(lang, dict) {
|
|
20
|
+
addMessages(lang, dict);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function setLocale(_locale) {
|
|
24
|
+
locale.set(_locale);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { _, setupI18n, addNewMessages, setLocale };
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import CasinoTournamentsSliderController from './CasinoTournamentsSliderController.svelte';
|
|
2
|
+
|
|
3
|
+
!customElements.get('casino-tournaments-slider-controller') && customElements.define('casino-tournaments-slider-controller', CasinoTournamentsSliderController);
|
|
4
|
+
export default CasinoTournamentsSliderController;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { html } from 'lit-element';
|
|
2
|
+
|
|
3
|
+
import CasinoTournamentsSliderController from '../src/CasinoTournamentsSliderController';
|
|
4
|
+
|
|
5
|
+
// This default export determines where your story goes in the story list
|
|
6
|
+
export default {
|
|
7
|
+
title: 'CasinoTournamentsSliderController',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// 👇 We create a “template” of how args map to rendering
|
|
11
|
+
const CasinoTournamentsSliderController = ({ aProperty }) => html`<casino-tournaments-slider-controller></casino-tournaments-slider-controller>`;
|
|
12
|
+
|
|
13
|
+
export const FirstStory = CasinoTournamentsSliderController.bind({});
|