-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add basic message box support (#12)
- Loading branch information
Showing
4 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
const { name, github, avatar, type } = defineProps<{ | ||
name: string | ||
github: string | ||
avatar?: string | ||
type?: string | ||
}>() | ||
const avatarUrl = computed(() => { | ||
return avatar ?? (github ? `https://github.com/${github}.png` : undefined) | ||
}) | ||
const messageType = computed(() => { | ||
const type_ = type ?? 'left' | ||
if (!['left', 'right'].includes(type_)) { | ||
console.warn(`Message type must be 'left' or 'right', but got '${type_}'`) | ||
return 'left' | ||
} | ||
return type_ | ||
}) | ||
const extraLiClasses = computed(() => { | ||
const type_ = messageType.value | ||
if (type_ === 'left') { | ||
return { | ||
'mr-10': true, | ||
} | ||
} else { | ||
return { | ||
'flex-row-reverse': true, | ||
'ml-10': true, | ||
} | ||
} | ||
}) | ||
const extraMessageDivClasses = computed(() => { | ||
const type_ = messageType.value | ||
if (type_ === 'left') { | ||
return { | ||
'items-start': true, | ||
} | ||
} else { | ||
return { | ||
'items-end': true, | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<li class="flex items-start space-y-2" :class="extraLiClasses"> | ||
<img v-if="avatarUrl" :src="avatarUrl" alt="author image" class="w-10 h-10 rounded-md m-0" /> | ||
<div class="flex flex-col px-3 !mt-0" :class="extraMessageDivClasses"> | ||
<span class="text-neutral-500 dark:text-neutral-400">{{ name }}</span> | ||
<div class="inline-block bg-slate-200 px-2 py-2 rounded-md dark:bg-zinc-700"> | ||
<slot></slot> | ||
</div> | ||
</div> | ||
</li> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script setup lang="ts"></script> | ||
|
||
<template> | ||
<ul class="p-0"> | ||
<slot></slot> | ||
</ul> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters