Skip to content

Commit

Permalink
Merge branch 'feat/chat-field-support' into feat/add-markdown-support…
Browse files Browse the repository at this point in the history
…-for-chat-fields
  • Loading branch information
frascuchon authored Sep 12, 2024
2 parents de2d9fc + b54edaa commit 7200fa7
Showing 1 changed file with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<template>
<div class="chat" :key="title">
<div
class="chat"
:key="title"
:class="checkIfAreLessThanTwoRoles ? '--simple' : '--multiple'"
>
<span class="chat__title" v-text="title" />

<div v-for="({ role, content: text }, index) in content" :key="index">
<span
:class="[
'chat__item',
role === 'user' || (checkIfAreLessThanTwoRoles && index === 0)
checkIfAreLessThanTwoRoles && index === 0
? 'chat__item--right'
: 'chat__item--left',
]"
Expand All @@ -16,16 +20,14 @@
v-if="role !== content[index - 1]?.role"
v-text="role"
:style="{
color: $color.generate([...role].reverse()).palette.dark,
color: getColorForRole(role),
}"
/>

<div
class="chat__bubble"
:style="{
borderColor: `hsl(from ${
$color.generate([...role].reverse()).palette.dark
} h s l / 20%)`,
borderColor: `hsl(from ${getColorForRole(role)} h s l / 20%)`,
}"
>
<MarkdownRenderer v-if="useMarkdown" :markdown="text" />
Expand Down Expand Up @@ -65,6 +67,20 @@ export default {
checkIfAreLessThanTwoRoles() {
return this.getAllUniqueRolesNames.length <= 2;
},
colorForRole() {
return [
"hsl(117, 47%, 58%)",
"hsl(288, 47%, 58%)",
"hsl(189, 47%, 58%)",
"hsl(0, 47%, 58%)",
"hsl(50, 47%, 58%)",
];
},
},
methods: {
getColorForRole(role) {
return this.colorForRole[this.getAllUniqueRolesNames.indexOf(role)];
},
},
};
</script>
Expand Down Expand Up @@ -107,6 +123,9 @@ export default {
border-width: 1px;
@include font-size(16px);
@include line-height(24px);
.--simple & {
border-color: var(--bg-opacity-2) !important;
}
}
&__role {
Expand Down

0 comments on commit 7200fa7

Please sign in to comment.