UI tweaks

This commit is contained in:
Prospector 2025-07-16 15:08:21 -07:00
parent 83bd4dde45
commit 2c90f1c142
3 changed files with 66 additions and 80 deletions

View File

@ -6,37 +6,35 @@
:closable="!updatingImmediately && !downloadInProgress" :closable="!updatingImmediately && !downloadInProgress"
> >
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<div class="max-w-[500px]">
<div class="font-extrabold text-contrast text-xl mb-1">Modrinth App v{{ update!.version }}</div>
<template v-if="!downloadInProgress && !downloadError">
<div class="mb-4 leading-tight">{{ formatMessage(messages.bodyVersion) }}</div>
<div class="text-sm text-secondary mb-3">
{{ formatMessage(messages.downloadSize, { size: formatBytes(updateSize) }) }}
</div>
</template>
<AppearingProgressBar <AppearingProgressBar
v-if="!downloadError" v-if="!downloadError"
:max-value="shouldShowProgress ? updateSize || 0 : 0" :max-value="shouldShowProgress ? updateSize || 0 : 0"
:current-value="shouldShowProgress ? downloadedBytes : 0" :current-value="shouldShowProgress ? downloadedBytes : 0"
color="green" color="green"
class="w-full" class="w-full mb-4 mt-2"
/> />
<div v-if="downloadError" class="leading-tight">
<div class="flex flex-col gap-4 max-w-[500px]"> <div class="text-red font-medium mb-4">
<div class="flex items-center gap-2 mx-auto">
<span
class="inline-flex items-center px-2 py-0.5 rounded text-lg font-semibold bg-red text-bg-raised border border-red"
>
v{{ update!.currentVersion }}
</span>
<RightArrowIcon class="size-6 text-secondary" />
<span
class="inline-flex items-center px-2 py-0.5 rounded text-lg font-semibold bg-brand text-bg-raised border border-green"
>
v{{ update!.version }}
</span>
</div>
<div>{{ formatMessage(messages.bodyVersion) }}</div>
<div>
{{ formatMessage(messages.downloadSize, { size: formatBytes(updateSize) }) }}
</div>
<div v-if="downloadError" class="flex flex-col gap-2">
<div class="text-red font-medium">
{{ formatMessage(messages.downloadError) }} {{ formatMessage(messages.downloadError) }}
</div> </div>
<ButtonStyled color="red"> <div class="flex flex-wrap gap-2">
<ButtonStyled color="brand">
<button @click="installUpdateNow">
<DownloadIcon />
{{
formatMessage(messages.tryAgain)
}}
</button>
</ButtonStyled>
<ButtonStyled>
<button @click="copyError"> <button @click="copyError">
<ClipboardCopyIcon /> <ClipboardCopyIcon />
{{ {{
@ -46,12 +44,16 @@
}} }}
</button> </button>
</ButtonStyled> </ButtonStyled>
<ButtonStyled>
<a href="https://support.modrinth.com"><ChatIcon /> Get support</a>
</ButtonStyled>
</div> </div>
<div class="flex flex-wrap gap-2 w-full"> </div>
<div v-if="!downloadError" class="flex flex-wrap gap-2 w-full mb-2">
<JoinedButtons <JoinedButtons
:actions="installActions" :actions="installActions"
:disabled="updatingImmediately || downloadInProgress" :disabled="updatingImmediately || downloadInProgress"
color="green" color="brand"
/> />
<div> <div>
<ButtonStyled> <ButtonStyled>
@ -74,21 +76,20 @@ import { AppearingProgressBar, ButtonStyled, JoinedButtons } from '@modrinth/ui'
import type { JoinedButtonAction } from '@modrinth/ui' import type { JoinedButtonAction } from '@modrinth/ui'
import { import {
ExternalIcon, ExternalIcon,
RefreshCwIcon, DownloadIcon,
RightArrowIcon, RightArrowIcon,
TimerIcon, RedoIcon,
XCircleIcon,
ClipboardCopyIcon, ClipboardCopyIcon,
} from '@modrinth/assets' } from '@modrinth/assets'
import { enqueueUpdateForInstallation, getUpdateSize, removeEnqueuedUpdate } from '@/helpers/utils' import { enqueueUpdateForInstallation, getUpdateSize } from '@/helpers/utils'
import { formatBytes } from '@modrinth/utils' import { formatBytes } from '@modrinth/utils'
import { handleError } from '@/store/notifications' import { handleError } from '@/store/notifications'
import { loading_listener } from '@/helpers/events' import { loading_listener } from '@/helpers/events'
import { getCurrentWindow } from '@tauri-apps/api/window' import { getCurrentWindow } from '@tauri-apps/api/window'
import { openUrl } from '@tauri-apps/plugin-opener' import { openUrl } from '@tauri-apps/plugin-opener'
import { ChatIcon } from '@/assets/icons'
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'updateSkipped', version: string): Promise<void>
(e: 'updateEnqueuedForLater', version: string | null): Promise<void> (e: 'updateEnqueuedForLater', version: string | null): Promise<void>
}>() }>()
@ -96,7 +97,7 @@ const { formatMessage } = useVIntl()
const messages = defineMessages({ const messages = defineMessages({
header: { header: {
id: 'app.update.modal-header', id: 'app.update.modal-header',
defaultMessage: 'A new app update is available!', defaultMessage: 'An update is available!',
}, },
copiedError: { copiedError: {
id: 'app.update.copied-error', id: 'app.update.copied-error',
@ -105,15 +106,15 @@ const messages = defineMessages({
bodyVersion: { bodyVersion: {
id: 'app.update.modal-body-version', id: 'app.update.modal-body-version',
defaultMessage: defaultMessage:
'We recommend updating as soon as possible so you can enjoy the latest features and improvements.', 'We recommend updating as soon as possible so you can enjoy the latest features, fixes, and improvements.',
}, },
downloadSize: { downloadSize: {
id: 'app.update.download-size', id: 'app.update.download-size',
defaultMessage: 'The download size of the update is {size}.', defaultMessage: 'The update is {size}.',
}, },
changelog: { changelog: {
id: 'app.update.changelog', id: 'app.update.changelog',
defaultMessage: 'Changelog', defaultMessage: 'View changelog',
}, },
restartNow: { restartNow: {
id: 'app.update.restart', id: 'app.update.restart',
@ -121,11 +122,7 @@ const messages = defineMessages({
}, },
later: { later: {
id: 'app.update.later', id: 'app.update.later',
defaultMessage: 'Update on next restart', defaultMessage: 'Update on exit',
},
skip: {
id: 'app.update.skip',
defaultMessage: 'Skip this update',
}, },
downloadError: { downloadError: {
id: 'app.update.download-error', id: 'app.update.download-error',
@ -136,6 +133,10 @@ const messages = defineMessages({
id: 'app.update.copy-error', id: 'app.update.copy-error',
defaultMessage: 'Copy error', defaultMessage: 'Copy error',
}, },
tryAgain: {
id: 'app.update.try-again',
defaultMessage: 'Try again',
},
}) })
type UpdateData = { type UpdateData = {
@ -151,7 +152,7 @@ const update = ref<UpdateData>()
const updateSize = ref<number>() const updateSize = ref<number>()
const updatingImmediately = ref(false) const updatingImmediately = ref(false)
const downloadInProgress = ref(false) const downloadInProgress = ref(true)
const downloadProgress = ref(0) const downloadProgress = ref(0)
const copiedError = ref(false) const copiedError = ref(false)
const downloadError = ref<Error | null>(null) const downloadError = ref<Error | null>(null)
@ -162,23 +163,16 @@ const installActions = computed<JoinedButtonAction[]>(() => [
{ {
id: 'install-now', id: 'install-now',
label: formatMessage(messages.restartNow), label: formatMessage(messages.restartNow),
icon: RefreshCwIcon, icon: DownloadIcon,
action: installUpdateNow, action: installUpdateNow,
color: 'green', color: 'green',
}, },
{ {
id: 'install-later', id: 'install-later',
label: formatMessage(messages.later), label: formatMessage(messages.later),
icon: TimerIcon, icon: RedoIcon,
action: updateAtNextExit, action: updateAtNextExit,
}, },
{
id: 'skip',
label: formatMessage(messages.skip),
action: skipUpdate,
icon: XCircleIcon,
color: 'red',
},
]) ])
const downloadedBytes = computed(() => { const downloadedBytes = computed(() => {
@ -301,14 +295,6 @@ async function downloadUpdate() {
await getCurrentWindow().close() await getCurrentWindow().close()
} }
} }
function skipUpdate() {
enqueuedUpdate.value = null
emit('updateSkipped', update.value!.version)
removeEnqueuedUpdate()
hide()
}
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>

View File

@ -21,7 +21,7 @@
"message": "Resource management" "message": "Resource management"
}, },
"app.update.changelog": { "app.update.changelog": {
"message": "Changelog" "message": "View changelog"
}, },
"app.update.complete-toast.text": { "app.update.complete-toast.text": {
"message": "Click here to view the changelog." "message": "Click here to view the changelog."
@ -39,22 +39,22 @@
"message": "An error occurred while downloading the update. Please try again later. Contact support if the issue persists." "message": "An error occurred while downloading the update. Please try again later. Contact support if the issue persists."
}, },
"app.update.download-size": { "app.update.download-size": {
"message": "The download size of the update is {size}." "message": "The update is {size}."
}, },
"app.update.later": { "app.update.later": {
"message": "Update on next restart" "message": "Update on exit"
}, },
"app.update.modal-body-version": { "app.update.modal-body-version": {
"message": "We recommend updating as soon as possible so you can enjoy the latest features and improvements." "message": "We recommend updating as soon as possible so you can enjoy the latest features, fixes, and improvements."
}, },
"app.update.modal-header": { "app.update.modal-header": {
"message": "A new app update is available!" "message": "An update is available!"
}, },
"app.update.restart": { "app.update.restart": {
"message": "Update now" "message": "Update now"
}, },
"app.update.skip": { "app.update.try-again": {
"message": "Skip this update" "message": "Try again"
}, },
"instance.add-server.add-and-play": { "instance.add-server.add-and-play": {
"message": "Add and play" "message": "Add and play"

View File

@ -10,7 +10,7 @@
<div v-if="isVisible" class="w-full"> <div v-if="isVisible" class="w-full">
<div class="mb-2 flex justify-between text-sm"> <div class="mb-2 flex justify-between text-sm">
<Transition name="phrase-fade" mode="out-in"> <Transition name="phrase-fade" mode="out-in">
<span :key="currentPhrase" class="text-lg font-medium text-contrast">{{ <span :key="currentPhrase" class="text-md font-semibold">{{
currentPhrase currentPhrase
}}</span> }}</span>
</Transition> </Transition>