Skip to content

Commit

Permalink
feat: add release date to ui
Browse files Browse the repository at this point in the history
Signed-off-by: zubairrafi <[email protected]>
  • Loading branch information
walleeva2018 authored and romangg committed Aug 6, 2024
1 parent d6cc67d commit 90c6f47
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions components/iso-card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
class="relative object-cover h-[180px]"
/>
</figure>
<div
v-if="dateFromLink!=='' && showDetails"
class="absolute right-2 bg-primary text-primary-content text-xs font-semibold px-2 py-1 rounded-full shadow-md"
>
{{ dateFromLink || '-' }}
</div>
<div
v-if="!showDetails"
class="card-body"
Expand Down Expand Up @@ -120,8 +126,8 @@ const props = defineProps({
desktopId: { type: String, required: true },
desktopData: { type: Object, required: true },
isoData: { type: Object, required: true },
showDetails: { type: Boolean, required: true } },
)
showDetails: { type: Boolean, required: true },
})
const emit = defineEmits(['details-toggled'])
function getDownloadLink() {
Expand All @@ -133,6 +139,7 @@ function getDownloadLink() {
const showDetailsRef = ref(props.showDetails)
const fullImage = ref(true)
const dateFromLink = ref('')
const enableDetails = () => {
showDetailsRef.value = true
Expand All @@ -156,4 +163,26 @@ const getDetailEntry = (entry: string) => {
}
return props.isoData[entry]
}
if (props.isoData?.image) {
const datePattern = /(\d{6})/
const match = props.isoData.image.match(datePattern)
if (match) {
const dateStr = match[1]
const year = parseInt(dateStr.slice(0, 2), 10)
const month = parseInt(dateStr.slice(2, 4), 10) - 1
const day = parseInt(dateStr.slice(4, 6), 10)
const dateObj = new Date(2000 + year, month, day)
const options: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'long',
day: 'numeric',
}
dateFromLink.value = dateObj.toLocaleDateString(undefined, options)
}
}
</script>

0 comments on commit 90c6f47

Please sign in to comment.