@everymatrix/casino-categories 0.0.335

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/index.html ADDED
@@ -0,0 +1,97 @@
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-categories</title>
8
+ <link rel="stylesheet" href="public/reset.css" />
9
+ <script src="dist/casino-categories.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: #42a3e2;
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
+ </style>
43
+ <header class="header">
44
+ <div class="header__logo">
45
+ <svg
46
+ xmlns="http://www.w3.org/2000/svg"
47
+ width="161"
48
+ height="132"
49
+ viewBox="0 0 161 132"
50
+ >
51
+ <defs>
52
+ <linearGradient x1="0%" y1="50%" y2="50%" id="a">
53
+ <stop stop-color="#2A3B8F" offset="0%" />
54
+ <stop stop-color="#29ABE2" offset="100%" />
55
+ </linearGradient>
56
+ <linearGradient x1="100%" y1="50%" x2="0%" y2="50%" id="c">
57
+ <stop stop-color="#B4D44E" offset="0%" />
58
+ <stop stop-color="#E7F716" offset="100%" />
59
+ </linearGradient>
60
+ </defs>
61
+ <g fill="none" fill-rule="evenodd">
62
+ <path
63
+ fill="#166DA5"
64
+ d="M160.6 65.9l-17.4 29.3-24.4-29.7 24.4-28.9z"
65
+ />
66
+ <path
67
+ fill="#8FDB69"
68
+ d="M141.3 100.2l-26.5-31.7-15.9 26.6 24.7 36.1z"
69
+ />
70
+ <path fill="#166DA5" d="M141 31.4l-26.2 31.8-15.9-26.6L123.6.9z" />
71
+ <path
72
+ fill="url(#a)"
73
+ opacity=".95"
74
+ d="M61.1 31.4H141L123.4.7H78.7z M114.8 63.3H159l-15.9-26.8H98.8"
75
+ />
76
+ <path
77
+ fill="url(#c)"
78
+ opacity=".95"
79
+ d="M141.3 100.3H61l17.6 30.5h45z M114.8 68.4H159l-15.9 26.8H98.8"
80
+ />
81
+ <path
82
+ fill="#010101"
83
+ d="M78.6 130.8L41 65.8 79.1.8H37.9L.4 65.8l37.5 65z"
84
+ />
85
+ </g>
86
+ </svg>
87
+ </div>
88
+ <h1 class="header__name"><span>WEBCOMPONENT:</span> casino-categories</h1>
89
+ </header>
90
+
91
+ <casino-categories
92
+ endpoint="https://demo-api.stage.norway.everymatrix.com/v2/casino/groups/"
93
+ datasource="RNG"
94
+ activecategory="RNG$popular-games"
95
+ ></casino-categories>
96
+ </body>
97
+ </html>
package/index.js ADDED
@@ -0,0 +1 @@
1
+ import './dist/casino-categories.js';
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@everymatrix/casino-categories",
3
+ "version": "0.0.335",
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": "2a202db0cacb4fbc4133d906609b7e72917a25ff"
40
+ }
Binary file
@@ -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
+ }
@@ -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-categories.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,159 @@
1
+ <svelte:options tag={null} />
2
+ <script lang="ts">
3
+ import { _, addNewMessages, setLocale } from './i18n';
4
+ import { Translations } from './translations';
5
+
6
+ export let endpoint:string = '';
7
+ export let datasource:string = '';
8
+ export let lang:string = 'en';
9
+ export let activecategory:string = '';
10
+ export let clientstyling:string = '';
11
+ export let clientstylingurl:string = '';
12
+
13
+ let customStylingContainer:HTMLElement;
14
+ let displayNone:boolean = false;
15
+ const categories:Array<any> = [];
16
+ let topCategories:Array<any> = [];
17
+ let otherCategories:Array<any> = [];
18
+
19
+ Object.keys(Translations).forEach((item:any):void => {
20
+ addNewMessages(item, Translations[item]);
21
+ });
22
+
23
+ const getCategories = ():void => {
24
+ const url:URL = new URL(`${endpoint}/${datasource}language=${lang}`);
25
+
26
+ fetch(url)
27
+ .then((res:any) => res.json())
28
+ .then((data:any) => {
29
+ categories.push(...data.items)
30
+
31
+ topCategories = categories.filter(category => category.isTopCategory === true)
32
+ otherCategories = categories.filter(category => category.isTopCategory === false)
33
+
34
+ });
35
+ }
36
+
37
+ const openGameCategory = (categoryId:any):void => {
38
+ window.postMessage({ type: 'OpenGameCategory', categoryId });
39
+ };
40
+
41
+ const setActiveLanguage = ():void => {
42
+ setLocale(lang);
43
+ }
44
+
45
+ const setClientStyling = ():void => {
46
+ let sheet = document.createElement('style');
47
+ sheet.innerHTML = clientstyling;
48
+ customStylingContainer.appendChild(sheet);
49
+ }
50
+
51
+ const setClientStylingURL = ():void => {
52
+ displayNone = true;
53
+
54
+ let url:URL = new URL(clientstylingurl);
55
+ let cssFile:HTMLElement = document.createElement('style');
56
+
57
+ fetch(url.href)
58
+ .then((res:any) => res.text())
59
+ .then((data:any) => {
60
+ cssFile.innerHTML = data;
61
+
62
+ if (customStylingContainer) {
63
+ setTimeout(() => { customStylingContainer.appendChild(cssFile) }, 1);
64
+ setTimeout(() => { displayNone = false; }, 500);
65
+ }
66
+ });
67
+ }
68
+
69
+ $: endpoint && datasource && getCategories();
70
+ $: lang && setActiveLanguage();
71
+ $: clientstyling && setClientStyling();
72
+ $: clientstylingurl && setClientStylingURL();
73
+
74
+ </script>
75
+
76
+ <div class="CasinoCategories">
77
+ <h4 class="CategoryTitle">{$_('Translations.topCategories')}</h4>
78
+ {#each topCategories as category}
79
+ <div class="Category {activecategory === category.id ? "Active" : ""}">
80
+ <img on:click={() => openGameCategory(category.id)} src={category.icon} alt="{category.name}" class="CategoryImage" >
81
+ <div class="CategoryTextContainer">
82
+ <p>{category.name}</p>
83
+ <p>{category.games.count} {$_('Translations.games')}</p>
84
+ </div>
85
+ </div>
86
+ {/each}
87
+ <h4 class="CategoryTitle">{$_('Translations.otherCategories')}</h4>
88
+ {#each otherCategories as category}
89
+ <div class="Category {activecategory === category.id ? "Active" : ""}">
90
+ <img on:click={() => openGameCategory(category.id)} src={category.icon} alt="{category.name}" class="CategoryImage">
91
+ <div class="CategoryTextContainer">
92
+ <p>{category.name}</p>
93
+ <p>{category.games.count} {$_('Translations.games')}</p>
94
+ </div>
95
+ </div>
96
+ {/each}
97
+ </div>
98
+
99
+ <style lang="scss">
100
+ :host {
101
+ font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
102
+ }
103
+
104
+ *,
105
+ *::before,
106
+ *::after {
107
+ margin: 0;
108
+ padding: 0;
109
+ box-sizing: border-box;
110
+ }
111
+
112
+ .CasinoCategories {
113
+ display: flex;
114
+ flex-direction: column;
115
+ gap: 1rem;
116
+ padding: 10px 60px;
117
+ }
118
+
119
+ .CategoryTitle {
120
+ font-weight: 500;
121
+ position: relative;
122
+ right: 30px;
123
+ margin: 10px 0;
124
+ }
125
+
126
+ .Category{
127
+ border-radius: 7px;
128
+ display: flex;
129
+ align-items: center;
130
+ gap: 16px;
131
+ max-width: 300px;
132
+ &.Active{
133
+ box-shadow: 15px 15px 30px #e4e2e2;
134
+ }
135
+
136
+ &TextContainer {
137
+ display: flex;
138
+ flex-direction: column;
139
+ justify-content: center;
140
+ gap: 10px;
141
+ font-size: 15px;
142
+ & p:first-child {
143
+ font-weight: 600;
144
+ }
145
+ & p:last-child {
146
+ color: #828282;
147
+ font-weight:300;
148
+ }
149
+ }
150
+
151
+ &Image {
152
+ border-radius: 4px;
153
+ object-fit:cover;
154
+ height: 64px;
155
+ width: 64px;
156
+ font-weight: 100;
157
+ }
158
+ }
159
+ </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 CasinoCategories from './CasinoCategories.svelte';
2
+
3
+ !customElements.get('casino-categories') && customElements.define('casino-categories', CasinoCategories);
4
+ export default CasinoCategories;
@@ -0,0 +1,100 @@
1
+ export const Translations = {
2
+ en: {
3
+ Translations: {
4
+ topCategories: "Top Categories",
5
+ otherCategories: "Other Categories",
6
+ games: "games",
7
+ },
8
+ },
9
+ de: {
10
+ Translations: {
11
+ topCategories: "Top Categories",
12
+ otherCategories: "Other Categories",
13
+ games: "games",
14
+ },
15
+ },
16
+ it: {
17
+ Translations: {
18
+ topCategories: "Top Categories",
19
+ otherCategories: "Other Categories",
20
+ games: "games",
21
+ },
22
+ },
23
+ fr: {
24
+ Translations: {
25
+ topCategories: "Top Categories",
26
+ otherCategories: "Other Categories",
27
+ games: "games",
28
+ },
29
+ },
30
+ es: {
31
+ Translations: {
32
+ topCategories: "Top Categories",
33
+ otherCategories: "Other Categories",
34
+ games: "games",
35
+ },
36
+ },
37
+ tr: {
38
+ Translations: {
39
+ topCategories: "Top Categories",
40
+ otherCategories: "Other Categories",
41
+ games: "games",
42
+ },
43
+ },
44
+ ru: {
45
+ Translations: {
46
+ topCategories: "Top Categories",
47
+ otherCategories: "Other Categories",
48
+ games: "games",
49
+ },
50
+ },
51
+ ro: {
52
+ Translations: {
53
+ topCategories: "Top Categories",
54
+ otherCategories: "Other Categories",
55
+ games: "games",
56
+ },
57
+ },
58
+ hr: {
59
+ Translations: {
60
+ topCategories: "Top Categories",
61
+ otherCategories: "Other Categories",
62
+ games: "games",
63
+ },
64
+ },
65
+ hu: {
66
+ Translations: {
67
+ topCategories: "Top Categories",
68
+ otherCategories: "Other Categories",
69
+ games: "games",
70
+ },
71
+ },
72
+ pl: {
73
+ Translations: {
74
+ topCategories: "Top Categories",
75
+ otherCategories: "Other Categories",
76
+ games: "games",
77
+ },
78
+ },
79
+ pt: {
80
+ Translations: {
81
+ topCategories: "Top Categories",
82
+ otherCategories: "Other Categories",
83
+ games: "games",
84
+ },
85
+ },
86
+ sl: {
87
+ Translations: {
88
+ topCategories: "Top Categories",
89
+ otherCategories: "Other Categories",
90
+ games: "games",
91
+ },
92
+ },
93
+ sr: {
94
+ Translations: {
95
+ topCategories: "Top Categories",
96
+ otherCategories: "Other Categories",
97
+ games: "games",
98
+ },
99
+ },
100
+ };
@@ -0,0 +1,13 @@
1
+ import { html } from 'lit-element';
2
+
3
+ import CasinoCategories from '../src/CasinoCategories';
4
+
5
+ // This default export determines where your story goes in the story list
6
+ export default {
7
+ title: 'CasinoCategories',
8
+ };
9
+
10
+ // 👇 We create a “template” of how args map to rendering
11
+ const CasinoCategories = ({ aProperty }) => html`<casino-categories></casino-categories>`;
12
+
13
+ export const FirstStory = CasinoCategories.bind({});
package/tsconfig.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "@tsconfig/svelte/tsconfig.json",
3
+
4
+ "include": ["src/**/*"],
5
+ "exclude": ["node_modules/*", "__sapper__/*", "public/*"]
6
+ }