@mundogamernetwork/shared-ui 1.19.2 → 1.19.5

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,43 +1,54 @@
1
1
  /*
2
- * Theme tokens of the What's New modal. Colours live ONLY here; the component
3
- * reads them through var(--mg-wn-*) with no literal fallback. A front can
4
- * restyle the modal by redefining any of these in its own theme.
5
- * Light is the default; the dark values apply under @nuxtjs/color-mode's
2
+ * Theme tokens of the What's New modal and drawer. The component reads them
3
+ * through var(--mg-wn-*) with no literal fallback.
4
+ *
5
+ * Surfaces, text, borders and the accent are NOT colours of their own: they
6
+ * alias the variables every front already defines in its own light/dark theme
7
+ * files (the same ones the user menu uses), so the modal always matches the
8
+ * front it is shown in. The accent is the front's strong text colour (and
9
+ * on-accent its surface): the brand accents differ per front and several do
10
+ * not reach 3:1 against the surface in one of the two themes, so a brand-
11
+ * coloured fill or link would be unreadable there. A front that wants its
12
+ * brand colour can redefine --mg-wn-accent / --mg-wn-on-accent.
13
+ * Only the semantic status colours, the scrims and the media chrome are fixed
14
+ * here, because no front theme has a counterpart.
15
+ * A front can still restyle the modal by redefining any --mg-wn-* in its theme.
16
+ *
17
+ * Light is the default; the status values switch under @nuxtjs/color-mode's
6
18
  * `.dark-mode` class (every front sets colorMode.preference).
7
19
  */
20
+ :root,
21
+ .light-mode,
22
+ .dark-mode {
23
+ --mg-wn-surface: var(--header-ui-config-bg);
24
+ --mg-wn-surface-2: var(--body-bg-card);
25
+ --mg-wn-text: var(--active);
26
+ --mg-wn-text-muted: var(--secondary-info-fg);
27
+ --mg-wn-border: var(--header-ui-config-border);
28
+ --mg-wn-accent: var(--active);
29
+ --mg-wn-on-accent: var(--header-ui-config-bg);
30
+ --mg-wn-neutral: var(--secondary-info-fg);
31
+ }
32
+
8
33
  :root,
9
34
  .light-mode {
10
- --mg-wn-overlay: rgba(11, 11, 20, 0.55);
11
- --mg-wn-surface: #ffffff;
12
- --mg-wn-surface-2: #f2f3f7;
13
- --mg-wn-text: #1d2030;
14
- --mg-wn-text-muted: #4f566b;
15
- --mg-wn-border: #dcdfe8;
16
- --mg-wn-accent: #3b38c4;
17
- --mg-wn-on-accent: #ffffff;
18
- --mg-wn-success: #146c43;
19
- --mg-wn-warning: #8a4f00;
20
- --mg-wn-neutral: #4f566b;
21
- --mg-wn-media-bg: #1d2030;
22
- --mg-wn-media-control-bg: rgba(0, 0, 0, 0.66);
23
- --mg-wn-media-control-fg: #ffffff;
24
- --mg-wn-shadow: rgba(0, 0, 0, 0.28);
35
+ /* scrim, status colours and media chrome: no counterpart in the front themes */
36
+ --mg-wn-overlay: rgba(11, 11, 20, 0.55); /* theme-ok: fixed scrim/status/media chrome */
37
+ --mg-wn-success: #146c43; /* theme-ok: fixed scrim/status/media chrome */
38
+ --mg-wn-warning: #8a4f00; /* theme-ok: fixed scrim/status/media chrome */
39
+ --mg-wn-media-bg: #0e0e0e; /* theme-ok: fixed scrim/status/media chrome */
40
+ --mg-wn-media-control-bg: rgba(0, 0, 0, 0.66); /* theme-ok: fixed scrim/status/media chrome */
41
+ --mg-wn-media-control-fg: #ffffff; /* theme-ok: fixed scrim/status/media chrome */
42
+ --mg-wn-shadow: rgba(0, 0, 0, 0.28); /* theme-ok: fixed scrim/status/media chrome */
25
43
  }
26
44
 
27
45
  .dark-mode {
28
- --mg-wn-overlay: rgba(0, 0, 0, 0.66);
29
- --mg-wn-surface: #1c1d2b;
30
- --mg-wn-surface-2: #262838;
31
- --mg-wn-text: #eceef8;
32
- --mg-wn-text-muted: #a9aec6;
33
- --mg-wn-border: #383b52;
34
- --mg-wn-accent: #a3a1ff;
35
- --mg-wn-on-accent: #12121c;
36
- --mg-wn-success: #5fd199;
37
- --mg-wn-warning: #f0b45a;
38
- --mg-wn-neutral: #a9aec6;
39
- --mg-wn-media-bg: #0c0c14;
40
- --mg-wn-media-control-bg: rgba(0, 0, 0, 0.72);
41
- --mg-wn-media-control-fg: #ffffff;
42
- --mg-wn-shadow: rgba(0, 0, 0, 0.6);
46
+ /* scrim, status colours and media chrome: no counterpart in the front themes */
47
+ --mg-wn-overlay: rgba(0, 0, 0, 0.66); /* theme-ok: fixed scrim/status/media chrome */
48
+ --mg-wn-success: #5fd199; /* theme-ok: fixed scrim/status/media chrome */
49
+ --mg-wn-warning: #f0b45a; /* theme-ok: fixed scrim/status/media chrome */
50
+ --mg-wn-media-bg: #050505; /* theme-ok: fixed scrim/status/media chrome */
51
+ --mg-wn-media-control-bg: rgba(0, 0, 0, 0.72); /* theme-ok: fixed scrim/status/media chrome */
52
+ --mg-wn-media-control-fg: #ffffff; /* theme-ok: fixed scrim/status/media chrome */
53
+ --mg-wn-shadow: rgba(0, 0, 0, 0.6); /* theme-ok: fixed scrim/status/media chrome */
43
54
  }
@@ -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">
@@ -195,20 +197,33 @@ const handleToggleOnline = () => {
195
197
  <template #user-subtitle>; hosts without one render nothing here,
196
198
  same as today.
197
199
  -->
198
- <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>
199
213
 
200
- <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">
201
216
  <span class="coins">
202
217
  <MGIcon icon="coin-v2" />
203
218
  {{ Math.floor(user?.coins ?? 0).toLocaleString(locale) }}
204
219
  <span class="coins__currency">MGC</span>
205
220
  </span>
206
221
  </div>
207
-
208
- <div v-if="features.gamification !== false" class="row info-row gamification-row">
209
- <MgXpLevelBar compact :mgc-balance="user?.coins ?? null" :show-balance="false" :locale="locale" />
210
222
  </div>
211
223
 
224
+ <!-- Group 2: your account. -->
225
+ <div class="menu-group menu-group--account">
226
+
212
227
  <!--
213
228
  Optional, empty by default. For a host whose primary CTA (jobs-
214
229
  frontend's "Post a job") and its related stat (companies followed)
@@ -226,18 +241,12 @@ const handleToggleOnline = () => {
226
241
  </div>
227
242
 
228
243
  <div class="row info-row">
229
- <a :href="accountsBaseUrl" target="_blank" class="btn btn-primary-outline mt-3">
244
+ <a :href="accountsBaseUrl" target="_blank" class="btn btn-primary-outline">
230
245
  {{ $t("account_menu.buttons.manage_account") }}
231
246
  </a>
232
247
  </div>
233
248
 
234
- <div class="row info-row">
235
- <a :href="supportUrl" target="_blank" class="support-link">
236
- {{ $t("account_menu.buttons.support", "Support") }}
237
- </a>
238
- </div>
239
-
240
- <div v-if="features.statusOnline" class="row info-row my-3">
249
+ <div v-if="features.statusOnline" class="row info-row">
241
250
  <div class="status-toggle">
242
251
  <span>{{ $t("account_menu.buttons.show_online") }}</span>
243
252
  <label class="switch">
@@ -247,17 +256,37 @@ const handleToggleOnline = () => {
247
256
  </div>
248
257
  </div>
249
258
 
250
- <slot name="extra-menu-items" />
259
+ </div>
251
260
 
252
- <!-- Secondary entry, like a help link: after the account rows, right above Logout. -->
253
- <div v-if="whatsNewHistory && whatsNewStore.hostMounted" class="row info-row whats-new-row">
254
- <MgWhatsNewMenuItem @opened="emit('toggleVisible')" />
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" />
255
264
  </div>
256
265
 
257
- <div class="row info-row my-3">
258
- <button class="logout" type="button" @click="handleLogout">
259
- {{ $t("account_menu.buttons.logout") }}
260
- </button>
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>
261
290
  </div>
262
291
  </section>
263
292
  </div>
@@ -385,16 +414,76 @@ const handleToggleOnline = () => {
385
414
  }
386
415
 
387
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.
388
418
  .username-line {
389
419
  display: flex;
390
- align-items: center;
420
+ align-items: baseline;
391
421
  flex-wrap: wrap;
392
- gap: 4px 8px;
422
+ gap: 4px 12px;
393
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
+ }
394
451
  }
395
452
 
396
- .whats-new-row {
397
- padding-top: 4px;
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
+ }
398
487
  }
399
488
 
400
489
  .username {
@@ -477,25 +566,6 @@ const handleToggleOnline = () => {
477
566
  }
478
567
  }
479
568
 
480
- .support-link {
481
- display: block;
482
- width: 100%;
483
- text-align: center;
484
- font-size: 0.75rem;
485
- font-weight: 400;
486
- // Deliberately quieter than .plans-pricing-link — this is a low-key
487
- // secondary affordance, not a conversion CTA, so it stays on a muted
488
- // text token instead of each host's accent color.
489
- color: var(--secondary-info-fg, var(--inactive));
490
- text-decoration: none;
491
- padding: 4px 0;
492
- margin-top: 8px;
493
-
494
- &:hover {
495
- text-decoration: underline;
496
- color: var(--active);
497
- }
498
- }
499
569
 
500
570
  .status-toggle {
501
571
  display: flex;
@@ -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.2",
3
+ "version": "1.19.5",
4
4
  "description": "Mundo Gamer Network - Shared UI Layer (Nuxt 3)",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",