|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <div class="flex items-center gap-4"> |
| 4 | + <div |
| 5 | + class="h-4 w-4 rounded-full border-2 border-solid border-button-border" |
| 6 | + :class="recent || first ? 'bg-brand' : 'bg-button-bg'" |
| 7 | + /> |
| 8 | + <AutoLink |
| 9 | + :to=" |
| 10 | + hasLink ? `/news/changelog/${entry.product}/${entry.version ?? entry.date.unix()}` : '' |
| 11 | + " |
| 12 | + class="flex items-center gap-2" |
| 13 | + :class="{ 'hover:underline': hasLink }" |
| 14 | + > |
| 15 | + <h2 class="flex items-center gap-2 m-0 text-xl font-extrabold text-contrast"> |
| 16 | + <template v-if="showType"> |
| 17 | + {{ formatMessage(messages[entry.product]) }} |
| 18 | + <div class="w-2 h-2 rounded-full bg-secondary" /> |
| 19 | + </template> |
| 20 | + <span :class="{ 'text-primary font-bold': showType }"> |
| 21 | + {{ entry.version ?? formattedDate }} |
| 22 | + </span> |
| 23 | + </h2> |
| 24 | + <div v-if="entry.version" v-tooltip="dateTooltip" :class="{ 'cursor-help': dateTooltip }"> |
| 25 | + {{ formattedDate }} |
| 26 | + </div> |
| 27 | + </AutoLink> |
| 28 | + </div> |
| 29 | + <div class="ml-8 mt-3 rounded-2xl bg-bg-raised px-4 py-3"> |
| 30 | + <div class="changelog-body" v-html="renderHighlightedString(entry.body)" /> |
| 31 | + </div> |
| 32 | + </div> |
| 33 | +</template> |
| 34 | + |
| 35 | +<script setup lang="ts"> |
| 36 | +import type { VersionEntry } from '@modrinth/utils/changelog' |
| 37 | +import { renderHighlightedString } from '@modrinth/utils' |
| 38 | +import dayjs from 'dayjs' |
| 39 | +import { useVIntl, defineMessages } from '@vintl/vintl' |
| 40 | +import { computed, ref } from 'vue' |
| 41 | +import AutoLink from '../base/AutoLink.vue' |
| 42 | +
|
| 43 | +const { formatMessage } = useVIntl() |
| 44 | +
|
| 45 | +const props = withDefaults( |
| 46 | + defineProps<{ |
| 47 | + entry: VersionEntry |
| 48 | + showType?: boolean |
| 49 | + first?: boolean |
| 50 | + hasLink?: boolean |
| 51 | + }>(), |
| 52 | + { |
| 53 | + showType: false, |
| 54 | + first: false, |
| 55 | + hasLink: false, |
| 56 | + }, |
| 57 | +) |
| 58 | +
|
| 59 | +const currentDate = ref(dayjs()) |
| 60 | +const recent = computed(() => props.entry.date.isAfter(currentDate.value.subtract(1, 'week'))) |
| 61 | +const dateTooltip = computed(() => props.entry.date.format('MMMM D, YYYY [at] h:mm A')) |
| 62 | +const formattedDate = computed(() => |
| 63 | + props.entry.version ? props.entry.date.fromNow() : props.entry.date.format('MMMM D, YYYY'), |
| 64 | +) |
| 65 | +
|
| 66 | +const messages = defineMessages({ |
| 67 | + web: { |
| 68 | + id: 'changelog.product.web', |
| 69 | + defaultMessage: 'Website', |
| 70 | + }, |
| 71 | + servers: { |
| 72 | + id: 'changelog.product.servers', |
| 73 | + defaultMessage: 'Servers', |
| 74 | + }, |
| 75 | + app: { |
| 76 | + id: 'changelog.product.app', |
| 77 | + defaultMessage: 'App', |
| 78 | + }, |
| 79 | + api: { |
| 80 | + id: 'changelog.product.api', |
| 81 | + defaultMessage: 'API', |
| 82 | + }, |
| 83 | +}) |
| 84 | +</script> |
| 85 | +<style lang="scss" scoped> |
| 86 | +:deep(.changelog-body) { |
| 87 | + line-height: 1.4; |
| 88 | +
|
| 89 | + h1, |
| 90 | + h2, |
| 91 | + h3, |
| 92 | + h4, |
| 93 | + h5, |
| 94 | + h6 { |
| 95 | + margin: 0; |
| 96 | + } |
| 97 | +
|
| 98 | + ul { |
| 99 | + padding-left: 1.25rem; |
| 100 | + margin: 0; |
| 101 | + } |
| 102 | +
|
| 103 | + a { |
| 104 | + color: var(--color-link); |
| 105 | +
|
| 106 | + &:hover, |
| 107 | + &:focus-visible { |
| 108 | + filter: brightness(1.2); |
| 109 | + text-decoration: underline; |
| 110 | + } |
| 111 | + } |
| 112 | +
|
| 113 | + code { |
| 114 | + background-color: var(--color-bg); |
| 115 | + font-size: var(--font-size-sm); |
| 116 | + padding: 0.125rem 0.25rem; |
| 117 | + border-radius: 4px; |
| 118 | + } |
| 119 | +
|
| 120 | + p { |
| 121 | + margin: 0; |
| 122 | + } |
| 123 | +
|
| 124 | + * + p { |
| 125 | + margin-top: 0.5rem; |
| 126 | + } |
| 127 | +
|
| 128 | + h3 + * { |
| 129 | + margin-top: 0.5rem; |
| 130 | + } |
| 131 | +
|
| 132 | + * + h3 { |
| 133 | + margin-top: 0.75rem; |
| 134 | + } |
| 135 | +
|
| 136 | + * + li { |
| 137 | + margin-top: 0.5rem; |
| 138 | + } |
| 139 | +
|
| 140 | + li ul li { |
| 141 | + margin-top: 0.25rem; |
| 142 | + } |
| 143 | +
|
| 144 | + img { |
| 145 | + max-width: 100%; |
| 146 | + border-radius: var(--radius-md); |
| 147 | + } |
| 148 | +} |
| 149 | +</style> |
0 commit comments