|
| 1 | +<script setup lang="ts"> |
| 2 | +import { AlertDialog, AlertDialogContent } from "@/components/ui/alert-dialog"; |
| 3 | +import { X } from "lucide-vue-next"; |
| 4 | +</script> |
| 5 | + |
| 6 | +<template> |
| 7 | + <AlertDialog :open="!!shouldShow"> |
| 8 | + <AlertDialogContent |
| 9 | + class="!max-w-md !gap-0 overflow-visible !border-0 !bg-transparent !p-0 !shadow-none" |
| 10 | + > |
| 11 | + <div |
| 12 | + v-if="match" |
| 13 | + class="relative overflow-hidden rounded-lg border border-border px-6 py-8 [backdrop-filter:blur(10px)] [background:linear-gradient(180deg,hsl(var(--card)/0.95)_0%,hsl(var(--card)/0.85)_100%)] [box-shadow:0_0_0_1px_hsl(var(--tac-amber)/0.3),0_0_40px_hsl(var(--tac-amber)/0.18)]" |
| 14 | + > |
| 15 | + <span |
| 16 | + aria-hidden="true" |
| 17 | + class="pointer-events-none absolute left-2 top-2 h-[14px] w-[14px] border-l-2 border-t-2 border-[hsl(var(--tac-amber))]" |
| 18 | + ></span> |
| 19 | + <span |
| 20 | + aria-hidden="true" |
| 21 | + class="pointer-events-none absolute bottom-2 right-2 h-[14px] w-[14px] border-b-2 border-r-2 border-[hsl(var(--tac-amber))]" |
| 22 | + ></span> |
| 23 | + <span |
| 24 | + aria-hidden="true" |
| 25 | + class="pointer-events-none absolute inset-0 opacity-30 [background-image:repeating-linear-gradient(180deg,transparent_0,transparent_3px,hsl(var(--tac-amber)/0.04)_3px,hsl(var(--tac-amber)/0.04)_4px)]" |
| 26 | + ></span> |
| 27 | + |
| 28 | + <div class="relative z-10 flex flex-col items-center gap-5 text-center"> |
| 29 | + <div class="flex flex-col items-center gap-1.5"> |
| 30 | + <div |
| 31 | + class="inline-flex items-center gap-2 font-mono text-[0.72rem] font-bold uppercase tracking-[0.28em] text-[hsl(var(--tac-amber))]" |
| 32 | + > |
| 33 | + <span |
| 34 | + class="inline-block h-[2px] w-[10px] bg-[hsl(var(--tac-amber))]" |
| 35 | + ></span> |
| 36 | + {{ statusLabel }} |
| 37 | + <span |
| 38 | + class="h-1 w-1 rounded-full animate-soft-pulse bg-[hsl(var(--tac-amber))]" |
| 39 | + ></span> |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + |
| 43 | + <div class="flex flex-col items-center gap-1"> |
| 44 | + <div |
| 45 | + class="font-sans text-base font-semibold leading-snug text-foreground" |
| 46 | + > |
| 47 | + {{ matchTitle }} |
| 48 | + </div> |
| 49 | + </div> |
| 50 | + |
| 51 | + <NuxtLink |
| 52 | + :to="`/matches/${match.id}`" |
| 53 | + class="tac-amber-cta relative isolate mt-2 inline-flex w-full items-center justify-center gap-3 overflow-hidden rounded-md border px-6 py-4 font-sans text-sm font-bold uppercase leading-none tracking-[0.22em]" |
| 54 | + @click="acknowledge" |
| 55 | + > |
| 56 | + <span |
| 57 | + class="inline-block h-[2px] w-[12px] bg-[hsl(var(--tac-amber-foreground))]/70" |
| 58 | + ></span> |
| 59 | + {{ $t("matchmaking.go_to_match") }} |
| 60 | + <span |
| 61 | + class="inline-block h-[2px] w-[12px] bg-[hsl(var(--tac-amber-foreground))]/70" |
| 62 | + ></span> |
| 63 | + </NuxtLink> |
| 64 | + |
| 65 | + <div |
| 66 | + class="mt-1 flex flex-col items-center gap-0.5 text-center text-xs leading-snug" |
| 67 | + > |
| 68 | + <span class="text-muted-foreground"> |
| 69 | + {{ $t("matchmaking.disable_match_ready_modal_hint") }} |
| 70 | + </span> |
| 71 | + <NuxtLink |
| 72 | + to="/settings/matchmaking" |
| 73 | + class="text-foreground underline underline-offset-4 decoration-muted-foreground/60 transition-colors hover:text-[hsl(var(--tac-amber))] hover:decoration-[hsl(var(--tac-amber))]" |
| 74 | + @click="acknowledge" |
| 75 | + > |
| 76 | + {{ $t("matchmaking.disable_match_ready_modal_action") }} |
| 77 | + </NuxtLink> |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + |
| 81 | + <button |
| 82 | + type="button" |
| 83 | + class="absolute right-3 top-3 z-20 inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground" |
| 84 | + :aria-label="$t('common.close')" |
| 85 | + @click="acknowledge" |
| 86 | + > |
| 87 | + <X class="h-4 w-4" /> |
| 88 | + </button> |
| 89 | + </div> |
| 90 | + </AlertDialogContent> |
| 91 | + </AlertDialog> |
| 92 | +</template> |
| 93 | + |
| 94 | +<script lang="ts"> |
| 95 | +import { e_match_status_enum } from "~/generated/zeus"; |
| 96 | +import { useMatchLobbyStore } from "~/stores/MatchLobbyStore"; |
| 97 | +import { useMatchmakingStore } from "~/stores/MatchmakingStore"; |
| 98 | +import { useAuthStore } from "~/stores/AuthStore"; |
| 99 | +import { useMatchReadyModal } from "~/composables/useMatchReadyModal"; |
| 100 | +
|
| 101 | +const ALERT_STATUSES: string[] = [ |
| 102 | + e_match_status_enum.WaitingForCheckIn, |
| 103 | + e_match_status_enum.Veto, |
| 104 | + e_match_status_enum.Live, |
| 105 | +]; |
| 106 | +
|
| 107 | +export default { |
| 108 | + setup() { |
| 109 | + const { manuallyOpened } = useMatchReadyModal(); |
| 110 | + return { manuallyOpened }; |
| 111 | + }, |
| 112 | + data() { |
| 113 | + return { |
| 114 | + acknowledgedKey: null as string | null, |
| 115 | + }; |
| 116 | + }, |
| 117 | + computed: { |
| 118 | + match(): any { |
| 119 | + return useMatchLobbyStore().currentMatch; |
| 120 | + }, |
| 121 | + matchKey(): string | null { |
| 122 | + if (!this.match) return null; |
| 123 | + return `${this.match.id}:${this.match.status}`; |
| 124 | + }, |
| 125 | + isAlertable(): boolean { |
| 126 | + return !!this.match && ALERT_STATUSES.includes(this.match.status); |
| 127 | + }, |
| 128 | + hasActiveMatchmakingConfirmation(): boolean { |
| 129 | + const confirmation = |
| 130 | + useMatchmakingStore().joinedMatchmakingQueues?.confirmation; |
| 131 | + return !!confirmation && !confirmation.matchId; |
| 132 | + }, |
| 133 | + showPref(): boolean { |
| 134 | + return useAuthStore().me?.show_match_ready_modal !== false; |
| 135 | + }, |
| 136 | + isOnMatchPage(): boolean { |
| 137 | + const path = this.$route?.path || ""; |
| 138 | + return !!this.match && path.startsWith(`/matches/${this.match.id}`); |
| 139 | + }, |
| 140 | + shouldShow(): boolean { |
| 141 | + if (!this.isAlertable) return false; |
| 142 | + if (this.hasActiveMatchmakingConfirmation) return false; |
| 143 | + if (this.isOnMatchPage) return false; |
| 144 | + if (this.acknowledgedKey && this.acknowledgedKey === this.matchKey) { |
| 145 | + return false; |
| 146 | + } |
| 147 | + return this.showPref || this.manuallyOpened; |
| 148 | + }, |
| 149 | + statusLabel(): string { |
| 150 | + return ( |
| 151 | + this.match?.e_match_status?.description || |
| 152 | + this.match?.status || |
| 153 | + "" |
| 154 | + ); |
| 155 | + }, |
| 156 | + matchTitle(): string { |
| 157 | + const a = this.match?.lineup_1?.name || this.$t("common.tbd"); |
| 158 | + const b = this.match?.lineup_2?.name || this.$t("common.tbd"); |
| 159 | + return `${a} vs ${b}`; |
| 160 | + }, |
| 161 | + }, |
| 162 | + watch: { |
| 163 | + matchKey(next, prev) { |
| 164 | + if (next !== prev && this.acknowledgedKey !== next) { |
| 165 | + this.acknowledgedKey = null; |
| 166 | + } |
| 167 | + }, |
| 168 | + }, |
| 169 | + methods: { |
| 170 | + acknowledge() { |
| 171 | + this.acknowledgedKey = this.matchKey; |
| 172 | + useMatchReadyModal().closeMatchReadyModal(); |
| 173 | + }, |
| 174 | + }, |
| 175 | +}; |
| 176 | +</script> |
0 commit comments