@mundogamernetwork/shared-ui 1.17.17 → 1.18.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.
- package/README.md +23 -0
- package/assets/kit/kit-base.css +47 -0
- package/assets/whats-new/tokens.css +43 -0
- package/components/ui/MgBanners.vue +13 -0
- package/components/whats-new/MgWhatsNewDialog.vue +552 -0
- package/components/whats-new/MgWhatsNewMedia.vue +242 -0
- package/components/whats-new/MgWhatsNewModal.vue +285 -0
- package/components/whats-new/MgWhatsNewRichText.vue +90 -0
- package/nuxt.config.ts +11 -0
- package/package.json +3 -2
- package/pages/contact.vue +8 -1
- package/pages/presskit/game/[slug].vue +29 -1
- package/pages/whats-new-preview.vue +96 -0
- package/services/creatorNetworkProgramService.ts +47 -0
- package/services/documentService.ts +16 -4
- package/stores/whatsNew.ts +170 -0
- package/utils/whatsNew.ts +300 -0
- package/utils/whatsNewMessages.ts +133 -0
- package/utils/whatsNewText.ts +10 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
|
3
|
+
import { embedSrc, safeMediaUrl, type WnMedia } from "../../utils/whatsNew";
|
|
4
|
+
import { wnText } from "../../utils/whatsNewText";
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{ media: WnMedia; locale: string }>();
|
|
7
|
+
const emit = defineEmits<{ (e: "video-play"): void }>();
|
|
8
|
+
|
|
9
|
+
const text = (key: Parameters<typeof wnText>[1]) => wnText(props.locale, key);
|
|
10
|
+
|
|
11
|
+
// Reduced motion or data saver → never start anything on its own; poster only.
|
|
12
|
+
const calm = ref(false);
|
|
13
|
+
const videoEl = ref<HTMLVideoElement | null>(null);
|
|
14
|
+
const playing = ref(false);
|
|
15
|
+
const embedActive = ref(false);
|
|
16
|
+
const failed = ref(false);
|
|
17
|
+
let playReported = false;
|
|
18
|
+
|
|
19
|
+
onMounted(() => {
|
|
20
|
+
try {
|
|
21
|
+
const connection: any = (navigator as any).connection;
|
|
22
|
+
calm.value =
|
|
23
|
+
window.matchMedia("(prefers-reduced-motion: reduce)").matches || !!connection?.saveData;
|
|
24
|
+
} catch {
|
|
25
|
+
calm.value = false;
|
|
26
|
+
}
|
|
27
|
+
if (videoEl.value) videoEl.value.muted = true;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
onBeforeUnmount(() => {
|
|
31
|
+
videoEl.value?.pause();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const ratio = computed(() => {
|
|
35
|
+
const { width, height } = props.media;
|
|
36
|
+
return width && height ? `${width} / ${height}` : "16 / 9";
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const description = computed(() => props.media.description || "");
|
|
40
|
+
const isMotion = computed(() => props.media.type === "gif" || props.media.type === "video_upload");
|
|
41
|
+
// A gif is shown as the poster when the visitor asked for calm and a poster exists.
|
|
42
|
+
const mediaUrl = computed(() => safeMediaUrl(props.media.url));
|
|
43
|
+
const posterUrl = computed(() => safeMediaUrl(props.media.poster_url));
|
|
44
|
+
const imageSrc = computed(() => {
|
|
45
|
+
if (props.media.type === "gif" && calm.value && posterUrl.value) return posterUrl.value;
|
|
46
|
+
return mediaUrl.value;
|
|
47
|
+
});
|
|
48
|
+
const embedUrl = computed(() =>
|
|
49
|
+
props.media.embed ? embedSrc(props.media.embed.provider, props.media.embed.id) : null,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
function reportPlay() {
|
|
53
|
+
if (playReported) return;
|
|
54
|
+
playReported = true;
|
|
55
|
+
emit("video-play");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function onVideoPlay() {
|
|
59
|
+
playing.value = true;
|
|
60
|
+
reportPlay();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function toggleVideo() {
|
|
64
|
+
const el = videoEl.value;
|
|
65
|
+
if (!el) return;
|
|
66
|
+
if (el.paused) {
|
|
67
|
+
try {
|
|
68
|
+
await el.play();
|
|
69
|
+
} catch {
|
|
70
|
+
failed.value = true;
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
el.pause();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function startEmbed() {
|
|
78
|
+
embedActive.value = true;
|
|
79
|
+
reportPlay();
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<template>
|
|
84
|
+
<figure class="mg-wn-media">
|
|
85
|
+
<div class="mg-wn-media__frame" :style="{ aspectRatio: ratio }">
|
|
86
|
+
<!-- image / gif -->
|
|
87
|
+
<img
|
|
88
|
+
v-if="(media.type === 'image' || media.type === 'gif') && imageSrc"
|
|
89
|
+
class="mg-wn-media__fill"
|
|
90
|
+
:src="imageSrc"
|
|
91
|
+
:alt="description"
|
|
92
|
+
:width="media.width || undefined"
|
|
93
|
+
:height="media.height || undefined"
|
|
94
|
+
decoding="async"
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
<!-- uploaded video: muted loop, with a pause control -->
|
|
98
|
+
<template v-else-if="media.type === 'video_upload' && mediaUrl && !failed">
|
|
99
|
+
<video
|
|
100
|
+
ref="videoEl"
|
|
101
|
+
class="mg-wn-media__fill"
|
|
102
|
+
:src="mediaUrl || undefined"
|
|
103
|
+
:poster="posterUrl || undefined"
|
|
104
|
+
:autoplay="!calm"
|
|
105
|
+
:aria-label="description"
|
|
106
|
+
muted
|
|
107
|
+
loop
|
|
108
|
+
playsinline
|
|
109
|
+
preload="metadata"
|
|
110
|
+
@play="onVideoPlay"
|
|
111
|
+
@pause="playing = false"
|
|
112
|
+
@error="failed = true"
|
|
113
|
+
/>
|
|
114
|
+
<button type="button" class="mg-wn-media__control" @click="toggleVideo">
|
|
115
|
+
{{ playing ? text("pause") : text("play") }}
|
|
116
|
+
</button>
|
|
117
|
+
</template>
|
|
118
|
+
|
|
119
|
+
<!-- embed: facade first, the cookie-less player only after a tap -->
|
|
120
|
+
<template v-else-if="media.type === 'video_embed' && embedUrl">
|
|
121
|
+
<iframe
|
|
122
|
+
v-if="embedActive"
|
|
123
|
+
class="mg-wn-media__fill"
|
|
124
|
+
:src="embedUrl"
|
|
125
|
+
:title="description || text('media_label')"
|
|
126
|
+
allow="autoplay; encrypted-media; picture-in-picture; fullscreen"
|
|
127
|
+
referrerpolicy="strict-origin-when-cross-origin"
|
|
128
|
+
allowfullscreen
|
|
129
|
+
/>
|
|
130
|
+
<template v-else>
|
|
131
|
+
<img
|
|
132
|
+
v-if="posterUrl"
|
|
133
|
+
class="mg-wn-media__fill"
|
|
134
|
+
:src="posterUrl"
|
|
135
|
+
alt=""
|
|
136
|
+
decoding="async"
|
|
137
|
+
/>
|
|
138
|
+
<button type="button" class="mg-wn-media__facade" @click="startEmbed">
|
|
139
|
+
<span class="mg-wn-media__play" aria-hidden="true">▶</span>
|
|
140
|
+
<span class="mg-wn-media__facade-label">{{ text("watch") }}</span>
|
|
141
|
+
</button>
|
|
142
|
+
</template>
|
|
143
|
+
</template>
|
|
144
|
+
|
|
145
|
+
<!-- load failure: the poster stays, the modal keeps working -->
|
|
146
|
+
<img
|
|
147
|
+
v-else-if="posterUrl"
|
|
148
|
+
class="mg-wn-media__fill"
|
|
149
|
+
:src="posterUrl"
|
|
150
|
+
alt=""
|
|
151
|
+
decoding="async"
|
|
152
|
+
/>
|
|
153
|
+
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<figcaption v-if="description && (isMotion || media.type === 'video_embed')" class="mg-wn-media__caption">
|
|
157
|
+
{{ description }}
|
|
158
|
+
</figcaption>
|
|
159
|
+
</figure>
|
|
160
|
+
</template>
|
|
161
|
+
|
|
162
|
+
<style lang="scss" scoped>
|
|
163
|
+
.mg-wn-media {
|
|
164
|
+
display: block;
|
|
165
|
+
margin: 0;
|
|
166
|
+
width: 100%;
|
|
167
|
+
|
|
168
|
+
&__frame {
|
|
169
|
+
position: relative;
|
|
170
|
+
width: 100%;
|
|
171
|
+
overflow: hidden;
|
|
172
|
+
border-radius: 0;
|
|
173
|
+
background: var(--mg-wn-media-bg);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&__fill {
|
|
177
|
+
position: absolute;
|
|
178
|
+
inset: 0;
|
|
179
|
+
width: 100%;
|
|
180
|
+
height: 100%;
|
|
181
|
+
object-fit: cover;
|
|
182
|
+
border: 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&__control {
|
|
186
|
+
position: absolute;
|
|
187
|
+
inset-inline-end: 8px;
|
|
188
|
+
inset-block-end: 8px;
|
|
189
|
+
padding: 4px 10px;
|
|
190
|
+
font: inherit;
|
|
191
|
+
font-size: 0.75rem;
|
|
192
|
+
font-weight: 600;
|
|
193
|
+
color: var(--mg-wn-media-control-fg);
|
|
194
|
+
background: var(--mg-wn-media-control-bg);
|
|
195
|
+
border: 0;
|
|
196
|
+
border-radius: 0;
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
&__facade {
|
|
201
|
+
position: absolute;
|
|
202
|
+
inset: 0;
|
|
203
|
+
display: flex;
|
|
204
|
+
flex-direction: column;
|
|
205
|
+
align-items: center;
|
|
206
|
+
justify-content: center;
|
|
207
|
+
gap: 8px;
|
|
208
|
+
width: 100%;
|
|
209
|
+
padding: 0;
|
|
210
|
+
color: var(--mg-wn-media-control-fg);
|
|
211
|
+
background: transparent;
|
|
212
|
+
border: 0;
|
|
213
|
+
cursor: pointer;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
&__play {
|
|
217
|
+
display: grid;
|
|
218
|
+
place-items: center;
|
|
219
|
+
width: 52px;
|
|
220
|
+
height: 52px;
|
|
221
|
+
font-size: 1.25rem;
|
|
222
|
+
background: var(--mg-wn-media-control-bg);
|
|
223
|
+
border-radius: 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
&__facade-label {
|
|
227
|
+
padding: 2px 10px;
|
|
228
|
+
font-size: 0.8125rem;
|
|
229
|
+
font-weight: 600;
|
|
230
|
+
background: var(--mg-wn-media-control-bg);
|
|
231
|
+
border-radius: 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// The description is the transcript/alt for sighted users too (decision A).
|
|
235
|
+
&__caption {
|
|
236
|
+
margin: 6px 2px 0;
|
|
237
|
+
font-size: 0.78rem;
|
|
238
|
+
line-height: 1.4;
|
|
239
|
+
color: var(--mg-wn-text-muted);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
</style>
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* "Novidades da Rede" — mount once in a logged-in layout next to <MgBanners />.
|
|
4
|
+
*
|
|
5
|
+
* <MgWhatsNewModal :suppress="discoveryHubOpen" :blocked-routes="['/wallet']" />
|
|
6
|
+
*
|
|
7
|
+
* The backend decides WHAT to show (one eligible comunicado per `pending` call);
|
|
8
|
+
* this component only decides WHEN: logged in, an allowed route, 2.5 s of
|
|
9
|
+
* idleness, nothing else open, once per session and ≥24 h between showings.
|
|
10
|
+
* No comunicado from the API = nothing renders, so the backend is the flag.
|
|
11
|
+
*/
|
|
12
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
13
|
+
import { WN_IDLE_MS, WN_MIN_GAP_MS, gate, toApiLang, type WnPost } from "../../utils/whatsNew";
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(
|
|
16
|
+
defineProps<{
|
|
17
|
+
/** Overrides auth detection (layouts that already know). */
|
|
18
|
+
loggedIn?: boolean;
|
|
19
|
+
/** When set, the modal only opens on these routes (prefix strings or RegExp). */
|
|
20
|
+
allowedRoutes?: (string | RegExp)[];
|
|
21
|
+
/** Extra routes where the modal must never interrupt, on top of the built-in list. */
|
|
22
|
+
blockedRoutes?: (string | RegExp)[];
|
|
23
|
+
/** The host app has its own modal/tour open: keep the comunicado queued. */
|
|
24
|
+
suppress?: boolean;
|
|
25
|
+
/** Locale override (admin preview); defaults to the vue-i18n locale. */
|
|
26
|
+
locale?: string;
|
|
27
|
+
/** Preview mode: no fetch, no receipts, no eligibility rules. */
|
|
28
|
+
preview?: boolean;
|
|
29
|
+
/** The post to render in preview mode (admin iframe / QA). */
|
|
30
|
+
previewPost?: WnPost | null;
|
|
31
|
+
/** Custom "does this in-app route exist" check; defaults to the router. */
|
|
32
|
+
hasRoute?: (path: string) => boolean;
|
|
33
|
+
}>(),
|
|
34
|
+
{
|
|
35
|
+
loggedIn: undefined,
|
|
36
|
+
allowedRoutes: () => [],
|
|
37
|
+
blockedRoutes: () => [],
|
|
38
|
+
suppress: false,
|
|
39
|
+
locale: undefined,
|
|
40
|
+
preview: false,
|
|
41
|
+
previewPost: null,
|
|
42
|
+
hasRoute: undefined,
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const emit = defineEmits<{ (e: "closed"): void }>();
|
|
47
|
+
|
|
48
|
+
const store = useWhatsNewStore();
|
|
49
|
+
const route = useRoute();
|
|
50
|
+
const router = useRouter();
|
|
51
|
+
|
|
52
|
+
const i18nLocale = (() => {
|
|
53
|
+
try {
|
|
54
|
+
return useI18n().locale;
|
|
55
|
+
} catch {
|
|
56
|
+
return ref("en");
|
|
57
|
+
}
|
|
58
|
+
})();
|
|
59
|
+
const localePath: ((p: string) => string) | null = (() => {
|
|
60
|
+
try {
|
|
61
|
+
return useLocalePath() as any;
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
})();
|
|
66
|
+
const auth: any = (() => {
|
|
67
|
+
try {
|
|
68
|
+
return useAuthStore();
|
|
69
|
+
} catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
73
|
+
|
|
74
|
+
const isPreview = computed(() => props.preview || !!props.previewPost);
|
|
75
|
+
const uiLocale = computed(() => props.locale || i18nLocale.value || "en");
|
|
76
|
+
|
|
77
|
+
const isLoggedIn = computed(() => (props.loggedIn !== undefined ? props.loggedIn : !!auth?.signedIn));
|
|
78
|
+
const identity = computed(() =>
|
|
79
|
+
isLoggedIn.value ? String(auth?.user?.uuid ?? auth?.user?.id ?? "user") : null,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// ── in-app route resolution (CTA, inline links, "see all") ─────────────────
|
|
83
|
+
function resolveInternal(path: string): string | null {
|
|
84
|
+
if (!path.startsWith("/") || path.startsWith("//")) return null;
|
|
85
|
+
const target = localePath ? localePath(path) : path;
|
|
86
|
+
if (props.hasRoute) return props.hasRoute(path) ? target : null;
|
|
87
|
+
try {
|
|
88
|
+
const resolved = router.resolve(target);
|
|
89
|
+
const real = resolved.matched.some((m) => !/\(\.\*\)|:pathMatch|\*\*/.test(m.path));
|
|
90
|
+
return real ? target : null;
|
|
91
|
+
} catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ── preview mode ───────────────────────────────────────────────────────────
|
|
97
|
+
const previewOpen = ref(true);
|
|
98
|
+
watch(
|
|
99
|
+
() => props.previewPost,
|
|
100
|
+
() => {
|
|
101
|
+
previewOpen.value = true;
|
|
102
|
+
},
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const activePost = computed<WnPost | null>(() => {
|
|
106
|
+
if (isPreview.value) return previewOpen.value ? props.previewPost : null;
|
|
107
|
+
return store.open ? store.post : null;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// ── when to open ───────────────────────────────────────────────────────────
|
|
111
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
112
|
+
|
|
113
|
+
function clearTimer() {
|
|
114
|
+
if (timer) clearTimeout(timer);
|
|
115
|
+
timer = null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Another dialog (not ours) is up: Bootstrap-style, native <dialog>, any aria-modal, or a driver.js tour. */
|
|
119
|
+
function otherModalOpen(): boolean {
|
|
120
|
+
if (typeof document === "undefined") return false;
|
|
121
|
+
if (document.querySelector(".driver-popover, .driver-overlay")) return true;
|
|
122
|
+
const generic = document.querySelectorAll('[role="dialog"][aria-modal="true"], dialog[open], .modal.show');
|
|
123
|
+
for (const el of Array.from(generic)) {
|
|
124
|
+
if (!el.closest("[data-mg-wn]") && (el as HTMLElement).getClientRects().length > 0) return true;
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function evaluate() {
|
|
130
|
+
return gate({
|
|
131
|
+
loggedIn: isLoggedIn.value,
|
|
132
|
+
path: route.path,
|
|
133
|
+
allowedRoutes: props.allowedRoutes,
|
|
134
|
+
blockedRoutes: props.blockedRoutes,
|
|
135
|
+
shownThisSession: store.shownThisSession,
|
|
136
|
+
lastShownAt: store.lastShownAt(),
|
|
137
|
+
now: Date.now(),
|
|
138
|
+
suppressed: props.suppress,
|
|
139
|
+
otherModalOpen: otherModalOpen(),
|
|
140
|
+
pageVisible: document.visibilityState !== "hidden",
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function attempt() {
|
|
145
|
+
timer = null;
|
|
146
|
+
if (!store.post || store.open) return;
|
|
147
|
+
const result = evaluate();
|
|
148
|
+
if (result === "ok") {
|
|
149
|
+
store.show();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// Transient blockers: stay queued and look again. A blocked route or an
|
|
153
|
+
// exhausted session/gap waits for the next route change instead.
|
|
154
|
+
if (result === "suppressed" || result === "other_modal" || result === "hidden") {
|
|
155
|
+
timer = setTimeout(attempt, WN_IDLE_MS);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function schedule() {
|
|
160
|
+
clearTimer();
|
|
161
|
+
if (isPreview.value || !store.post || store.open) return;
|
|
162
|
+
const result = evaluate();
|
|
163
|
+
if (result === "logged_out" || result === "session" || result === "gap") return;
|
|
164
|
+
timer = setTimeout(attempt, WN_IDLE_MS);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function ensureFetched() {
|
|
168
|
+
if (isPreview.value) return;
|
|
169
|
+
const id = identity.value;
|
|
170
|
+
if (!id) {
|
|
171
|
+
store.reset();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (store.fetchedFor && store.fetchedFor !== id) store.reset();
|
|
175
|
+
if (store.shownThisSession) return;
|
|
176
|
+
const last = store.lastShownAt();
|
|
177
|
+
if (last !== null && Date.now() - last < WN_MIN_GAP_MS) return;
|
|
178
|
+
await store.fetchPending(id, toApiLang(uiLocale.value));
|
|
179
|
+
schedule();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
watch(identity, () => ensureFetched());
|
|
183
|
+
watch(() => route.fullPath, schedule);
|
|
184
|
+
watch(() => props.suppress, schedule);
|
|
185
|
+
watch(() => store.post, schedule);
|
|
186
|
+
|
|
187
|
+
function onVisibility() {
|
|
188
|
+
if (document.visibilityState === "visible") schedule();
|
|
189
|
+
else store.flush();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
onMounted(() => {
|
|
193
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
194
|
+
window.addEventListener("pagehide", store.flush);
|
|
195
|
+
ensureFetched();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
onBeforeUnmount(() => {
|
|
199
|
+
clearTimer();
|
|
200
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
201
|
+
window.removeEventListener("pagehide", store.flush);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// ── dialog events ──────────────────────────────────────────────────────────
|
|
205
|
+
function onClose() {
|
|
206
|
+
if (isPreview.value) {
|
|
207
|
+
previewOpen.value = false;
|
|
208
|
+
emit("closed");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
store.track("dismiss");
|
|
212
|
+
store.hide();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function onCta() {
|
|
216
|
+
if (isPreview.value) return;
|
|
217
|
+
store.track("cta_click");
|
|
218
|
+
store.track("dismiss");
|
|
219
|
+
store.hide();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function onNavigate(path: string) {
|
|
223
|
+
if (isPreview.value) return;
|
|
224
|
+
// A link click is neither "seen" nor "dismissed": just get out of the way.
|
|
225
|
+
if (store.open) store.hide();
|
|
226
|
+
router.push(path);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function onLink(target: string) {
|
|
230
|
+
if (!isPreview.value) store.track("link_click", target);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function onVideoPlay() {
|
|
234
|
+
if (!isPreview.value) store.track("video_play");
|
|
235
|
+
}
|
|
236
|
+
</script>
|
|
237
|
+
|
|
238
|
+
<template>
|
|
239
|
+
<ClientOnly>
|
|
240
|
+
<Teleport to="body">
|
|
241
|
+
<Transition name="mg-wn-fade">
|
|
242
|
+
<MgWhatsNewDialog
|
|
243
|
+
v-if="activePost"
|
|
244
|
+
:post="activePost"
|
|
245
|
+
:locale="uiLocale"
|
|
246
|
+
:resolve-internal="resolveInternal"
|
|
247
|
+
@close="onClose"
|
|
248
|
+
@cta="onCta"
|
|
249
|
+
@navigate="onNavigate"
|
|
250
|
+
@link="onLink"
|
|
251
|
+
@video-play="onVideoPlay"
|
|
252
|
+
/>
|
|
253
|
+
</Transition>
|
|
254
|
+
</Teleport>
|
|
255
|
+
</ClientOnly>
|
|
256
|
+
</template>
|
|
257
|
+
|
|
258
|
+
<style lang="scss">
|
|
259
|
+
.mg-wn-fade-enter-active,
|
|
260
|
+
.mg-wn-fade-leave-active {
|
|
261
|
+
transition: opacity 0.2s ease;
|
|
262
|
+
|
|
263
|
+
.mg-wn-panel {
|
|
264
|
+
transition: transform 0.2s ease;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.mg-wn-fade-enter-from,
|
|
269
|
+
.mg-wn-fade-leave-to {
|
|
270
|
+
opacity: 0;
|
|
271
|
+
|
|
272
|
+
.mg-wn-panel {
|
|
273
|
+
transform: translateY(12px) scale(0.98);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
@media (prefers-reduced-motion: reduce) {
|
|
278
|
+
.mg-wn-fade-enter-active,
|
|
279
|
+
.mg-wn-fade-leave-active,
|
|
280
|
+
.mg-wn-fade-enter-active .mg-wn-panel,
|
|
281
|
+
.mg-wn-fade-leave-active .mg-wn-panel {
|
|
282
|
+
transition: none;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
</style>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent, h, type PropType, type VNode } from "vue";
|
|
3
|
+
import { parseRich, type WnNode } from "../../utils/whatsNew";
|
|
4
|
+
import { wnText } from "../../utils/whatsNewText";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Renders server text (`**bold**` + `[text](url)`) as real Vue nodes. There is
|
|
8
|
+
* no v-html anywhere: text is a text node, bold is <strong>, links are <a>.
|
|
9
|
+
*/
|
|
10
|
+
export default defineComponent({
|
|
11
|
+
name: "MgWhatsNewRichText",
|
|
12
|
+
props: {
|
|
13
|
+
text: { type: String as PropType<string | null>, default: null },
|
|
14
|
+
// false flattens links to their label (the whole item is already a link).
|
|
15
|
+
allowLinks: { type: Boolean, default: true },
|
|
16
|
+
locale: { type: String, default: "en" },
|
|
17
|
+
// Returns the final in-app path, or null when this front has no such route.
|
|
18
|
+
resolveInternal: { type: Function as PropType<(path: string) => string | null>, default: null },
|
|
19
|
+
},
|
|
20
|
+
emits: ["link", "navigate"],
|
|
21
|
+
setup(props, { emit }) {
|
|
22
|
+
const render = (nodes: WnNode[]): (VNode | string)[] =>
|
|
23
|
+
nodes.map((node) => {
|
|
24
|
+
if (node.type === "text") return node.text;
|
|
25
|
+
if (node.type === "bold") return h("strong", node.text);
|
|
26
|
+
const children = render(node.children);
|
|
27
|
+
if (node.kind === "internal") {
|
|
28
|
+
const resolved = props.resolveInternal ? props.resolveInternal(node.href) : null;
|
|
29
|
+
// No such route in this front → show the words, not a dead link.
|
|
30
|
+
if (!resolved) return h("span", children);
|
|
31
|
+
return h(
|
|
32
|
+
"a",
|
|
33
|
+
{
|
|
34
|
+
class: "mg-wn-link",
|
|
35
|
+
href: resolved,
|
|
36
|
+
onClick: (event: MouseEvent) => {
|
|
37
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return;
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
emit("link", node.href);
|
|
40
|
+
emit("navigate", resolved);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
children,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return h(
|
|
47
|
+
"a",
|
|
48
|
+
{
|
|
49
|
+
class: "mg-wn-link",
|
|
50
|
+
href: node.href,
|
|
51
|
+
target: "_blank",
|
|
52
|
+
rel: "noopener noreferrer",
|
|
53
|
+
onClick: () => emit("link", node.href),
|
|
54
|
+
},
|
|
55
|
+
[...children, h("span", { class: "mg-wn-sr" }, ` (${wnText(props.locale, "new_tab")})`)],
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return () => h("span", { class: "mg-wn-rich" }, render(parseRich(props.text, props.allowLinks)));
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<style lang="scss" scoped>
|
|
65
|
+
.mg-wn-rich {
|
|
66
|
+
overflow-wrap: anywhere;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.mg-wn-link {
|
|
70
|
+
color: var(--mg-wn-accent);
|
|
71
|
+
text-decoration: underline;
|
|
72
|
+
text-underline-offset: 2px;
|
|
73
|
+
|
|
74
|
+
&:hover {
|
|
75
|
+
text-decoration-thickness: 2px;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.mg-wn-sr {
|
|
80
|
+
position: absolute;
|
|
81
|
+
width: 1px;
|
|
82
|
+
height: 1px;
|
|
83
|
+
margin: -1px;
|
|
84
|
+
padding: 0;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
clip: rect(0, 0, 0, 0);
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
border: 0;
|
|
89
|
+
}
|
|
90
|
+
</style>
|
package/nuxt.config.ts
CHANGED
|
@@ -123,11 +123,13 @@ export default defineNuxtConfig({
|
|
|
123
123
|
`${packageRoot}/stores/announcement.ts`,
|
|
124
124
|
`${packageRoot}/stores/appInstallBanner.ts`,
|
|
125
125
|
`${packageRoot}/stores/promotion.ts`,
|
|
126
|
+
`${packageRoot}/stores/whatsNew.ts`,
|
|
126
127
|
],
|
|
127
128
|
},
|
|
128
129
|
css: [
|
|
129
130
|
`${packageRoot}/assets/kit/kit-base.css`,
|
|
130
131
|
`${packageRoot}/assets/kit/kit-theme.css`,
|
|
132
|
+
`${packageRoot}/assets/whats-new/tokens.css`,
|
|
131
133
|
],
|
|
132
134
|
runtimeConfig: {
|
|
133
135
|
public: {
|
|
@@ -155,6 +157,15 @@ export default defineNuxtConfig({
|
|
|
155
157
|
// with no gamification data for its users can set this to false.
|
|
156
158
|
gamification: true,
|
|
157
159
|
},
|
|
160
|
+
// "Novidades da Rede" modal, mounted by <MgBanners />. Routes are path
|
|
161
|
+
// prefixes (locale prefix ignored); allowedRoutes empty = any logged-in
|
|
162
|
+
// route that is not blocked. blockedRoutes add to the built-in list
|
|
163
|
+
// (login, signup, checkout, payment, create/publish/upload...).
|
|
164
|
+
whatsNew: {
|
|
165
|
+
enabled: true,
|
|
166
|
+
allowedRoutes: [] as string[],
|
|
167
|
+
blockedRoutes: [] as string[],
|
|
168
|
+
},
|
|
158
169
|
languages: ["pt-BR", "en", "es", "de", "ro"],
|
|
159
170
|
protectedRoutes: [] as string[],
|
|
160
171
|
chatEndpoints: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mundogamernetwork/shared-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "Mundo Gamer Network - Shared UI Layer (Nuxt 3)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"dev": "nuxi dev .playground",
|
|
28
|
-
"build": "nuxi build .playground"
|
|
28
|
+
"build": "nuxi build .playground",
|
|
29
|
+
"test": "npx --yes vitest@2.1.9 run"
|
|
29
30
|
},
|
|
30
31
|
"peerDependencies": {
|
|
31
32
|
"@pinia-plugin-persistedstate/nuxt": ">=1.0.0",
|
package/pages/contact.vue
CHANGED
|
@@ -64,7 +64,12 @@ watchEffect(() => { if (formData.value.message) inputErrors.value.message.status
|
|
|
64
64
|
watchEffect(() => { if (formData.value.subject_id) inputErrors.value.subject_id.status = false; });
|
|
65
65
|
watchEffect(() => { if (formData.value.country_id) inputErrors.value.country_id.status = false; });
|
|
66
66
|
|
|
67
|
+
// A double click used to send the message twice; the second answer replaced the success dialog with an error.
|
|
68
|
+
const sending = ref(false);
|
|
69
|
+
|
|
67
70
|
const submitForm = async () => {
|
|
71
|
+
if (sending.value) return;
|
|
72
|
+
sending.value = true;
|
|
68
73
|
try {
|
|
69
74
|
const data = {
|
|
70
75
|
...formData.value,
|
|
@@ -94,6 +99,8 @@ const submitForm = async () => {
|
|
|
94
99
|
modalMessage.value = String($t("more.contact.message_popup.error") || "There was an error sending your message. Please try again.");
|
|
95
100
|
showModal.value = true;
|
|
96
101
|
}
|
|
102
|
+
} finally {
|
|
103
|
+
sending.value = false;
|
|
97
104
|
}
|
|
98
105
|
};
|
|
99
106
|
|
|
@@ -170,7 +177,7 @@ const { $t } = useNuxtApp().$i18n;
|
|
|
170
177
|
<span v-if="inputErrors.message.status" class="error-msg">{{ inputErrors.message.error }}</span>
|
|
171
178
|
</div>
|
|
172
179
|
|
|
173
|
-
<button type="submit" class="btn-contact">
|
|
180
|
+
<button type="submit" class="btn-contact" :disabled="sending">
|
|
174
181
|
{{ $t("more.contact.btn_send_message") }}
|
|
175
182
|
</button>
|
|
176
183
|
</form>
|