mirror of
https://github.com/modrinth/code.git
synced 2026-09-03 13:36:48 +00:00
fix: bring back signal icon for ping and players online
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
|||||||
MoreVerticalIcon,
|
MoreVerticalIcon,
|
||||||
NoSignalIcon,
|
NoSignalIcon,
|
||||||
PlayIcon,
|
PlayIcon,
|
||||||
|
SignalIcon,
|
||||||
SkullIcon,
|
SkullIcon,
|
||||||
SpinnerIcon,
|
SpinnerIcon,
|
||||||
StopCircleIcon,
|
StopCircleIcon,
|
||||||
@@ -25,15 +26,17 @@ import {
|
|||||||
commonMessages,
|
commonMessages,
|
||||||
defineMessages,
|
defineMessages,
|
||||||
injectNotificationManager,
|
injectNotificationManager,
|
||||||
ServerOnlinePlayers,
|
|
||||||
SmartClickable,
|
SmartClickable,
|
||||||
TagItem,
|
TagItem,
|
||||||
TeleportOverflowMenu,
|
TeleportOverflowMenu,
|
||||||
useFormatDateTime,
|
useFormatDateTime,
|
||||||
|
useFormatNumber,
|
||||||
useRelativeTime,
|
useRelativeTime,
|
||||||
useVIntl,
|
useVIntl,
|
||||||
} from '@modrinth/ui'
|
} from '@modrinth/ui'
|
||||||
|
import { getPingLevel } from '@modrinth/utils'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
import { Tooltip } from 'floating-vue'
|
||||||
import type { Component } from 'vue'
|
import type { Component } from 'vue'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
@@ -53,6 +56,7 @@ import { LockIcon } from '../../../../../../packages/assets/generated-icons'
|
|||||||
|
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
const formatRelativeTime = useRelativeTime()
|
const formatRelativeTime = useRelativeTime()
|
||||||
|
const formatNumber = useFormatNumber()
|
||||||
const formatDateTime = useFormatDateTime({
|
const formatDateTime = useFormatDateTime({
|
||||||
timeStyle: 'short',
|
timeStyle: 'short',
|
||||||
dateStyle: 'long',
|
dateStyle: 'long',
|
||||||
@@ -121,6 +125,9 @@ const props = withDefaults(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const playingOtherWorld = computed(() => props.playingInstance && !props.playingWorld)
|
const playingOtherWorld = computed(() => props.playingInstance && !props.playingWorld)
|
||||||
|
const hasPlayersTooltip = computed(
|
||||||
|
() => !!props.serverStatus?.players?.sample && props.serverStatus.players.sample.length > 0,
|
||||||
|
)
|
||||||
const serverIncompatible = computed(
|
const serverIncompatible = computed(
|
||||||
() =>
|
() =>
|
||||||
!!props.serverStatus &&
|
!!props.serverStatus &&
|
||||||
@@ -238,6 +245,10 @@ const messages = defineMessages({
|
|||||||
id: 'app.world.world-item.incompatible-version',
|
id: 'app.world.world-item.incompatible-version',
|
||||||
defaultMessage: 'Incompatible version {version}',
|
defaultMessage: 'Incompatible version {version}',
|
||||||
},
|
},
|
||||||
|
playersOnline: {
|
||||||
|
id: 'app.world.world-item.players-online',
|
||||||
|
defaultMessage: '{count} online',
|
||||||
|
},
|
||||||
offline: {
|
offline: {
|
||||||
id: 'app.world.world-item.offline',
|
id: 'app.world.world-item.offline',
|
||||||
defaultMessage: 'Offline',
|
defaultMessage: 'Offline',
|
||||||
@@ -315,13 +326,34 @@ const messages = defineMessages({
|
|||||||
}}
|
}}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<div v-else class="flex items-center gap-2">
|
<template v-else>
|
||||||
<ServerOnlinePlayers
|
<SignalIcon
|
||||||
:online="serverStatus.players?.online ?? 0"
|
v-tooltip="`${serverStatus.ping}ms`"
|
||||||
status-online
|
aria-hidden="true"
|
||||||
hide-label
|
:style="`--_signal-${getPingLevel(serverStatus.ping ?? 0)}: var(--color-green)`"
|
||||||
|
stroke-width="3px"
|
||||||
|
class="shrink-0 smart-clickable:allow-pointer-events"
|
||||||
/>
|
/>
|
||||||
</div>
|
<Tooltip :disabled="!hasPlayersTooltip">
|
||||||
|
<span
|
||||||
|
class="smart-clickable:allow-pointer-events"
|
||||||
|
:class="{ 'cursor-help': hasPlayersTooltip }"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
formatMessage(messages.playersOnline, {
|
||||||
|
count: formatNumber(serverStatus.players?.online ?? 0),
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
<template #popper>
|
||||||
|
<div class="flex flex-col gap-1">
|
||||||
|
<span v-for="player in serverStatus.players?.sample" :key="player.id">
|
||||||
|
{{ player.name }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Tooltip>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<NoSignalIcon aria-hidden="true" stroke-width="3px" class="shrink-0" />
|
<NoSignalIcon aria-hidden="true" stroke-width="3px" class="shrink-0" />
|
||||||
|
|||||||
Reference in New Issue
Block a user