mirror of
https://github.com/robonen/lorem-blog.git
synced 2026-03-20 02:44:39 +00:00
feat(comment): add Comment entity with types and UI component
This commit is contained in:
2
src/entities/Comment/index.ts
Normal file
2
src/entities/Comment/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './types';
|
||||||
|
export { default as Comment } from './ui/Comment.vue';
|
||||||
7
src/entities/Comment/types.ts
Normal file
7
src/entities/Comment/types.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export interface PostComment {
|
||||||
|
id: number;
|
||||||
|
avatar: string;
|
||||||
|
name: string;
|
||||||
|
text: string;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
29
src/entities/Comment/ui/Comment.vue
Normal file
29
src/entities/Comment/ui/Comment.vue
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export interface CommentProps extends Omit<PostComment, 'text'> {}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { PostComment } from '../types';
|
||||||
|
import { formatDateTime } from '@/shared/utils';
|
||||||
|
|
||||||
|
const props = defineProps<CommentProps>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<img
|
||||||
|
class="w-10 h-10 rounded-full object-cover"
|
||||||
|
:src="props.avatar"
|
||||||
|
:alt="props.name"
|
||||||
|
>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<span class="text-sm font-semibold text-gray-900">
|
||||||
|
{{ props.name }}</span>
|
||||||
|
<p class="text-sm">
|
||||||
|
<slot />
|
||||||
|
</p>
|
||||||
|
<span class="text-xs text-foreground-muted-light">
|
||||||
|
{{ formatDateTime(props.created_at) }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
Reference in New Issue
Block a user