@everymatrix/casino-tournaments-filter-controller 0.0.367 → 0.0.368

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.
@@ -1,244 +1,244 @@
1
- <svelte:options tag={null} />
2
-
3
- <script lang="ts">
4
- import { onMount } from 'svelte';
5
- import { getDevice, isMobile } from 'rvhelper';
6
- import { _, addNewMessages, setLocale } from './i18n';
7
- import { TournamentsFilterTranslations } from './translations';
8
-
9
- // Array as string, without empty spaces (ex: "All,Scheduled,Ongoing,Finished");
10
- export let filters:string = '';
11
- export let activefilters:string = '';
12
-
13
- let hasErrors:boolean = false;
14
- let filterItems:any = [];
15
- let filterNumber:number = 0;
16
- let activeIndexes:Array<Number> = new Array(100);
17
- let allActive:boolean = true;
18
- let userAgent:string = window.navigator.userAgent;
19
- let shownStatus:string = '';
20
-
21
- Object.keys(TournamentsFilterTranslations).forEach((item:any) => {
22
- addNewMessages(item, TournamentsFilterTranslations[item]);
23
- });
24
-
25
- const makeButtonActive = (item:String, index:Number) => {
26
- if (index == 0) {
27
- allActive = true;
28
- activeIndexes = new Array(filterNumber);
29
-
30
- window.postMessage({ type: 'TournamentsFiltersSelected', filters: ['All']});
31
- } else {
32
- allActive = false;
33
-
34
- if (activeIndexes[index] == 1) {
35
- activeIndexes[index] = 0;
36
-
37
- if (activeIndexes.indexOf(1) == -1) {
38
- allActive = true;
39
- }
40
- } else {
41
- activeIndexes[index] = 1;
42
- }
43
-
44
- if (activeIndexes.indexOf(1) == -1) {
45
- window.postMessage({ type: 'TournamentsFiltersSelected', filters: ['All']});
46
- } else {
47
- let message:Array<String> = [];
48
-
49
- for (let i = 0; i < filterItems.length; i++) {
50
- if (activeIndexes[i] == 1) {
51
- message.push(filterItems[i]);
52
- }
53
- }
54
-
55
- window.postMessage({ type: 'TournamentsFiltersSelected', filters: message });
56
- }
57
- }
58
- }
59
-
60
- const matchFilter = (filter:string) => {
61
- if (filter == 'Scheduled') {
62
- return $_('tournamentsFilter.scheduled');
63
- }
64
-
65
- if (filter == 'Ongoing') {
66
- return $_('tournamentsFilter.ongoing');
67
- }
68
-
69
- if (filter == 'Finished') {
70
- return $_('tournamentsFilter.finished');
71
- }
72
-
73
- if (filter == 'All') {
74
- return $_('tournamentsFilter.all');
75
- }
76
- }
77
-
78
- const processFilters = () => {
79
- filterItems = filters.split(',');
80
- filterNumber = filterItems.length;
81
- }
82
-
83
- const setActiveFilters = () => {
84
- let items = activefilters.split(',');
85
-
86
- activeIndexes = new Array(filterNumber);
87
-
88
- if (items.indexOf('All') != -1) {
89
- allActive = true;
90
- } else {
91
- allActive = false;
92
-
93
- items.forEach((item) => {
94
- let index = filterItems.indexOf(item);
95
-
96
- if (index > 0) {
97
- $: activeIndexes[index] = 1;
98
- }
99
- });
100
- }
101
- }
102
-
103
- $: filters && processFilters();
104
- $: activefilters && setActiveFilters();
105
- </script>
106
- <div class="FiltersController { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }" part="FiltersController { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }">
107
- {#if filterItems.length > 0}
108
- <ul class="FiltersList { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }" part="FiltersList { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }">
109
- <li class="FiltersTitle { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }" part="FiltersTitle { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }">
110
- {$_('tournamentsFilter.tournaments')}:
111
- </li>
112
- {#each filterItems as filter, index}
113
- <li class="FiltersItem" part="FiltersItem" on:click={() => makeButtonActive(filter, index)}>
114
- <button class="{activeIndexes[index] == 1 || (allActive && index == 0) ? 'Active' : ''} { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }" part="{activeIndexes[index] == 1 || (allActive && index == 0) ? 'Active' : ''} { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }">
115
- {#if activeIndexes[index] == 1 || (allActive && index == 0)}
116
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check" part="bi bi-check" viewBox="0 0 16 16">
117
- <path d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z"/>
118
- </svg>
119
- {/if}
120
- <div class="FilterButton { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }" part="FilterButton { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }">
121
- {#if filter == 'Scheduled'}
122
- {$_('tournamentsFilter.scheduled')}
123
- {/if}
124
- {#if filter == 'Ongoing'}
125
- {$_('tournamentsFilter.ongoing')}
126
- {/if}
127
- {#if filter == 'Finished'}
128
- {$_('tournamentsFilter.finished')}
129
- {/if}
130
- {#if filter == 'All'}
131
- {$_('tournamentsFilter.all')}
132
- {/if}
133
- </div>
134
- </button>
135
- </li>
136
- {/each}
137
- </ul>
138
- {/if}
139
- </div>
140
-
141
-
142
- <style lang="scss">
143
- :host {
144
- font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
145
- }
146
-
147
- *,
148
- *::before,
149
- *::after {
150
- margin: 0;
151
- padding: 0;
152
- list-style: none;
153
- text-decoration: none;
154
- outline: none;
155
- box-sizing: border-box;
156
- }
157
-
158
- ul {
159
- display: flex;
160
- gap: 10px;
161
- &.MobileClass {
162
- padding-top: 21px;
163
- }
164
- }
165
-
166
- li:first-child {
167
- height: 100%;
168
- position: realtive;
169
- padding: 1em 0;
170
- margin: 0;
171
- font-size: 14px;
172
- text-align:center;
173
- letter-spacing: 0px;
174
- color: var(--emfe-w-color-white, #FFFFFF);
175
- opacity: 1;
176
- }
177
-
178
- li.MobileClass {
179
- position: absolute;
180
- left: 10px;
181
- top: -15px;
182
- font-size: 14px;
183
- height: auto;
184
- }
185
-
186
- button {
187
- display: flex;
188
- align-items: center;
189
- background-color: transparent;
190
- justify-content: center;
191
- padding: 10px;
192
- height: 40px;
193
- border: 1px solid var(--emfe-w-color-white, #FFFFFF);
194
- min-width: 40px;
195
- text-align: center;
196
- color: var(--emfe-w-color-white, #FFFFFF);
197
- &.MobileClass {
198
- height: 30px;
199
- }
200
- }
201
-
202
- button:hover {
203
- background-color: var(--emfe-w-color-gray-100, #E6E6E6);
204
- border: 1px solid var(--emfe-w-color-gray-100, #E6E6E6);
205
- color: var(--emfe-w-color-black, #000000);
206
- cursor: pointer;
207
- }
208
-
209
- .FiltersController {
210
- color: var(--emfe-w-color-white, #FFFFFF);
211
- display: flex;
212
- justify-content: flex-end;
213
- margin-bottom: 20px;
214
- &.MobileClass {
215
- justify-content: flex-start;
216
- margin-bottom: 10px;
217
- }
218
-
219
- .FilterButton {
220
- font-size: 14px;
221
- letter-spacing: 0px;
222
- opacity: 1;
223
- text-transform: uppercase;
224
- &.MobileClass {
225
- font-size: 10px;
226
- }
227
- }
228
-
229
- .Active {
230
- background-color: var(--emfe-w-color-gray-300, #58586B);
231
- border: 1px solid var(--emfe-w-color-gray-300, #58586B);
232
- }
233
-
234
- .Active:hover {
235
- background-color: var(--emfe-w-color-gray-300, #58586B);
236
- border: 1px solid var(--emfe-w-color-gray-300, #58586B);
237
- }
238
-
239
- }
240
-
241
-
242
-
243
-
244
- </style>
1
+ <svelte:options tag={null} />
2
+
3
+ <script lang="ts">
4
+ import { onMount } from 'svelte';
5
+ import { getDevice, isMobile } from 'rvhelper';
6
+ import { _, addNewMessages, setLocale } from './i18n';
7
+ import { TournamentsFilterTranslations } from './translations';
8
+
9
+ // Array as string, without empty spaces (ex: "All,Scheduled,Ongoing,Finished");
10
+ export let filters:string = '';
11
+ export let activefilters:string = '';
12
+
13
+ let hasErrors:boolean = false;
14
+ let filterItems:any = [];
15
+ let filterNumber:number = 0;
16
+ let activeIndexes:Array<Number> = new Array(100);
17
+ let allActive:boolean = true;
18
+ let userAgent:string = window.navigator.userAgent;
19
+ let shownStatus:string = '';
20
+
21
+ Object.keys(TournamentsFilterTranslations).forEach((item:any) => {
22
+ addNewMessages(item, TournamentsFilterTranslations[item]);
23
+ });
24
+
25
+ const makeButtonActive = (item:String, index:Number) => {
26
+ if (index == 0) {
27
+ allActive = true;
28
+ activeIndexes = new Array(filterNumber);
29
+
30
+ window.postMessage({ type: 'TournamentsFiltersSelected', filters: ['All']});
31
+ } else {
32
+ allActive = false;
33
+
34
+ if (activeIndexes[index] == 1) {
35
+ activeIndexes[index] = 0;
36
+
37
+ if (activeIndexes.indexOf(1) == -1) {
38
+ allActive = true;
39
+ }
40
+ } else {
41
+ activeIndexes[index] = 1;
42
+ }
43
+
44
+ if (activeIndexes.indexOf(1) == -1) {
45
+ window.postMessage({ type: 'TournamentsFiltersSelected', filters: ['All']});
46
+ } else {
47
+ let message:Array<String> = [];
48
+
49
+ for (let i = 0; i < filterItems.length; i++) {
50
+ if (activeIndexes[i] == 1) {
51
+ message.push(filterItems[i]);
52
+ }
53
+ }
54
+
55
+ window.postMessage({ type: 'TournamentsFiltersSelected', filters: message });
56
+ }
57
+ }
58
+ }
59
+
60
+ const matchFilter = (filter:string) => {
61
+ if (filter == 'Scheduled') {
62
+ return $_('tournamentsFilter.scheduled');
63
+ }
64
+
65
+ if (filter == 'Ongoing') {
66
+ return $_('tournamentsFilter.ongoing');
67
+ }
68
+
69
+ if (filter == 'Finished') {
70
+ return $_('tournamentsFilter.finished');
71
+ }
72
+
73
+ if (filter == 'All') {
74
+ return $_('tournamentsFilter.all');
75
+ }
76
+ }
77
+
78
+ const processFilters = () => {
79
+ filterItems = filters.split(',');
80
+ filterNumber = filterItems.length;
81
+ }
82
+
83
+ const setActiveFilters = () => {
84
+ let items = activefilters.split(',');
85
+
86
+ activeIndexes = new Array(filterNumber);
87
+
88
+ if (items.indexOf('All') != -1) {
89
+ allActive = true;
90
+ } else {
91
+ allActive = false;
92
+
93
+ items.forEach((item) => {
94
+ let index = filterItems.indexOf(item);
95
+
96
+ if (index > 0) {
97
+ $: activeIndexes[index] = 1;
98
+ }
99
+ });
100
+ }
101
+ }
102
+
103
+ $: filters && processFilters();
104
+ $: activefilters && setActiveFilters();
105
+ </script>
106
+ <div class="FiltersController { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }" part="FiltersController { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }">
107
+ {#if filterItems.length > 0}
108
+ <ul class="FiltersList { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }" part="FiltersList { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }">
109
+ <li class="FiltersTitle { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }" part="FiltersTitle { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }">
110
+ {$_('tournamentsFilter.tournaments')}:
111
+ </li>
112
+ {#each filterItems as filter, index}
113
+ <li class="FiltersItem" part="FiltersItem" on:click={() => makeButtonActive(filter, index)}>
114
+ <button class="{activeIndexes[index] == 1 || (allActive && index == 0) ? 'Active' : ''} { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }" part="{activeIndexes[index] == 1 || (allActive && index == 0) ? 'Active' : ''} { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }">
115
+ {#if activeIndexes[index] == 1 || (allActive && index == 0)}
116
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check" part="bi bi-check" viewBox="0 0 16 16">
117
+ <path d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z"/>
118
+ </svg>
119
+ {/if}
120
+ <div class="FilterButton { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }" part="FilterButton { isMobile(userAgent) ? 'MobileClass' : 'Non-MobileClass/empty' }">
121
+ {#if filter == 'Scheduled'}
122
+ {$_('tournamentsFilter.scheduled')}
123
+ {/if}
124
+ {#if filter == 'Ongoing'}
125
+ {$_('tournamentsFilter.ongoing')}
126
+ {/if}
127
+ {#if filter == 'Finished'}
128
+ {$_('tournamentsFilter.finished')}
129
+ {/if}
130
+ {#if filter == 'All'}
131
+ {$_('tournamentsFilter.all')}
132
+ {/if}
133
+ </div>
134
+ </button>
135
+ </li>
136
+ {/each}
137
+ </ul>
138
+ {/if}
139
+ </div>
140
+
141
+
142
+ <style lang="scss">
143
+ :host {
144
+ font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
145
+ }
146
+
147
+ *,
148
+ *::before,
149
+ *::after {
150
+ margin: 0;
151
+ padding: 0;
152
+ list-style: none;
153
+ text-decoration: none;
154
+ outline: none;
155
+ box-sizing: border-box;
156
+ }
157
+
158
+ ul {
159
+ display: flex;
160
+ gap: 10px;
161
+ &.MobileClass {
162
+ padding-top: 21px;
163
+ }
164
+ }
165
+
166
+ li:first-child {
167
+ height: 100%;
168
+ position: realtive;
169
+ padding: 1em 0;
170
+ margin: 0;
171
+ font-size: 14px;
172
+ text-align:center;
173
+ letter-spacing: 0px;
174
+ color: var(--emfe-w-color-white, #FFFFFF);
175
+ opacity: 1;
176
+ }
177
+
178
+ li.MobileClass {
179
+ position: absolute;
180
+ left: 10px;
181
+ top: -15px;
182
+ font-size: 14px;
183
+ height: auto;
184
+ }
185
+
186
+ button {
187
+ display: flex;
188
+ align-items: center;
189
+ background-color: transparent;
190
+ justify-content: center;
191
+ padding: 10px;
192
+ height: 40px;
193
+ border: 1px solid var(--emfe-w-color-white, #FFFFFF);
194
+ min-width: 40px;
195
+ text-align: center;
196
+ color: var(--emfe-w-color-white, #FFFFFF);
197
+ &.MobileClass {
198
+ height: 30px;
199
+ }
200
+ }
201
+
202
+ button:hover {
203
+ background-color: var(--emfe-w-color-gray-100, #E6E6E6);
204
+ border: 1px solid var(--emfe-w-color-gray-100, #E6E6E6);
205
+ color: var(--emfe-w-color-black, #000000);
206
+ cursor: pointer;
207
+ }
208
+
209
+ .FiltersController {
210
+ color: var(--emfe-w-color-white, #FFFFFF);
211
+ display: flex;
212
+ justify-content: flex-end;
213
+ margin-bottom: 20px;
214
+ &.MobileClass {
215
+ justify-content: flex-start;
216
+ margin-bottom: 10px;
217
+ }
218
+
219
+ .FilterButton {
220
+ font-size: 14px;
221
+ letter-spacing: 0px;
222
+ opacity: 1;
223
+ text-transform: uppercase;
224
+ &.MobileClass {
225
+ font-size: 10px;
226
+ }
227
+ }
228
+
229
+ .Active {
230
+ background-color: var(--emfe-w-color-gray-300, #58586B);
231
+ border: 1px solid var(--emfe-w-color-gray-300, #58586B);
232
+ }
233
+
234
+ .Active:hover {
235
+ background-color: var(--emfe-w-color-gray-300, #58586B);
236
+ border: 1px solid var(--emfe-w-color-gray-300, #58586B);
237
+ }
238
+
239
+ }
240
+
241
+
242
+
243
+
244
+ </style>
package/src/i18n.js CHANGED
@@ -1,27 +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 };
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 CHANGED
@@ -1,4 +1,4 @@
1
- import CasinoTournamentsFilterController from './CasinoTournamentsFilterController.svelte';
2
-
3
- !customElements.get('casino-tournaments-filter-controller') && customElements.define('casino-tournaments-filter-controller', CasinoTournamentsFilterController);
4
- export default CasinoTournamentsFilterController;
1
+ import CasinoTournamentsFilterController from './CasinoTournamentsFilterController.svelte';
2
+
3
+ !customElements.get('casino-tournaments-filter-controller') && customElements.define('casino-tournaments-filter-controller', CasinoTournamentsFilterController);
4
+ export default CasinoTournamentsFilterController;