@@ -1,4 +1,4 @@
|
||||
<script setup >
|
||||
<script setup lang="ts">
|
||||
import { format, isToday } from 'date-fns'
|
||||
|
||||
const props = defineProps({
|
||||
@@ -12,15 +12,15 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue','emailSelected'])
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const mailsRefs = ref([])
|
||||
const mailsRefs = ref<Element[]>([])
|
||||
|
||||
const selectedMail = computed({
|
||||
get() {
|
||||
return props.modelValue
|
||||
},
|
||||
set(value) {
|
||||
set(value: Mail | null) {
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
})
|
||||
@@ -30,17 +30,12 @@ watch(selectedMail, () => {
|
||||
return
|
||||
}
|
||||
|
||||
const ref1 = mailsRefs.value[selectedMail.value.id]
|
||||
if (ref1) {
|
||||
ref1.scrollIntoView({ block: 'nearest' })
|
||||
const ref = mailsRefs.value[selectedMail.value.id]
|
||||
if (ref) {
|
||||
ref.scrollIntoView({ block: 'nearest' })
|
||||
}
|
||||
})
|
||||
|
||||
const changeMail = (mail) => {
|
||||
selectedMail.value = mail
|
||||
emit("emailSelected")
|
||||
}
|
||||
|
||||
defineShortcuts({
|
||||
arrowdown: () => {
|
||||
const index = props.mails.findIndex((mail) => mail.id === selectedMail.value?.id)
|
||||
@@ -64,15 +59,15 @@ defineShortcuts({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-0 scrollCont overflow-scroll">
|
||||
<div v-for="(mail, index) in mails" :key="index" :ref="el => { mailsRefs[mail.id] = el }">
|
||||
<UDashboardPanelContent class="p-0">
|
||||
<div v-for="(mail, index) in mails" :key="index" :ref="el => { mailsRefs[mail.id] = el as Element }">
|
||||
<div
|
||||
class="p-4 text-sm cursor-pointer border-l-2"
|
||||
:class="[
|
||||
!mail.seen ? 'text-gray-900 dark:text-white' : 'text-gray-600 dark:text-gray-300',
|
||||
mail.unread ? 'text-gray-900 dark:text-white' : 'text-gray-600 dark:text-gray-300',
|
||||
selectedMail && selectedMail.id === mail.id ? 'border-primary-500 dark:border-primary-400 bg-primary-100 dark:bg-primary-900/25' : 'border-white dark:border-gray-900 hover:border-primary-500/25 dark:hover:border-primary-400/25 hover:bg-primary-100/50 dark:hover:bg-primary-900/10'
|
||||
]"
|
||||
@click="changeMail(mail)"
|
||||
@click="selectedMail = mail"
|
||||
>
|
||||
<div class="flex items-center justify-between" :class="[mail.unread && 'font-semibold']">
|
||||
<div class="flex items-center gap-3">
|
||||
@@ -87,17 +82,11 @@ defineShortcuts({
|
||||
{{ mail.subject }}
|
||||
</p>
|
||||
<p class="text-gray-400 dark:text-gray-500 line-clamp-1">
|
||||
{{ mail.text }}
|
||||
{{ mail.body }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<UDivider />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.scrollCont {
|
||||
height: 90vh;
|
||||
}
|
||||
</style>
|
||||
</UDashboardPanelContent>
|
||||
</template>
|
||||
Reference in New Issue
Block a user