@mundogamernetwork/shared-ui 1.14.5 → 1.16.0

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.
@@ -3,9 +3,13 @@ import { storeToRefs } from "pinia";
3
3
 
4
4
  const emit = defineEmits(["toggleVisible"]);
5
5
 
6
- const showOnline = ref(true);
7
6
  const authStore = useAuthStore();
8
- const { user, signedIn } = storeToRefs(authStore);
7
+ // showOnline used to be a local ref here — flipped on click, called no
8
+ // endpoint, reset on every reload. The auth store's fetchOnlineStatus /
9
+ // toggleOnlineStatus (see tv-frontend's store, the pattern this now
10
+ // matches everywhere) are what actually persist it; a host whose store
11
+ // doesn't implement them yet just won't expose features.statusOnline.
12
+ const { user, signedIn, showOnline } = storeToRefs(authStore);
9
13
  const { performLogout } = useLogout();
10
14
 
11
15
  const runtimeConfig = useRuntimeConfig();
@@ -31,53 +35,32 @@ onMounted(() => {
31
35
  document.addEventListener("keydown", ({ key }) => {
32
36
  if (key === "Escape") emit("toggleVisible");
33
37
  });
38
+ // Guarded: not every host's auth store has adopted this pattern yet
39
+ // (see tv-frontend's store for the reference implementation).
40
+ if (signedIn.value && typeof authStore.fetchOnlineStatus === "function") {
41
+ authStore.fetchOnlineStatus();
42
+ }
34
43
  });
35
44
 
36
45
  onUnmounted(() => {
37
46
  document.removeEventListener("click", focusOut);
38
47
  });
39
48
 
40
- const login = () => {
41
- const redirectTo = encodeURIComponent(window.location.href);
42
- window.location.href = `${accountsBaseUrl}/login?redirect_to=${redirectTo}`;
43
- };
44
-
45
- // Computed in script rather than read inline in the template: a bare `window`
46
- // reference in the template crashes the render (it's not part of the
47
- // script-setup bindings the compiled render function has access to, and it's
48
- // undefined during SSR), which took down this whole dropdown for every
49
- // signed-out visitor.
50
- const registerHref = computed(
51
- () => `${accountsBaseUrl}/register?redirect_to=${encodeURIComponent(import.meta.client ? window.location.href : "")}`,
52
- );
53
-
54
49
  const handleLogout = async () => {
55
50
  await performLogout(`${accountsBaseUrl}/login`);
56
51
  };
52
+
53
+ const handleToggleOnline = () => {
54
+ if (typeof authStore.toggleOnlineStatus === "function") {
55
+ authStore.toggleOnlineStatus();
56
+ }
57
+ };
57
58
  </script>
58
59
 
59
60
  <template>
60
61
  <div ref="refDiv" :class="{ 'ui-config-user': true, 'signed-in': signedIn }">
61
62
  <div ref="wrapper" class="ui-config-user__content">
62
- <div v-if="!signedIn" class="ui-config-user__content__tab">
63
- <div class="ui-config-user__option">
64
- <div class="w-100">
65
- <a class="btn primary lg w-100" href="#" @click.prevent="login">
66
- {{ $t("header.login.btn_login") }}
67
- </a>
68
- </div>
69
- </div>
70
- <div class="ui-config-user__option">
71
- <div>
72
- <p class="d-flex">
73
- {{ $t("header.login.register_message") }}
74
- <a :href="registerHref" class="ms-1">
75
- {{ $t("header.login.btn_register") }}
76
- </a>
77
- </p>
78
- </div>
79
- </div>
80
- </div>
63
+ <MgLoginRegisterMenu v-if="!signedIn" :dropdown="false" />
81
64
 
82
65
  <div v-else class="signed-in-menu">
83
66
  <div class="row info-row ps-0">
@@ -134,7 +117,7 @@ const handleLogout = async () => {
134
117
  <div class="status-toggle">
135
118
  <span>{{ $t("account_menu.buttons.show_online") }}</span>
136
119
  <label class="switch">
137
- <input v-model="showOnline" type="checkbox" />
120
+ <input :checked="showOnline" type="checkbox" @change="handleToggleOnline" />
138
121
  <span class="slider"></span>
139
122
  </label>
140
123
  </div>
@@ -169,74 +152,26 @@ const handleLogout = async () => {
169
152
  top: 45px;
170
153
  right: 0;
171
154
  z-index: 999;
172
- overflow: hidden;
155
+ // Signed-in content is open-ended — hosts add their own extra-menu-items
156
+ // (Jobs alone has 5 nav links plus a CTA button and pricing link on top
157
+ // of the base menu). With no height cap this just grew as tall as its
158
+ // content, unbounded, and once the earlier width:100% bug (see below)
159
+ // stopped collapsing it to an unreadable 32px sliver, the height had
160
+ // nowhere to go but off the bottom of the viewport — no scrollbar, no
161
+ // way to reach whatever content and the page below it that it covered.
162
+ max-height: calc(100vh - 65px);
163
+ overflow-y: auto;
173
164
  transition: all ease 0.5s;
174
165
 
175
166
  &:not(.signed-in) {
176
167
  width: 340px;
177
168
  }
178
169
 
179
- &__option {
180
- color: var(--sidebar-menus-fg);
181
- display: flex;
182
- justify-content: space-between;
183
- padding: 0 1rem;
184
- font-size: 0.875rem;
185
- min-height: 48px;
186
- align-items: center;
187
-
188
- a {
189
- font-size: 16px !important;
190
- font-weight: 400;
191
- }
192
-
193
- // Self-contained styling, not a host `.btn.primary` Bootstrap class:
194
- // this component ships to hosts that don't all load Bootstrap (Shop
195
- // doesn't), so relying on it left the login button rendering as a
196
- // bare unstyled link there. Same color tokens the rest of this file
197
- // already falls back through (see .plans-pricing-link below).
198
- a.btn.primary {
199
- display: block;
200
- text-align: center;
201
- padding: 0.625rem 1rem;
202
- background: var(--highlight-color, var(--header-active-fg, var(--active)));
203
- color: var(--header-ui-config-bg, #fff);
204
- text-decoration: none;
205
-
206
- &:hover {
207
- opacity: 0.85;
208
- }
209
- }
210
-
211
- & > div > p {
212
- font-size: 15px !important;
213
- font-weight: 400;
214
- color: var(--sidebar-menus-fg);
215
-
216
- a {
217
- color: var(--highlight-color, var(--header-active-fg, var(--active)));
218
- }
219
- }
220
- }
221
-
222
170
  &__content {
223
171
  display: flex;
224
172
  justify-content: flex-start;
225
173
  align-items: flex-start;
226
174
  transition: transform 0.4s cubic-bezier(0.86, 0, 0.07, 1);
227
-
228
- &__tab {
229
- flex: 1 0 100%;
230
- width: 100%;
231
- background-color: var(--header-ui-config-bg);
232
-
233
- p {
234
- color: var(--active);
235
- font-size: 12px;
236
- padding: 0.5rem 1rem;
237
- margin: 0;
238
- }
239
- }
240
175
  }
241
176
 
242
177
  .signed-in-menu {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mundogamernetwork/shared-ui",
3
- "version": "1.14.5",
3
+ "version": "1.16.0",
4
4
  "description": "Mundo Gamer Network - Shared UI Layer (Nuxt 3)",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",