All files / apps/huella-legal/layers/comments/app/components CommentItem.vue

100% Statements 13/13
83.33% Branches 5/6
100% Functions 5/5
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53  41x   3x 3x                     46x                             4x                       41x       41x   41x 41x 41x    
<template>
    <article :id :aria-labelledby="`${id}-autor`" class="grid grid-cols-[2.25rem_1fr] gap-x-3">
        <UAvatar :text="authorInitials" size="md" aria-hidden="true" class="mt-0.5" />
        <div class="flex min-w-0 flex-col gap-2">
            <p class="flex flex-wrap items-baseline gap-x-2 font-sans text-meta">
                <span :id="`${id}-autor`" class="font-semibold text-highlighted">
                    {{ author }}
                </span>
                <time :datetime="comment.publishedAt" class="text-muted">
                    {{ $d(comment.publishedAt, "long") }}
                </time>
            </p>
            <p v-if="comment.replyTo" class="font-sans text-meta text-muted">
                {{ $t("commentItem.replyTo", { author: comment.replyTo }) }}
            </p>
            <p
                v-for="(paragraph, index) in comment.paragraphs"
                :key="index"
                class="font-serif text-base/relaxed wrap-break-word text-toned"
            >
                {{ paragraph }}
            </p>
            <UButton
                v-if="replyable"
                variant="link"
                size="sm"
                icon="i-lucide-reply"
                :label="$t('commentItem.reply')"
                :aria-label="$t('commentItem.replyLabel', { author })"
                class="-ml-2.5 self-start print:hidden"
                @click="$emit('reply', comment)"
            />
        </div>
    </article>
</template>
 
<script setup lang="ts">
interface Props {
    comment: ReaderComment;
    replyable?: boolean;
}
 
const props = defineProps<Props>();
 
defineEmits<{ reply: [comment: ReaderComment] }>();
 
const { t } = useI18n();
 
const author = computed<string>(() => props.comment.author || t("commentItem.anonymous"));
const authorInitials = computed<string>(() => initials(author.value));
const id = computed<string>(() => `comentario-${props.comment.id}`);
</script>