Skip to content

Commit

Permalink
feat(chat): add avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 6, 2021
1 parent 6a48912 commit 9ced6c1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
18 changes: 17 additions & 1 deletion packages/plugin-chat/client/chat.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<k-chat-panel class="page-chat" :messages="messages" pinned @click="handleClick" @send="handleSend">
<template #default="{ channelName, username, timestamp, content }">
<template #default="{ avatar, channelName, username, timestamp, content }">
<img class="avatar" :src="avatar"/>
<div class="header">
<span class="channel">{{ channelName || '私聊' }}</span>
<span class="username">{{ username }}</span>
Expand Down Expand Up @@ -54,8 +55,19 @@ function formatDateTime(timestamp: number) {

<style lang="scss">
$avatarSize: 2.5rem;
.page-chat {
.avatar {
position: absolute;
margin-top: 4px;
width: $avatarSize;
height: $avatarSize;
border-radius: $avatarSize;
}
.header {
padding-left: $avatarSize + 1rem;
color: #72767d;
span {
margin-right: 0.5rem;
Expand All @@ -71,6 +83,10 @@ function formatDateTime(timestamp: number) {
.timestamp {
color: #72767d;
}
.k-message {
padding-left: $avatarSize + 1rem;
}
}
</style>
4 changes: 2 additions & 2 deletions packages/plugin-webui/client/components/card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ defineProps<{

<style lang="scss" scoped>
$paddingX: 1.2rem;
$paddingY: 1.6rem;
$paddingX: 1.25rem;
$paddingY: 1.5rem;
.k-card {
margin: 0 auto 2rem;
Expand Down
11 changes: 10 additions & 1 deletion packages/plugin-webui/client/components/chat-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ async function onPaste(event: ClipboardEvent) {
$padding: 1.5rem;
.k-chat-panel {
.k-card.k-chat-panel {
height: 100%;
.k-card-body {
padding: 1rem 0.5rem;
display: flex;
flex-direction: column;
height: -webkit-fill-available;
Expand All @@ -75,7 +76,15 @@ $padding: 1.5rem;
overflow-y: auto;
}
.k-chat-footer {
padding: 0 0.5rem;
}
.k-chat-message {
position: relative;
line-height: 1.5rem;
padding: 0 0.5rem;
&:hover {
background-color: rgba(4, 4, 5, 0.2);
}
Expand Down

0 comments on commit 9ced6c1

Please sign in to comment.