@mundogamernetwork/shared-ui 1.19.1 → 1.19.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.
@@ -1,6 +1,5 @@
1
1
  <script setup lang="ts">
2
2
  import { storeToRefs } from "pinia";
3
- import { formatBadge } from "../../utils/whatsNew";
4
3
 
5
4
  /**
6
5
  * The account-menu toggle icon in the header top bar (not the dropdown
@@ -27,13 +26,6 @@ const { user, signedIn } = storeToRefs(authStore);
27
26
  // defensively instead of destructuring: a host whose store doesn't expose
28
27
  // it treats the state as already known, skipping the skeleton rather than
29
28
  // getting stuck showing it forever.
30
- // "Novidades" history: the unread number rides on the avatar, wherever the host draws this toggle. Shown only when the
31
- // drawer host is mounted (MgBanners does it) and the user is signed in; the number comes from the history store.
32
- const whatsNewStore = useWhatsNewStore();
33
- const whatsNewBadge = computed(() =>
34
- signedIn.value && whatsNewStore.hostMounted ? formatBadge(whatsNewStore.unread) : "",
35
- );
36
-
37
29
  const initialized = computed(() => {
38
30
  const raw = (authStore as unknown as { initialized?: boolean }).initialized;
39
31
  return raw === undefined ? true : raw;
@@ -57,7 +49,7 @@ const initialized = computed(() => {
57
49
  alt=""
58
50
  @error="(e: Event) => { const t = e.target as HTMLImageElement; if (t) { t.onerror = null; t.src = '/imgs/default-avatar.png' } }"
59
51
  />
60
- <span v-if="whatsNewBadge" class="mg-wn-avatar-badge" aria-hidden="true">{{ whatsNewBadge }}</span>
52
+ <MgWhatsNewBadge />
61
53
  <template #fallback>
62
54
  <div
63
55
  class="mg-avatar-skeleton"
@@ -90,23 +82,6 @@ const initialized = computed(() => {
90
82
  }
91
83
  }
92
84
 
93
- // Positioned against the host's avatar wrapper (every host's menu item is position:relative).
94
- .mg-wn-avatar-badge {
95
- position: absolute;
96
- top: -4px;
97
- inset-inline-end: -4px;
98
- min-width: 16px;
99
- height: 16px;
100
- padding: 0 4px;
101
- font-size: 0.625rem;
102
- font-weight: 700;
103
- line-height: 16px;
104
- text-align: center;
105
- color: var(--mg-wn-on-accent);
106
- background: var(--mg-wn-accent);
107
- pointer-events: none;
108
- }
109
-
110
85
  .mg-avatar-img {
111
86
  display: block;
112
87
  // Host apps wrap this in a fixed-size clickable link/button and expect
@@ -127,6 +127,8 @@ const handleToggleOnline = () => {
127
127
  <MgLoginRegisterMenu v-if="hydrated && !signedIn" key="guest" :dropdown="false" />
128
128
 
129
129
  <section v-else-if="hydrated" key="signed-in" class="signed-in-menu">
130
+ <!-- Group 1: who you are. Every group below is separated by one thin line and the same spacing. -->
131
+ <div class="menu-group menu-group--identity">
130
132
  <div class="row info-row ps-0">
131
133
  <div class="col-auto px-3">
132
134
  <div v-if="!user?.avatar_url" class="no-avatar-wrapper">
@@ -170,15 +172,21 @@ const handleToggleOnline = () => {
170
172
  and blank next to the avatar, show the username here
171
173
  instead of in its own row below.
172
174
  -->
173
- <div v-else class="col p-0 d-flex align-items-center">
175
+ <div v-else class="col p-0 username-line">
174
176
  <span class="username username--inline">{{ user?.nickname || user?.name }}</span>
177
+ <slot name="username-suffix" />
175
178
  </div>
176
179
  </slot>
177
180
  </div>
178
181
 
179
182
  <div v-if="hasStats" class="row info-row">
180
- <div class="col p-0 d-flex flex-column">
183
+ <div class="col p-0 username-line">
181
184
  <span class="username">{{ user?.nickname || user?.name }}</span>
185
+ <!--
186
+ Optional, inline right after the nickname (a plan badge, a role chip). Replaces putting
187
+ the plan on its own row under the name via #user-subtitle, which hosts can still use.
188
+ -->
189
+ <slot name="username-suffix" />
182
190
  </div>
183
191
  </div>
184
192
 
@@ -189,20 +197,33 @@ const handleToggleOnline = () => {
189
197
  <template #user-subtitle>; hosts without one render nothing here,
190
198
  same as today.
191
199
  -->
192
- <slot name="user-subtitle" />
200
+ <div class="user-subtitle-slot">
201
+ <slot name="user-subtitle" />
202
+ </div>
203
+
204
+ <!-- Level, XP and the MGC balance in one block (the bar draws the balance itself). -->
205
+ <div v-if="features.gamification !== false" class="row info-row gamification-row">
206
+ <MgXpLevelBar
207
+ compact
208
+ :mgc-balance="user?.coins ?? null"
209
+ :show-balance="!!features.wallet && user?.coins !== null"
210
+ :locale="locale"
211
+ />
212
+ </div>
193
213
 
194
- <div v-if="features.wallet && user?.coins !== null" class="row info-row">
214
+ <!-- Hosts that switch the XP bar off keep the plain balance row. -->
215
+ <div v-else-if="features.wallet && user?.coins !== null" class="row info-row">
195
216
  <span class="coins">
196
217
  <MGIcon icon="coin-v2" />
197
218
  {{ Math.floor(user?.coins ?? 0).toLocaleString(locale) }}
198
219
  <span class="coins__currency">MGC</span>
199
220
  </span>
200
221
  </div>
201
-
202
- <div v-if="features.gamification !== false" class="row info-row gamification-row">
203
- <MgXpLevelBar compact :mgc-balance="user?.coins ?? null" :show-balance="false" :locale="locale" />
204
222
  </div>
205
223
 
224
+ <!-- Group 2: your account. -->
225
+ <div class="menu-group menu-group--account">
226
+
206
227
  <!--
207
228
  Optional, empty by default. For a host whose primary CTA (jobs-
208
229
  frontend's "Post a job") and its related stat (companies followed)
@@ -219,23 +240,13 @@ const handleToggleOnline = () => {
219
240
  </a>
220
241
  </div>
221
242
 
222
- <div v-if="whatsNewHistory && whatsNewStore.hostMounted" class="row info-row">
223
- <MgWhatsNewMenuItem @opened="emit('toggleVisible')" />
224
- </div>
225
-
226
243
  <div class="row info-row">
227
- <a :href="accountsBaseUrl" target="_blank" class="btn btn-primary-outline mt-3">
244
+ <a :href="accountsBaseUrl" target="_blank" class="btn btn-primary-outline">
228
245
  {{ $t("account_menu.buttons.manage_account") }}
229
246
  </a>
230
247
  </div>
231
248
 
232
- <div class="row info-row">
233
- <a :href="supportUrl" target="_blank" class="support-link">
234
- {{ $t("account_menu.buttons.support", "Support") }}
235
- </a>
236
- </div>
237
-
238
- <div v-if="features.statusOnline" class="row info-row my-3">
249
+ <div v-if="features.statusOnline" class="row info-row">
239
250
  <div class="status-toggle">
240
251
  <span>{{ $t("account_menu.buttons.show_online") }}</span>
241
252
  <label class="switch">
@@ -245,12 +256,37 @@ const handleToggleOnline = () => {
245
256
  </div>
246
257
  </div>
247
258
 
248
- <slot name="extra-menu-items" />
259
+ </div>
249
260
 
250
- <div class="row info-row my-3">
251
- <button class="logout" type="button" @click="handleLogout">
252
- {{ $t("account_menu.buttons.logout") }}
253
- </button>
261
+ <!-- Group 3: the host's own navigation links. -->
262
+ <div v-if="$slots['extra-menu-items']" class="menu-group menu-group--nav">
263
+ <slot name="extra-menu-items" />
264
+ </div>
265
+
266
+ <!-- Group 4: secondary entries, then Logout. -->
267
+ <div class="menu-group menu-group--secondary">
268
+ <div v-if="whatsNewHistory && whatsNewStore.hostMounted" class="row info-row">
269
+ <MgWhatsNewMenuItem @opened="emit('toggleVisible')" />
270
+ </div>
271
+
272
+ <div class="row info-row">
273
+ <a :href="supportUrl" target="_blank" class="menu-link">
274
+ <span class="menu-link__icon" aria-hidden="true">
275
+ <svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
276
+ <circle cx="12" cy="12" r="9" />
277
+ <path d="M9.6 9.4a2.5 2.5 0 1 1 3.5 2.3c-.7.3-1.1.8-1.1 1.6" />
278
+ <path d="M12 16.8h.01" />
279
+ </svg>
280
+ </span>
281
+ <span class="menu-link__label">{{ $t("account_menu.buttons.support", "Support") }}</span>
282
+ </a>
283
+ </div>
284
+
285
+ <div class="row info-row logout-row">
286
+ <button class="logout" type="button" @click="handleLogout">
287
+ {{ $t("account_menu.buttons.logout") }}
288
+ </button>
289
+ </div>
254
290
  </div>
255
291
  </section>
256
292
  </div>
@@ -377,6 +413,79 @@ const handleToggleOnline = () => {
377
413
  }
378
414
  }
379
415
 
416
+ // Nickname and an optional suffix (plan badge) on one line; wraps instead of overflowing the 240px menu.
417
+ // Baseline-aligned so a small chip sits on the nickname's line instead of floating above it, with room between them.
418
+ .username-line {
419
+ display: flex;
420
+ align-items: baseline;
421
+ flex-wrap: wrap;
422
+ gap: 4px 12px;
423
+ min-width: 0;
424
+ margin-top: 4px;
425
+
426
+ .username {
427
+ margin-top: 0;
428
+ }
429
+ }
430
+
431
+ // Hosts fill #user-subtitle with a Bootstrap .row; its negative gutter margins pulled the line ~12px left of the
432
+ // nickname and the avatar. The slot's content starts on the same left edge as every other row of the menu.
433
+ .user-subtitle-slot {
434
+ :deep(.row) {
435
+ margin-left: 0;
436
+ margin-right: 0;
437
+ }
438
+ }
439
+
440
+ // One rhythm for the whole menu: 8px between rows of a group; groups are 12px away from their divider line.
441
+ .menu-group {
442
+ display: flex;
443
+ flex-direction: column;
444
+ gap: 8px;
445
+
446
+ & + .menu-group {
447
+ margin-top: 12px;
448
+ padding-top: 12px;
449
+ border-top: 1px solid var(--header-ui-config-border);
450
+ }
451
+ }
452
+
453
+ .menu-group--nav {
454
+ // The host's own links keep their markup; they only get the shared edge.
455
+ gap: 0;
456
+ }
457
+
458
+ .logout-row {
459
+ margin-top: 4px;
460
+ }
461
+
462
+ // Same look as the "What's new" entry (MgWhatsNewMenuItem), so the secondary group reads as one list.
463
+ .menu-link {
464
+ display: flex;
465
+ align-items: center;
466
+ gap: 8px;
467
+ width: 100%;
468
+ padding: 6px 0;
469
+ font-size: 0.8125rem;
470
+ text-decoration: none;
471
+ color: var(--secondary-info-fg, var(--inactive));
472
+
473
+ &:hover,
474
+ &:focus-visible {
475
+ color: var(--active);
476
+ }
477
+
478
+ &__icon {
479
+ display: inline-flex;
480
+ flex: none;
481
+ }
482
+
483
+ &__label {
484
+ flex: 1;
485
+ min-width: 0;
486
+ }
487
+ }
488
+
380
489
  .username {
381
490
  margin-top: 4px;
382
491
  line-height: 1.25rem;
@@ -457,25 +566,6 @@ const handleToggleOnline = () => {
457
566
  }
458
567
  }
459
568
 
460
- .support-link {
461
- display: block;
462
- width: 100%;
463
- text-align: center;
464
- font-size: 0.75rem;
465
- font-weight: 400;
466
- // Deliberately quieter than .plans-pricing-link — this is a low-key
467
- // secondary affordance, not a conversion CTA, so it stays on a muted
468
- // text token instead of each host's accent color.
469
- color: var(--secondary-info-fg, var(--inactive));
470
- text-decoration: none;
471
- padding: 4px 0;
472
- margin-top: 8px;
473
-
474
- &:hover {
475
- text-decoration: underline;
476
- color: var(--active);
477
- }
478
- }
479
569
 
480
570
  .status-toggle {
481
571
  display: flex;
@@ -523,7 +613,8 @@ const handleToggleOnline = () => {
523
613
  position: absolute;
524
614
  inset: 0;
525
615
  cursor: pointer;
526
- background-color: var(--border-card, rgba(255, 255, 255, 0.2));
616
+ // A tint of the row's own text colour: visible on a light menu and on a dark one, no fixed colour.
617
+ background-color: color-mix(in srgb, currentColor 35%, transparent);
527
618
  transition: 0.3s;
528
619
  border-radius: 999px;
529
620
 
@@ -534,7 +625,8 @@ const handleToggleOnline = () => {
534
625
  width: 14px;
535
626
  left: 3px;
536
627
  bottom: 3px;
537
- background-color: #fff;
628
+ // The menu's own background: white on a light menu, dark on a dark one, always against the track.
629
+ background-color: var(--header-ui-config-bg);
538
630
  transition: 0.3s;
539
631
  border-radius: 50%;
540
632
  }
@@ -147,7 +147,7 @@ onMounted(async () => {
147
147
  class="mg-xp-bar"
148
148
  :class="{
149
149
  'mg-xp-bar--compact': props.compact,
150
- 'mg-xp-bar--empty': loaded && !level,
150
+ 'mg-xp-bar--empty': loaded && !level && !(props.showBalance && balance),
151
151
  }"
152
152
  @click="emit('navigate')"
153
153
  >
@@ -172,6 +172,13 @@ onMounted(async () => {
172
172
  </div>
173
173
  </template>
174
174
 
175
+ <!-- No level to draw (the summary failed or is empty), but the host asked for the balance: show just that. -->
176
+ <template v-else-if="loaded && props.showBalance && balance">
177
+ <div class="mg-xp-bar__top">
178
+ <span class="mg-xp-bar__balance">{{ balance }} MGC</span>
179
+ </div>
180
+ </template>
181
+
175
182
  <template v-else>
176
183
  <div class="mg-xp-bar__top">
177
184
  <span class="mg-xp-bar__badge mg-xp-bar__skeleton" />
@@ -0,0 +1,38 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The unread number of the "Novidades" history as a small mark on the avatar. <MgHeaderAvatarToggle /> draws it by
4
+ * itself; a front that builds its own avatar button drops this inside it (the button must be position:relative).
5
+ * Nothing renders when signed out, when the drawer host is not mounted, or when there is nothing unread.
6
+ */
7
+ import { computed } from "vue";
8
+ import { storeToRefs } from "pinia";
9
+ import { formatBadge } from "../../utils/whatsNew";
10
+
11
+ const store = useWhatsNewStore();
12
+ const { signedIn } = storeToRefs(useAuthStore());
13
+
14
+ const text = computed(() => (signedIn.value && store.hostMounted ? formatBadge(store.unread) : ""));
15
+ </script>
16
+
17
+ <template>
18
+ <span v-if="text" class="mg-wn-avatar-badge" aria-hidden="true">{{ text }}</span>
19
+ </template>
20
+
21
+ <style scoped lang="scss">
22
+ // Positioned against the host's avatar wrapper (every host's menu item is position:relative).
23
+ .mg-wn-avatar-badge {
24
+ position: absolute;
25
+ top: -4px;
26
+ inset-inline-end: -4px;
27
+ min-width: 16px;
28
+ height: 16px;
29
+ padding: 0 4px;
30
+ font-size: 0.625rem;
31
+ font-weight: 700;
32
+ line-height: 16px;
33
+ text-align: center;
34
+ color: var(--mg-wn-on-accent);
35
+ background: var(--mg-wn-accent);
36
+ pointer-events: none;
37
+ }
38
+ </style>
@@ -28,7 +28,7 @@ function open() {
28
28
  <template>
29
29
  <button type="button" class="mg-wn-menu-item" :aria-label="label" aria-haspopup="dialog" @click="open">
30
30
  <span class="mg-wn-menu-item__icon" aria-hidden="true">
31
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="square">
31
+ <svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
32
32
  <path d="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z" />
33
33
  <path d="M19 16l.8 2.2L22 19l-2.2.8L19 22l-.8-2.2L16 19l2.2-.8L19 16z" />
34
34
  </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mundogamernetwork/shared-ui",
3
- "version": "1.19.1",
3
+ "version": "1.19.4",
4
4
  "description": "Mundo Gamer Network - Shared UI Layer (Nuxt 3)",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",