@everymatrix/casino-hamburger-menu 1.0.2 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-hamburger-menu",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "main": "dist/casino-hamburger-menu.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -11,6 +11,8 @@
11
11
  export let lang:string = 'en';
12
12
  export let activecategory:string = '';
13
13
  export let languageslist:string = '';
14
+ export let clientstyling:string = '';
15
+ export let clientstylingurl:string = '';
14
16
 
15
17
  let modalElement:any;
16
18
  // let isLoggedIn:Boolean = false;
@@ -29,6 +31,7 @@
29
31
  let languageChanged:boolean = false;
30
32
 
31
33
  let selectedLanguage = '';
34
+ let customStylingContainer:HTMLElement;
32
35
 
33
36
  // setupI18n({ withLocale: 'en', translations: {}});
34
37
 
@@ -63,6 +66,14 @@
63
66
  activeMenuItemId = id;
64
67
  // check first if primary menu item has children
65
68
  activeMenuItemChildren = children ? children : [];
69
+
70
+ //Analytics event
71
+ if(typeof gtag == 'function'){
72
+ gtag('event', 'ChangeMenu', {
73
+ 'context': 'HamburgerMenu',
74
+ 'menuItem' : `${activeMenuItemId}`
75
+ });
76
+ }
66
77
  }
67
78
 
68
79
  const setActiveIndex = ():void => {
@@ -133,56 +144,79 @@
133
144
  }
134
145
  });
135
146
 
147
+ const setClientStyling = ():void => {
148
+ let sheet = document.createElement('style');
149
+ sheet.innerHTML = clientstyling;
150
+ customStylingContainer.appendChild(sheet);
151
+ }
152
+
153
+ const setClientStylingURL = ():void => {
154
+ let url:URL = new URL(clientstylingurl);
155
+ let cssFile:HTMLElement = document.createElement('style');
156
+
157
+ fetch(url.href)
158
+ .then((res:any) => res.text())
159
+ .then((data:any) => {
160
+ cssFile.innerHTML = data
161
+
162
+ setTimeout(() => { customStylingContainer.appendChild(cssFile) }, 1);
163
+ });
164
+ }
165
+
136
166
  $: lang && languageslist && initialLoad();
137
167
  $: activecategory && !isLoading && setActiveIndex();
168
+ $: clientstyling && customStylingContainer && setClientStyling();
169
+ $: clientstylingurl && customStylingContainer && setClientStylingURL();
138
170
  </script>
139
171
 
140
- {#if show === true}
141
- <div
142
- transition:fade="{{ transitionDuration: duration }}"
143
- bind:this={modalElement}
144
- class="HamburgerModalWindow"
145
- part="HamburgerModalWindow">
146
- <span class="{modalIsOpen ? 'ModalCloseBtn' : ''}" part="{modalIsOpen ? 'ModalCloseBtn' : ''}" on:click={close} role="button">
147
- <slot name="close">
148
- <svg class="w-6 h-6" part="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>
149
- </slot>
150
- </span>
151
- <div class="HamburgerModalContainer {modalIsOpen ? 'ActiveHamburgerMenu' : ''}" part="HamburgerModalContainer {modalIsOpen ? 'ActiveHamburgerMenu' : ''}">
152
- <ul class="HamburgerPrimaryMenu {menuIsFixed ? 'HamburgerPrimaryMenuFixed' : ''}" part="HamburgerPrimaryMenu {menuIsFixed ? 'HamburgerPrimaryMenuFixed' : ''}">
153
- {#each HamburgerMenuItems as mainItem}
154
- <li class="{activeMenuItemId === mainItem.id ? 'ActiveItem' : ''}" part="{activeMenuItemId === mainItem.id ? 'ActiveItem' : ''}" on:click={()=>changeMenu(mainItem.id, mainItem.children)}>
155
- <div class="HamburgerItemContainer" part="HamburgerItemContainer">
156
- <img src={mainItem.img} alt="menu icon" />
157
- {mainItem.label}
158
- </div>
159
- </li>
160
- {/each}
161
- </ul>
162
- <ul class="HamburgerSecondaryMenu {menuIsFixed ? 'HamburgerSecondaryMenuFixed' : ''}" part="HamburgerSecondaryMenu {menuIsFixed ? 'HamburgerSecondaryMenuFixed' : ''}">
163
- {#each activeMenuItemChildren as secondaryItem}
164
- <li>
165
- <a href={secondaryItem.path}>
166
- <img src={secondaryItem.img} alt="menu icon" />
167
- {secondaryItem.label}
168
- </a>
169
- </li>
170
- {/each}
171
- </ul>
172
- <div class="LanguageSelectorTitle" part="LanguageSelectorTitle">
173
- <span>{$_('languageSelector.language')}</span>
174
- <select bind:value={selectedLanguage} class="Item ItemLanguage" part="Item ItemLanguage" on:change={()=>sendLangChange()}>
175
- {#each languagesArray as lang}
176
- <option value={lang} selected>{lang}</option>
172
+ <div bind:this={customStylingContainer}>
173
+ {#if show === true}
174
+ <div
175
+ transition:fade="{{ transitionDuration: duration }}"
176
+ bind:this={modalElement}
177
+ class="HamburgerModalWindow"
178
+ part="HamburgerModalWindow">
179
+ <span class="{modalIsOpen ? 'ModalCloseBtn' : ''}" part="{modalIsOpen ? 'ModalCloseBtn' : ''}" on:click={close} role="button">
180
+ <slot name="close">
181
+ <svg class="w-6 h-6" part="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>
182
+ </slot>
183
+ </span>
184
+ <div class="HamburgerModalContainer {modalIsOpen ? 'ActiveHamburgerMenu' : ''}" part="HamburgerModalContainer {modalIsOpen ? 'ActiveHamburgerMenu' : ''}">
185
+ <ul class="HamburgerPrimaryMenu {menuIsFixed ? 'HamburgerPrimaryMenuFixed' : ''}" part="HamburgerPrimaryMenu {menuIsFixed ? 'HamburgerPrimaryMenuFixed' : ''}">
186
+ {#each HamburgerMenuItems as mainItem}
187
+ <li class="{activeMenuItemId === mainItem.id ? 'ActiveItem' : ''}" part="{activeMenuItemId === mainItem.id ? 'ActiveItem' : ''}" on:click={()=>changeMenu(mainItem.id, mainItem.children)}>
188
+ <div class="HamburgerItemContainer" part="HamburgerItemContainer">
189
+ <img src={mainItem.img} alt="menu icon" />
190
+ {mainItem.label}
191
+ </div>
192
+ </li>
177
193
  {/each}
178
- </select>
179
-
194
+ </ul>
195
+ <ul class="HamburgerSecondaryMenu {menuIsFixed ? 'HamburgerSecondaryMenuFixed' : ''}" part="HamburgerSecondaryMenu {menuIsFixed ? 'HamburgerSecondaryMenuFixed' : ''}">
196
+ {#each activeMenuItemChildren as secondaryItem}
197
+ <li>
198
+ <a href={secondaryItem.path}>
199
+ <img src={secondaryItem.img} alt="menu icon" />
200
+ {secondaryItem.label}
201
+ </a>
202
+ </li>
203
+ {/each}
204
+ </ul>
205
+ <div class="LanguageSelectorTitle" part="LanguageSelectorTitle">
206
+ <span>{$_('languageSelector.language')}</span>
207
+ <select bind:value={selectedLanguage} class="Item ItemLanguage" part="Item ItemLanguage" on:change={()=>sendLangChange()}>
208
+ {#each languagesArray as lang}
209
+ <option value={lang} selected>{lang}</option>
210
+ {/each}
211
+ </select>
212
+
213
+ </div>
180
214
  </div>
181
- </div>
182
215
 
183
216
 
184
- </div>
185
- {/if}
217
+ </div>
218
+ {/if}
219
+ </div>
186
220
 
187
221
  <style lang="scss">
188
222