@everymatrix/casino-search 0.0.343
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-search.js +16014 -0
- package/dist/casino-search.js.map +1 -0
- package/index.html +100 -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/CasinoSearch.svelte +402 -0
- package/src/i18n.js +27 -0
- package/src/index.ts +4 -0
- package/src/translations.js +167 -0
- package/stories/CasinoSearch.stories.js +13 -0
- package/tsconfig.json +6 -0
package/index.html
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
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>casino-search</title>
|
|
8
|
+
<link rel="stylesheet" href="public/reset.css" />
|
|
9
|
+
<script src="dist/casino-search.js"></script>
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
<body>
|
|
13
|
+
<style>
|
|
14
|
+
html,
|
|
15
|
+
body {
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
height: 100%;
|
|
19
|
+
font-family: "Helvetica Neue", "Helvetica", sans-serif;
|
|
20
|
+
}
|
|
21
|
+
.header {
|
|
22
|
+
display: flex;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
align-items: center;
|
|
25
|
+
padding: 10px 20px;
|
|
26
|
+
margin-bottom: 20px;
|
|
27
|
+
background: #252a31;
|
|
28
|
+
box-shadow: 3px 4px 5px 0px rgba(0, 0, 0, 0.2);
|
|
29
|
+
}
|
|
30
|
+
.header__logo svg {
|
|
31
|
+
height: 50px;
|
|
32
|
+
width: 50px;
|
|
33
|
+
margin-right: 5px;
|
|
34
|
+
}
|
|
35
|
+
.header__name {
|
|
36
|
+
color: #fff;
|
|
37
|
+
}
|
|
38
|
+
.header__name span {
|
|
39
|
+
margin-right: 10px;
|
|
40
|
+
font-weight: bold;
|
|
41
|
+
}
|
|
42
|
+
.webcomponent {
|
|
43
|
+
padding: 10px 20px;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
46
|
+
<header class="header">
|
|
47
|
+
<div class="header__logo">
|
|
48
|
+
<svg
|
|
49
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
50
|
+
width="161"
|
|
51
|
+
height="132"
|
|
52
|
+
viewBox="0 0 161 132"
|
|
53
|
+
>
|
|
54
|
+
<defs>
|
|
55
|
+
<linearGradient x1="0%" y1="50%" y2="50%" id="a">
|
|
56
|
+
<stop stop-color="#2A3B8F" offset="0%" />
|
|
57
|
+
<stop stop-color="#29ABE2" offset="100%" />
|
|
58
|
+
</linearGradient>
|
|
59
|
+
<linearGradient x1="100%" y1="50%" x2="0%" y2="50%" id="c">
|
|
60
|
+
<stop stop-color="#B4D44E" offset="0%" />
|
|
61
|
+
<stop stop-color="#E7F716" offset="100%" />
|
|
62
|
+
</linearGradient>
|
|
63
|
+
</defs>
|
|
64
|
+
<g fill="none" fill-rule="evenodd">
|
|
65
|
+
<path
|
|
66
|
+
fill="#166DA5"
|
|
67
|
+
d="M160.6 65.9l-17.4 29.3-24.4-29.7 24.4-28.9z"
|
|
68
|
+
/>
|
|
69
|
+
<path
|
|
70
|
+
fill="#8FDB69"
|
|
71
|
+
d="M141.3 100.2l-26.5-31.7-15.9 26.6 24.7 36.1z"
|
|
72
|
+
/>
|
|
73
|
+
<path fill="#166DA5" d="M141 31.4l-26.2 31.8-15.9-26.6L123.6.9z" />
|
|
74
|
+
<path
|
|
75
|
+
fill="url(#a)"
|
|
76
|
+
opacity=".95"
|
|
77
|
+
d="M61.1 31.4H141L123.4.7H78.7z M114.8 63.3H159l-15.9-26.8H98.8"
|
|
78
|
+
/>
|
|
79
|
+
<path
|
|
80
|
+
fill="url(#c)"
|
|
81
|
+
opacity=".95"
|
|
82
|
+
d="M141.3 100.3H61l17.6 30.5h45z M114.8 68.4H159l-15.9 26.8H98.8"
|
|
83
|
+
/>
|
|
84
|
+
<path
|
|
85
|
+
fill="#010101"
|
|
86
|
+
d="M78.6 130.8L41 65.8 79.1.8H37.9L.4 65.8l37.5 65z"
|
|
87
|
+
/>
|
|
88
|
+
</g>
|
|
89
|
+
</svg>
|
|
90
|
+
</div>
|
|
91
|
+
<h1 class="header__name"><span>WEBCOMPONENT:</span> casino-search</h1>
|
|
92
|
+
</header>
|
|
93
|
+
|
|
94
|
+
<casino-search
|
|
95
|
+
endpoint="https://demo-api.stage.norway.everymatrix.com/v1"
|
|
96
|
+
datasource="RNG"
|
|
97
|
+
lang="en"
|
|
98
|
+
></casino-search>
|
|
99
|
+
</body>
|
|
100
|
+
</html>
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './dist/casino-search.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@everymatrix/casino-search",
|
|
3
|
+
"version": "0.0.343",
|
|
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": "6be9853b96711372488a485dce3085abe424c8c9"
|
|
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-search.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,402 @@
|
|
|
1
|
+
<svelte:options tag={null} />
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { _, addNewMessages, setLocale } from './i18n';
|
|
5
|
+
import { Translations } from './translations.js';
|
|
6
|
+
import { getDevice } from 'rvhelper';
|
|
7
|
+
import { onMount } from 'svelte';
|
|
8
|
+
|
|
9
|
+
import '@everymatrix/casino-game-thumbnail';
|
|
10
|
+
|
|
11
|
+
export let endpoint:string = '';
|
|
12
|
+
export let datasource:string = '';
|
|
13
|
+
export let lang:string = 'en';
|
|
14
|
+
export let clientstyling:string = '';
|
|
15
|
+
export let clientstylingurl:string = '';
|
|
16
|
+
|
|
17
|
+
let userAgent:any = window.navigator.userAgent;
|
|
18
|
+
let searchArray:Array<any> = [];
|
|
19
|
+
let searchedValues:any = [];
|
|
20
|
+
let gamesCache:Object = {};
|
|
21
|
+
|
|
22
|
+
let searchValue:string = '';
|
|
23
|
+
let searchElement:HTMLElement;
|
|
24
|
+
let searchCancelled:boolean = true;
|
|
25
|
+
let searchActive:boolean = false;
|
|
26
|
+
|
|
27
|
+
let isLoading:boolean = false;
|
|
28
|
+
let customStylingContainer:HTMLElement;
|
|
29
|
+
|
|
30
|
+
Object.keys(Translations).forEach((item:any):void => {
|
|
31
|
+
addNewMessages(item, Translations[item]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const messageHandler = (e:any):void => {
|
|
35
|
+
if (e.data && e.data.type == 'OpenGameFrame') {
|
|
36
|
+
addSearchedItem(e.data.gameId);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const onFocus = ():void => {
|
|
41
|
+
searchCancelled = false;
|
|
42
|
+
searchActive = true;
|
|
43
|
+
|
|
44
|
+
if (endpoint && datasource && lang) {
|
|
45
|
+
if (searchValue.length < 2) {
|
|
46
|
+
let recentSearchedGames = getCookieValue(`searchedGamesWds_casino`);
|
|
47
|
+
let recentSearchedGamesArray:Array<any> = [];
|
|
48
|
+
|
|
49
|
+
if (recentSearchedGames) {
|
|
50
|
+
recentSearchedGamesArray = recentSearchedGames.split(',');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let promises:Array<Promise<any>> = [];
|
|
54
|
+
let index = 0;
|
|
55
|
+
let length = recentSearchedGamesArray.length;
|
|
56
|
+
|
|
57
|
+
if (length > 0) {
|
|
58
|
+
for (index = 0; index < length; index++) {
|
|
59
|
+
let url:any = new URL(`${endpoint}/casino/games/${recentSearchedGamesArray[index]}`);
|
|
60
|
+
|
|
61
|
+
url.searchParams.append('language', lang);
|
|
62
|
+
url.searchParams.append('datasource', datasource);
|
|
63
|
+
url.searchParams.append('platform', getDevice(userAgent));
|
|
64
|
+
|
|
65
|
+
promises.push(getGame(url, recentSearchedGamesArray[index]));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Promise.all(promises).then((res:any):void => {
|
|
69
|
+
searchArray = res;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const getGames = (url:URL):Promise<any> => {
|
|
77
|
+
return new Promise((resolve, reject):void => {
|
|
78
|
+
isLoading = true;
|
|
79
|
+
|
|
80
|
+
fetch(url.href)
|
|
81
|
+
.then((res:any) => res.json())
|
|
82
|
+
.then((games:any) => {
|
|
83
|
+
isLoading = false;
|
|
84
|
+
|
|
85
|
+
resolve(games);
|
|
86
|
+
}).catch((err:any) => {
|
|
87
|
+
isLoading = false;
|
|
88
|
+
|
|
89
|
+
console.error(err);
|
|
90
|
+
|
|
91
|
+
reject(err);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const getGame = (url:any, gameId?:string):Promise<any> => {
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
isLoading = true;
|
|
99
|
+
|
|
100
|
+
if (gameId && Object.keys(gamesCache).indexOf(gameId) >= 0) {
|
|
101
|
+
isLoading = false;
|
|
102
|
+
|
|
103
|
+
resolve(gamesCache[gameId]);
|
|
104
|
+
} else {
|
|
105
|
+
fetch(url)
|
|
106
|
+
.then(fetchRes => fetchRes.json())
|
|
107
|
+
.then(gameData => {
|
|
108
|
+
isLoading = false;
|
|
109
|
+
|
|
110
|
+
gamesCache[gameData[0].gameId] = gameData[0];
|
|
111
|
+
|
|
112
|
+
resolve(gameData[0]);
|
|
113
|
+
}).catch((err:any) => {
|
|
114
|
+
isLoading = false;
|
|
115
|
+
|
|
116
|
+
console.error(err);
|
|
117
|
+
|
|
118
|
+
reject(err);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const addSearchedItem = (gameID:any):void => {
|
|
125
|
+
searchedValues = getCookieValue(`searchedGamesWds_casino`);
|
|
126
|
+
|
|
127
|
+
if (searchedValues) {
|
|
128
|
+
searchedValues = searchedValues.split(',');
|
|
129
|
+
} else {
|
|
130
|
+
searchedValues = [];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (searchedValues.indexOf(gameID) === -1) {
|
|
134
|
+
let value;
|
|
135
|
+
|
|
136
|
+
searchedValues.push(gameID);
|
|
137
|
+
value = searchedValues.join(',');
|
|
138
|
+
document.cookie = `searchedGamesWds_casino=` + value;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const getCookieValue = (name:string):string => {
|
|
143
|
+
let match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
|
|
144
|
+
|
|
145
|
+
if (match) {
|
|
146
|
+
return match[2];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const cancelSearch = ():void => {
|
|
151
|
+
searchValue = '';
|
|
152
|
+
searchCancelled = true;
|
|
153
|
+
isLoading = false;
|
|
154
|
+
searchArray = [];
|
|
155
|
+
searchActive = false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const clearSearch = ():void => {
|
|
159
|
+
searchValue = '';
|
|
160
|
+
searchElement.focus();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const setActiveLanguage = ():void => {
|
|
164
|
+
setLocale(lang);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const setClientStyling = ():void => {
|
|
168
|
+
let sheet = document.createElement('style');
|
|
169
|
+
sheet.innerHTML = clientstyling;
|
|
170
|
+
customStylingContainer.appendChild(sheet);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const setClientStylingURL = ():void => {
|
|
174
|
+
let url:URL = new URL(clientstylingurl);
|
|
175
|
+
let cssFile:HTMLElement = document.createElement('style');
|
|
176
|
+
|
|
177
|
+
fetch(url.href)
|
|
178
|
+
.then((res:any) => res.text())
|
|
179
|
+
.then((data:any) => {
|
|
180
|
+
cssFile.innerHTML = data
|
|
181
|
+
|
|
182
|
+
if (customStylingContainer) {
|
|
183
|
+
setTimeout(() => { customStylingContainer.appendChild(cssFile) }, 1);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
$: if (searchValue.length >= 2) {
|
|
189
|
+
const searchUrl:URL = new URL(`${endpoint}/casino/games`);
|
|
190
|
+
|
|
191
|
+
searchUrl.searchParams.append("datasource", datasource);
|
|
192
|
+
searchUrl.searchParams.append("expand", "vendor");
|
|
193
|
+
searchUrl.searchParams.append("platform", getDevice(userAgent));
|
|
194
|
+
searchUrl.searchParams.append("language", lang);
|
|
195
|
+
searchUrl.searchParams.append("pagination", "offset=0,limit=30");
|
|
196
|
+
searchUrl.searchParams.append("filter", `name=${searchValue}`);
|
|
197
|
+
|
|
198
|
+
getGames(searchUrl).then((searchData:any) => {
|
|
199
|
+
searchArray = searchData.items.map((item) => item);
|
|
200
|
+
});
|
|
201
|
+
} else {
|
|
202
|
+
if (!searchCancelled) {
|
|
203
|
+
onFocus();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
onMount(()=> {
|
|
208
|
+
window.addEventListener('message', messageHandler, false);
|
|
209
|
+
|
|
210
|
+
return () => {
|
|
211
|
+
window.removeEventListener('message', messageHandler);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
$: lang && setActiveLanguage();
|
|
216
|
+
$: clientstyling && setClientStyling();
|
|
217
|
+
$: clientstylingurl && setClientStylingURL();
|
|
218
|
+
|
|
219
|
+
</script>
|
|
220
|
+
|
|
221
|
+
<div bind:this={customStylingContainer}>
|
|
222
|
+
<div class="CasinoSearch">
|
|
223
|
+
<div class="Search">
|
|
224
|
+
<div class="SearchIcon">
|
|
225
|
+
<svg width="14" height="15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
226
|
+
<path stroke="#212121" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="m10.48 10.985 2.21 2.373"/>
|
|
227
|
+
<circle cx="6.5" cy="6.5" r="5.75" stroke="#212121" stroke-width="1.5"/>
|
|
228
|
+
</svg>
|
|
229
|
+
</div>
|
|
230
|
+
<div class="SearchContainer">
|
|
231
|
+
<input class="SearchInput" type="search" placeholder="Search for Games" bind:value={searchValue} on:focus={onFocus} bind:this={searchElement}>
|
|
232
|
+
<span on:click={() => clearSearch()} class="SearchClearButton { searchValue.length != 0 ? '' : 'NotVisible'}">
|
|
233
|
+
<svg width="11" height="11" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
234
|
+
<path d="m1.45 1.5 8.1 8M1.45 9.5l8.1-8" stroke="#717171" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
235
|
+
</svg>
|
|
236
|
+
</span>
|
|
237
|
+
</div>
|
|
238
|
+
<small on:click={() => cancelSearch()} class="SearchCancelButton {searchCancelled ? 'NotVisible' : ''}">
|
|
239
|
+
{$_('Translations.cancel')}
|
|
240
|
+
</small>
|
|
241
|
+
</div>
|
|
242
|
+
{#if isLoading}
|
|
243
|
+
<p>{$_('Translations.loading')}</p>
|
|
244
|
+
{:else}
|
|
245
|
+
{#if searchActive == true && searchValue.length < 2}
|
|
246
|
+
<p class="SearchMessage">{$_('Translations.recentSearch')}</p>
|
|
247
|
+
{:else if searchArray.length != 0}
|
|
248
|
+
<p class="SearchMessage">{$_('Translations.searchResult')}</p>
|
|
249
|
+
{/if}
|
|
250
|
+
<div class="SearchResultsContainer">
|
|
251
|
+
{#if searchCancelled === false}
|
|
252
|
+
{#each searchArray as game}
|
|
253
|
+
<casino-game-thumbnail
|
|
254
|
+
lang={lang}
|
|
255
|
+
gamethumbnail={game.thumbnail}
|
|
256
|
+
gamename={game.name}
|
|
257
|
+
gamevendor={game.vendor.name}
|
|
258
|
+
gameisnew={game.isNew}
|
|
259
|
+
gamepopularity={game.popularity}
|
|
260
|
+
gamecellsize={game.cellSize}
|
|
261
|
+
gameid={game.id}
|
|
262
|
+
gamefunmode={game.hasFunMode}
|
|
263
|
+
gamefavorite={game.isFavorite}
|
|
264
|
+
livelobbyendpoint={game.details ? game.launchUrl : ''}
|
|
265
|
+
endpoint={endpoint}
|
|
266
|
+
></casino-game-thumbnail>
|
|
267
|
+
{/each}
|
|
268
|
+
{/if}
|
|
269
|
+
{#if searchValue.length >= 2 && searchArray.length == 0}
|
|
270
|
+
<div class="ResultsContainerError">
|
|
271
|
+
<p class="SearchMessage">{$_('Translations.notFound')}</p>
|
|
272
|
+
<p>{$_('Translations.notFoundText')}</p>
|
|
273
|
+
</div>
|
|
274
|
+
{/if}
|
|
275
|
+
</div>
|
|
276
|
+
{/if}
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
<style lang="scss">
|
|
281
|
+
:host {
|
|
282
|
+
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
$color-grey: #717171;
|
|
286
|
+
$color-light-grey: #cacaca;
|
|
287
|
+
$color-black: #212121;
|
|
288
|
+
|
|
289
|
+
$grid-gap: 8px;
|
|
290
|
+
$grid-cell-size: 167px;
|
|
291
|
+
$grid-cell-size-small: 110px;
|
|
292
|
+
$grid-cell-size-medium: 122px;
|
|
293
|
+
|
|
294
|
+
*,
|
|
295
|
+
*::before,
|
|
296
|
+
*::after {
|
|
297
|
+
margin: 0;
|
|
298
|
+
padding: 0;
|
|
299
|
+
box-sizing: border-box;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.NotVisible {
|
|
303
|
+
display: none;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.CasinoSearch {
|
|
307
|
+
margin: 16px;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.Search {
|
|
311
|
+
display: flex;
|
|
312
|
+
align-items: center;
|
|
313
|
+
position: relative;
|
|
314
|
+
justify-content: space-between;
|
|
315
|
+
margin-bottom: 20px;
|
|
316
|
+
|
|
317
|
+
&Icon{
|
|
318
|
+
position: absolute;
|
|
319
|
+
left: 5%;
|
|
320
|
+
z-index: 1;
|
|
321
|
+
|
|
322
|
+
svg {
|
|
323
|
+
height: 14px;
|
|
324
|
+
width: 13px;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
&Container {
|
|
328
|
+
width: 100%;
|
|
329
|
+
position: relative;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
&Input {
|
|
333
|
+
border-radius: 4px;
|
|
334
|
+
border: 1px solid $color-light-grey;
|
|
335
|
+
color: $color-grey;
|
|
336
|
+
display: block;
|
|
337
|
+
font-size: 16px;
|
|
338
|
+
font-weight: 300;
|
|
339
|
+
padding: 14px 5px 14px 46px;
|
|
340
|
+
width:100%;
|
|
341
|
+
|
|
342
|
+
&::placeholder {
|
|
343
|
+
color: $color-grey;
|
|
344
|
+
font-size: 16px;
|
|
345
|
+
font-weight: 300;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
&:focus {
|
|
349
|
+
outline: 1px solid #d9d7d7;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
&::-webkit-search-decoration,
|
|
353
|
+
&::-webkit-search-cancel-button,
|
|
354
|
+
&::-webkit-search-results-button,
|
|
355
|
+
&::-webkit-search-results-decoration {
|
|
356
|
+
-webkit-appearance:none;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
&ClearButton{
|
|
361
|
+
position: absolute;
|
|
362
|
+
top: 30%;
|
|
363
|
+
right: 15px;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
&CancelButton {
|
|
367
|
+
color: $color-grey;
|
|
368
|
+
font-weight: 300;
|
|
369
|
+
margin-left: 8px;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
&Message {
|
|
373
|
+
font-size: 18px;
|
|
374
|
+
font-weight: 600;
|
|
375
|
+
margin: 24px 0;
|
|
376
|
+
color: $color-black;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
&ResultsContainer {
|
|
380
|
+
display: grid;
|
|
381
|
+
gap: $grid-gap;
|
|
382
|
+
grid-template-columns: repeat(auto-fill, minmax(Min($grid-cell-size, 46%), 1fr));
|
|
383
|
+
grid-template-rows: repeat(auto-fill, $grid-cell-size);
|
|
384
|
+
grid-auto-rows: $grid-cell-size;
|
|
385
|
+
grid-auto-columns: $grid-cell-size;
|
|
386
|
+
grid-auto-flow: row dense;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.ResultsContainerError {
|
|
391
|
+
text-align: center;
|
|
392
|
+
width: 300px;
|
|
393
|
+
color: $color-grey;
|
|
394
|
+
font-weight: 300;
|
|
395
|
+
position: absolute;
|
|
396
|
+
top: 50%;
|
|
397
|
+
left: 50%;
|
|
398
|
+
transform: translate(-50%, -50%);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
</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