@everymatrix/casino-tournaments-limited-controller 0.0.292
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-limited-controller.js +8993 -0
- package/dist/casino-tournaments-limited-controller.js.map +1 -0
- package/index.html +40 -0
- package/index.js +1 -0
- package/package.json +40 -0
- package/public/favicon.png +0 -0
- package/public/reset.css +48 -0
- package/rollup.config.js +59 -0
- package/src/CasinoTournamentsLimitedController.svelte +382 -0
- package/src/date.js +25 -0
- package/src/i18n.js +38 -0
- package/src/icon.js +3 -0
- package/src/index.ts +4 -0
- package/src/message.js +97 -0
- package/src/translations.js +57 -0
- package/src/util.js +61 -0
- package/stories/CasinoTournamentsLimitedController.stories.js +13 -0
- package/tsconfig.json +6 -0
package/index.html
ADDED
@@ -0,0 +1,40 @@
|
|
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-limited-controller
|
9
|
+
</title>
|
10
|
+
<link rel="stylesheet" href="public/reset.css">
|
11
|
+
<script src='dist/casino-tournaments-limited-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 {
|
22
|
+
/* padding: 10px 0; */
|
23
|
+
}
|
24
|
+
</style>
|
25
|
+
|
26
|
+
<div class="webcomponent">
|
27
|
+
<casino-tournaments-limited-controller
|
28
|
+
session="a887ca78-e59c-460f-b9d0-9f80acde0a98"
|
29
|
+
userid="3198998"
|
30
|
+
endpoint="https://jetbull-api.stage.norway.everymatrix.com/v1"
|
31
|
+
lang="en"
|
32
|
+
state="Ongoing"
|
33
|
+
states="Scheduled,Ongoing,Finished"
|
34
|
+
filter="PlayerEnrolled=true"
|
35
|
+
>
|
36
|
+
</casino-tournaments-limited-controller>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
</body>
|
40
|
+
</html>
|
package/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
import './dist/casino-tournaments-limited-controller.js';
|
package/package.json
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
"name": "@everymatrix/casino-tournaments-limited-controller",
|
3
|
+
"version": "0.0.292",
|
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
|
+
"cross-env": "^7.0.3",
|
33
|
+
"sirv-cli": "^1.0.0",
|
34
|
+
"svelte": "^3.0.0"
|
35
|
+
},
|
36
|
+
"publishConfig": {
|
37
|
+
"access": "public"
|
38
|
+
},
|
39
|
+
"gitHead": "c69fc04487b15c7c69d2a7c8943340d2a8b78c4f"
|
40
|
+
}
|
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,59 @@
|
|
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
|
+
const production = process.env.NODE_ENV === 'production';
|
10
|
+
const dev = process.env.NODE_ENV === 'development';
|
11
|
+
|
12
|
+
export default {
|
13
|
+
input: 'src/index.ts',
|
14
|
+
output: {
|
15
|
+
sourcemap: true,
|
16
|
+
format: 'umd',
|
17
|
+
name: 'app',
|
18
|
+
file: 'dist/casino-tournaments-limited-controller.js'
|
19
|
+
},
|
20
|
+
plugins: [
|
21
|
+
svelte({
|
22
|
+
preprocess: sveltePreprocess(),
|
23
|
+
compilerOptions: {
|
24
|
+
// enable run-time checks when not in production
|
25
|
+
customElement: true,
|
26
|
+
dev: !production
|
27
|
+
}
|
28
|
+
}),
|
29
|
+
commonjs(),
|
30
|
+
resolve({
|
31
|
+
browser: true,
|
32
|
+
dedupe: ['svelte']
|
33
|
+
}),
|
34
|
+
dev && serve({
|
35
|
+
open: true,
|
36
|
+
verbose: true,
|
37
|
+
allowCrossOrigin: true,
|
38
|
+
historyApiFallback: false,
|
39
|
+
host: 'localhost',
|
40
|
+
port: 5050,
|
41
|
+
}),
|
42
|
+
dev && livereload({ watch: ['', 'dist'] }),
|
43
|
+
typescript({
|
44
|
+
sourceMap: !production,
|
45
|
+
inlineSources: !production,
|
46
|
+
}),
|
47
|
+
// If we're building for production (npm run build
|
48
|
+
// instead of npm run dev), minify
|
49
|
+
production &&
|
50
|
+
terser({
|
51
|
+
output: {
|
52
|
+
comments: "all"
|
53
|
+
},
|
54
|
+
})
|
55
|
+
],
|
56
|
+
watch: {
|
57
|
+
clearScreen: false
|
58
|
+
}
|
59
|
+
};
|
@@ -0,0 +1,382 @@
|
|
1
|
+
<svelte:options tag={null} />
|
2
|
+
|
3
|
+
<script lang="ts">
|
4
|
+
import { onMount } from "svelte";
|
5
|
+
import { formatDate } from './date'
|
6
|
+
import icon from './icon'
|
7
|
+
|
8
|
+
import {
|
9
|
+
_fetch,
|
10
|
+
matchStatusFromApiToView,
|
11
|
+
} from "./util";
|
12
|
+
|
13
|
+
import { setLocale, setLocaleWhenInit, _ } from './i18n'
|
14
|
+
|
15
|
+
import {
|
16
|
+
onMountMessageLifeCycle,
|
17
|
+
updateEventSourceLifeCycle,
|
18
|
+
composeEventSourceMessageHandler,
|
19
|
+
postMessageTabLocaleTextUpdate,
|
20
|
+
postMessageTabTotalUpdate,
|
21
|
+
_postMessage,
|
22
|
+
createEventSource,
|
23
|
+
} from "./message";
|
24
|
+
|
25
|
+
import '@everymatrix/casino-tournaments-tab'
|
26
|
+
|
27
|
+
type State = 'Scheduled' | 'Ongoing' | 'Finished'
|
28
|
+
|
29
|
+
export let endpoint: string = ''
|
30
|
+
export let lang: string = 'en'
|
31
|
+
export let session: string = ''
|
32
|
+
export let state: State | undefined = undefined
|
33
|
+
export let states: string = ''
|
34
|
+
export let filter: string = ''
|
35
|
+
|
36
|
+
let eventSource = undefined
|
37
|
+
let svgSize: number = 0
|
38
|
+
let href = icon
|
39
|
+
|
40
|
+
type Tournament = {
|
41
|
+
id: string
|
42
|
+
nameOrTitle: string
|
43
|
+
endTime: string
|
44
|
+
state: string
|
45
|
+
}
|
46
|
+
|
47
|
+
type TournamentForRendering = {
|
48
|
+
id: string,
|
49
|
+
title: string,
|
50
|
+
rank: string,
|
51
|
+
enddate: string,
|
52
|
+
prize: string,
|
53
|
+
}
|
54
|
+
|
55
|
+
type TournamentsMatrix = {
|
56
|
+
[P in State]?: TournamentForRendering[]
|
57
|
+
}
|
58
|
+
|
59
|
+
let tournamentsMatrix: TournamentsMatrix = {}
|
60
|
+
|
61
|
+
const eventSourceHandler = composeEventSourceMessageHandler({
|
62
|
+
"PlayerLeaderBoardsUpdate": (data) => {
|
63
|
+
let _tournamentsMatrix: TournamentsMatrix = {}
|
64
|
+
__states.map(s => {
|
65
|
+
if(!_tournamentsMatrix[s]){
|
66
|
+
_tournamentsMatrix[s] = []
|
67
|
+
}
|
68
|
+
})
|
69
|
+
|
70
|
+
data.items.map(_item => {
|
71
|
+
|
72
|
+
const { id, nameOrTitle: title, endTime: enddate } = _item.tournament
|
73
|
+
|
74
|
+
const tournamentComposed: TournamentForRendering = {
|
75
|
+
id,
|
76
|
+
title,
|
77
|
+
rank: _item.leaderBoard && `#${_item.leaderBoard.rank}/${_item.endRank}`,
|
78
|
+
enddate,
|
79
|
+
prize: _item.leaderBoard && _item.leaderBoard.prizeName,
|
80
|
+
}
|
81
|
+
|
82
|
+
_tournamentsMatrix[matchStatusFromApiToView(_item.tournament.state)].push(tournamentComposed)
|
83
|
+
})
|
84
|
+
|
85
|
+
tournamentsMatrix = _tournamentsMatrix
|
86
|
+
|
87
|
+
statesNeedSubscribe.map(s => {
|
88
|
+
postMessageTabTotalUpdate(s, tournamentsMatrix[s].length)
|
89
|
+
})
|
90
|
+
|
91
|
+
},
|
92
|
+
'TournamentUpdate': (data) => {
|
93
|
+
if(data.item){
|
94
|
+
const tournament = data.item as Tournament
|
95
|
+
let _state = matchStatusFromApiToView(tournament.state)
|
96
|
+
tournamentsMatrix = {
|
97
|
+
...tournamentsMatrix,
|
98
|
+
[_state]: tournamentsMatrix[_state].map(t => {
|
99
|
+
if(t.id === tournament.id){
|
100
|
+
return {
|
101
|
+
...t,
|
102
|
+
title: tournament.nameOrTitle,
|
103
|
+
enddate: tournament.endTime
|
104
|
+
}
|
105
|
+
}else{
|
106
|
+
return t
|
107
|
+
}
|
108
|
+
})
|
109
|
+
}
|
110
|
+
}
|
111
|
+
},
|
112
|
+
})
|
113
|
+
|
114
|
+
const subscribeApi = async (offset:number, limit:number) => {
|
115
|
+
|
116
|
+
const source = `${endpoint}/tournaments`
|
117
|
+
const url = new URL(source)
|
118
|
+
|
119
|
+
url.searchParams.append('pagination', `offset=${offset},limit=${limit}`);
|
120
|
+
url.searchParams.append('sortField', 'StartTime');
|
121
|
+
url.searchParams.append('sortOrder', 'desc');
|
122
|
+
url.searchParams.append('language', lang);
|
123
|
+
url.searchParams.append('XSessionId', session);
|
124
|
+
|
125
|
+
|
126
|
+
if(filter){
|
127
|
+
url.searchParams.append('filter', filter);
|
128
|
+
}
|
129
|
+
|
130
|
+
eventSource = updateEventSourceLifeCycle(
|
131
|
+
eventSource,
|
132
|
+
createEventSource(`${source}/leaderboard/player/updates?${url.searchParams.toString()}`),
|
133
|
+
eventSourceHandler
|
134
|
+
)
|
135
|
+
}
|
136
|
+
|
137
|
+
// =============== define above, run below =============== \\
|
138
|
+
|
139
|
+
setLocaleWhenInit()
|
140
|
+
|
141
|
+
$: __state = state
|
142
|
+
$: __states = states.split(',') as State[]
|
143
|
+
$: statesNeedSubscribe = __states.filter(s => s !== 'Finished')
|
144
|
+
$: list = tournamentsMatrix[__state]
|
145
|
+
|
146
|
+
const init = () => {
|
147
|
+
subscribeApi(0, 30)
|
148
|
+
|
149
|
+
setLocale(lang)
|
150
|
+
|
151
|
+
postMessageTabLocaleTextUpdate('Scheduled', $_('tournamentsLimitedController.Scheduled'))
|
152
|
+
postMessageTabLocaleTextUpdate('Ongoing', $_('tournamentsLimitedController.Ongoing'))
|
153
|
+
postMessageTabLocaleTextUpdate('Finished', `${$_(`tournamentsLimitedController.Finished`)} (${$_('tournamentsLimitedController.last')} 48h)`)
|
154
|
+
}
|
155
|
+
|
156
|
+
$: endpoint && filter && lang && session && init()
|
157
|
+
|
158
|
+
onMount(() => {
|
159
|
+
return () => {
|
160
|
+
if(eventSource){
|
161
|
+
eventSource.removeEventListener('message', eventSourceHandler);
|
162
|
+
}
|
163
|
+
}
|
164
|
+
})
|
165
|
+
|
166
|
+
onMountMessageLifeCycle({
|
167
|
+
TournamentsTabSwitch: async (data) => __state = data.tab
|
168
|
+
})
|
169
|
+
|
170
|
+
</script>
|
171
|
+
|
172
|
+
<div class="casino-tournaments-limited-controller">
|
173
|
+
|
174
|
+
<div class="top-wrapper">
|
175
|
+
<div class="svg" bind:clientWidth={svgSize}>
|
176
|
+
<svg width={svgSize} height={svgSize} viewBox={`0 0 ${svgSize} ${svgSize}`} fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
177
|
+
<rect width={svgSize} height={svgSize} fill="url(#pattern0)"/>
|
178
|
+
<defs>
|
179
|
+
<pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
|
180
|
+
<use xlink:href="#image0_2606_356" transform="scale(0.00195312)"/>
|
181
|
+
</pattern>
|
182
|
+
{#if href}
|
183
|
+
<image
|
184
|
+
id="image0_2606_356"
|
185
|
+
width="512"
|
186
|
+
height="512"
|
187
|
+
xlink:href={href}
|
188
|
+
/>
|
189
|
+
{/if}
|
190
|
+
</defs>
|
191
|
+
</svg>
|
192
|
+
</div>
|
193
|
+
|
194
|
+
<div class="text">
|
195
|
+
{$_('tournamentsLimitedController.myTournaments')}
|
196
|
+
</div>
|
197
|
+
|
198
|
+
<div class="CloseButton" part="CloseButton"
|
199
|
+
on:click='{
|
200
|
+
()=>window.postMessage({ type: 'OnCloseThumbnail' }, window.location.href)
|
201
|
+
}'
|
202
|
+
>X</div>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<section>
|
206
|
+
<casino-tournaments-tab
|
207
|
+
tabs={states}
|
208
|
+
tab={state}
|
209
|
+
/>
|
210
|
+
|
211
|
+
<div class='list header'>
|
212
|
+
{#each [
|
213
|
+
$_('tournamentsLimitedController.name'),
|
214
|
+
$_('tournamentsLimitedController.rank'),
|
215
|
+
$_('tournamentsLimitedController.enddate'),
|
216
|
+
$_('tournamentsLimitedController.prize')
|
217
|
+
] as item}
|
218
|
+
<div>{item}</div>
|
219
|
+
{/each}
|
220
|
+
</div>
|
221
|
+
|
222
|
+
{#if list}
|
223
|
+
{#each list as item, i}
|
224
|
+
|
225
|
+
<div class='list'>
|
226
|
+
{#if item}
|
227
|
+
{#each Object.keys(item).filter(_key => _key !== 'id') as key, i}
|
228
|
+
|
229
|
+
<div class={key}>
|
230
|
+
{#if item[key]}
|
231
|
+
|
232
|
+
{#if key === 'title'}
|
233
|
+
<span on:click={() => {
|
234
|
+
window.postMessage({
|
235
|
+
type: 'MyTournamentFromNavClicked',
|
236
|
+
tournamentId: item.id,
|
237
|
+
showLeaderboard: true
|
238
|
+
}, window.location.href)
|
239
|
+
}}>
|
240
|
+
{item.title}
|
241
|
+
</span>
|
242
|
+
{/if}
|
243
|
+
|
244
|
+
{#if key === 'enddate'}
|
245
|
+
{formatDate(item.enddate)}
|
246
|
+
{/if}
|
247
|
+
{/if}
|
248
|
+
|
249
|
+
{#if key === 'rank'}
|
250
|
+
<span class={item.prize ? "prize-active" : ''}>{item.rank || ' -'}</span>
|
251
|
+
{/if}
|
252
|
+
|
253
|
+
{#if key === 'prize'}
|
254
|
+
<span class={item.prize ? "prize-active" : ''}>{item.prize || ' -'}</span>
|
255
|
+
{/if}
|
256
|
+
</div>
|
257
|
+
{/each}
|
258
|
+
{/if}
|
259
|
+
</div>
|
260
|
+
{/each}
|
261
|
+
{/if}
|
262
|
+
</section>
|
263
|
+
</div>
|
264
|
+
|
265
|
+
<style lang="scss">
|
266
|
+
:host {
|
267
|
+
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
|
268
|
+
}
|
269
|
+
|
270
|
+
*,
|
271
|
+
*::before,
|
272
|
+
*::after {
|
273
|
+
margin: 0;
|
274
|
+
padding: 0;
|
275
|
+
list-style: none;
|
276
|
+
text-decoration: none;
|
277
|
+
outline: none;
|
278
|
+
box-sizing: border-box;
|
279
|
+
}
|
280
|
+
|
281
|
+
$vw_base: 320px;
|
282
|
+
@function vw($px) {
|
283
|
+
@return ($px / $vw_base) * 100vw;
|
284
|
+
}
|
285
|
+
|
286
|
+
.CloseButton {
|
287
|
+
position: absolute;
|
288
|
+
right: vw(5px);
|
289
|
+
font-size: vw(11px);
|
290
|
+
color: #FFFFFF;
|
291
|
+
cursor: pointer
|
292
|
+
}
|
293
|
+
|
294
|
+
.casino-tournaments-limited-controller {
|
295
|
+
background: #282828;
|
296
|
+
|
297
|
+
.top-wrapper {
|
298
|
+
padding: vw(6px);
|
299
|
+
display: flex;
|
300
|
+
background: #333333;
|
301
|
+
|
302
|
+
.svg {
|
303
|
+
& {
|
304
|
+
width: vw(35px);
|
305
|
+
height: vw(35px);
|
306
|
+
}
|
307
|
+
}
|
308
|
+
|
309
|
+
.text {
|
310
|
+
color: white;
|
311
|
+
font-size: vw(16px);
|
312
|
+
padding-left: vw(10px);
|
313
|
+
font-weight: bold;
|
314
|
+
line-height: vw(19px);
|
315
|
+
padding-top: vw(7px);
|
316
|
+
}
|
317
|
+
}
|
318
|
+
|
319
|
+
section {
|
320
|
+
padding: 0 vw(12px);
|
321
|
+
|
322
|
+
}
|
323
|
+
|
324
|
+
.list {
|
325
|
+
|
326
|
+
&.header {
|
327
|
+
background: #1C1C1C;
|
328
|
+
div {
|
329
|
+
color: #F7F7F7;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
333
|
+
display: flex;
|
334
|
+
align-items: center;
|
335
|
+
font-size: vw(12px);
|
336
|
+
|
337
|
+
@import url('https://rsms.me/inter/inter.css');
|
338
|
+
div { font: initial; font-family: 'Inter', sans-serif; }
|
339
|
+
@supports (font-variation-settings: normal) {
|
340
|
+
div { font: initial; font-family: 'Inter var', sans-serif; }
|
341
|
+
}
|
342
|
+
|
343
|
+
div {
|
344
|
+
display: flex;
|
345
|
+
padding: vw(8px) vw(6.45px);
|
346
|
+
// text-align: center;
|
347
|
+
word-break: break-word;
|
348
|
+
font-size: vw(12px) !important;
|
349
|
+
color: #B5B5B5;
|
350
|
+
|
351
|
+
&:nth-child(1) {
|
352
|
+
flex: 0 0 25%;
|
353
|
+
}
|
354
|
+
|
355
|
+
&:nth-child(2) {
|
356
|
+
flex: 0 0 25%;
|
357
|
+
}
|
358
|
+
|
359
|
+
&:nth-child(3) {
|
360
|
+
flex: 0 0 25%;
|
361
|
+
}
|
362
|
+
|
363
|
+
&:nth-child(4) {
|
364
|
+
flex: 0 0 25%;
|
365
|
+
}
|
366
|
+
|
367
|
+
&.title span {
|
368
|
+
color: #FF8364;
|
369
|
+
text-decoration-line: underline;
|
370
|
+
|
371
|
+
&:active {
|
372
|
+
opacity: 0.6;
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
.prize-active {
|
377
|
+
color: #FFD700;
|
378
|
+
}
|
379
|
+
}
|
380
|
+
}
|
381
|
+
}
|
382
|
+
</style>
|
package/src/date.js
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
function padTo2Digits(num) {
|
2
|
+
return num.toString().padStart(2, '0');
|
3
|
+
}
|
4
|
+
|
5
|
+
export function formatDate(date) {
|
6
|
+
|
7
|
+
const _date = new Date(date)
|
8
|
+
|
9
|
+
let str = ''
|
10
|
+
|
11
|
+
str += [
|
12
|
+
padTo2Digits(_date.getDate()),
|
13
|
+
padTo2Digits(_date.getMonth() + 1),
|
14
|
+
_date.getFullYear() % 100,
|
15
|
+
].join('.')
|
16
|
+
str += '\n'
|
17
|
+
str += [
|
18
|
+
padTo2Digits(_date.getHours()),
|
19
|
+
padTo2Digits(_date.getMinutes()),
|
20
|
+
].join(':')
|
21
|
+
str += ' '
|
22
|
+
str += _date.getHours() >= 12 ? 'PM' : 'AM'
|
23
|
+
|
24
|
+
return str
|
25
|
+
}
|
package/src/i18n.js
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
import {
|
2
|
+
dictionary,
|
3
|
+
locale,
|
4
|
+
addMessages,
|
5
|
+
_
|
6
|
+
} from 'svelte-i18n';
|
7
|
+
|
8
|
+
import { translations } from './translations'
|
9
|
+
|
10
|
+
function setupI18n({ withLocale: _locale, translations }) {
|
11
|
+
locale.subscribe((data) => {
|
12
|
+
if (data == null) {
|
13
|
+
dictionary.set(translations);
|
14
|
+
locale.set(_locale);
|
15
|
+
}
|
16
|
+
}); // maybe we will need this to make sure that the i18n is set up only once
|
17
|
+
/*dictionary.set(translations);
|
18
|
+
locale.set(_locale);*/
|
19
|
+
}
|
20
|
+
|
21
|
+
function addNewMessages(lang, dict) {
|
22
|
+
addMessages(lang, dict);
|
23
|
+
}
|
24
|
+
|
25
|
+
function setLocale(_locale) {
|
26
|
+
locale.set(_locale);
|
27
|
+
}
|
28
|
+
|
29
|
+
const setLocaleWhenInit = () => {
|
30
|
+
|
31
|
+
setupI18n({ withLocale: 'en', translations: {}});
|
32
|
+
|
33
|
+
Object.keys(translations).forEach((item) => {
|
34
|
+
addNewMessages(item, translations[item]);
|
35
|
+
});
|
36
|
+
}
|
37
|
+
|
38
|
+
export { _, setupI18n, addNewMessages, setLocale, setLocaleWhenInit };
|