You've already forked AstralRinth
f62c60a681
* Improve Intl formatting * Additional fixes * Fixed formatters were not updated on locale change * Fixed formatNumber was not updated on locale change * Additional formatting and fixes after merge * Run prepr:frontend * Remove `'` in icon map * Run `pnpm install` * fix: lint + import * Additional fixes --------- Co-authored-by: Calum H. <calum@modrinth.com> Co-authored-by: Calum H. (IMB11) <contact@cal.engineer>
51 lines
1.3 KiB
Vue
51 lines
1.3 KiB
Vue
<script setup lang="ts">
|
|
import { CalendarIcon, HistoryIcon } from '@modrinth/assets'
|
|
import { capitalizeString } from '@modrinth/utils'
|
|
import { computed } from 'vue'
|
|
|
|
import { defineMessage, useFormatDateTime, useRelativeTime, useVIntl } from '../../../composables'
|
|
|
|
const { formatMessage } = useVIntl()
|
|
|
|
const formatRelativeTime = useRelativeTime()
|
|
const formatDateTime = useFormatDateTime({
|
|
timeStyle: 'short',
|
|
dateStyle: 'long',
|
|
})
|
|
|
|
const props = defineProps<{
|
|
date: Date
|
|
type: 'updated' | 'published'
|
|
}>()
|
|
|
|
const formattedDate = computed(() => formatDateTime(props.date))
|
|
|
|
const types = {
|
|
updated: {
|
|
icon: HistoryIcon,
|
|
tooltip: defineMessage({
|
|
id: 'project-card.date.updated.tooltip',
|
|
defaultMessage: 'Updated {date}',
|
|
}),
|
|
},
|
|
published: {
|
|
icon: CalendarIcon,
|
|
tooltip: defineMessage({
|
|
id: 'project-card.date.published.tooltip',
|
|
defaultMessage: 'Published {date}',
|
|
}),
|
|
},
|
|
}
|
|
|
|
const tooltip = computed(() =>
|
|
capitalizeString(formatMessage(types[props.type].tooltip, { date: formattedDate.value })),
|
|
)
|
|
</script>
|
|
|
|
<template>
|
|
<div v-tooltip="tooltip" class="flex items-center gap-2 smart-clickable:allow-pointer-events">
|
|
<component :is="types[props.type].icon" class="size-5 shrink-0" />
|
|
{{ capitalizeString(formatRelativeTime(date)) }}
|
|
</div>
|
|
</template>
|