-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Message to ChatMessage type
- Loading branch information
Showing
8 changed files
with
105 additions
and
99 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
64 changes: 64 additions & 0 deletions
64
src/modules/AieraChat/Messages/MessageFactory/MessagePrompt/index.tsx
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,64 @@ | ||
import { MicroQuestionMark } from '@aiera/client-sdk/components/Svg/MicroQuestionMark'; | ||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
import { useChatStore } from '../../../store'; | ||
import { ChatMessage } from '../../../services/messages'; | ||
|
||
export const MessagePrompt = ({ | ||
data, | ||
className, | ||
isStickyHeader, | ||
}: { | ||
data: ChatMessage; | ||
className?: string; | ||
isStickyHeader?: boolean; | ||
}) => { | ||
const { searchTerm } = useChatStore(); | ||
const prompt = data.prompt; | ||
if (!prompt) return null; | ||
return ( | ||
<div | ||
className={classNames( | ||
'px-4 bg-slate-200/60-solid rounded-xl flex relative', | ||
{ | ||
'py-3.5 min-h-14': !isStickyHeader, | ||
'h-14': isStickyHeader, | ||
}, | ||
className | ||
)} | ||
> | ||
<div | ||
className={classNames( | ||
'h-7 self-start flex-shrink-0 w-7 mr-2.5 bg-indigo-600', | ||
'flex items-center justify-center rounded-lg', | ||
{ | ||
'mt-3.5': isStickyHeader, | ||
} | ||
)} | ||
> | ||
<MicroQuestionMark className="w-4 text-white" /> | ||
</div> | ||
<div className="self-center"> | ||
<p | ||
className={classNames('text-base font-bold antialiased leading-[1.125rem]', { | ||
'line-clamp-2': isStickyHeader, | ||
})} | ||
> | ||
{searchTerm | ||
? prompt | ||
.split(new RegExp(`(${searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'gi')) | ||
.map((part, index) => | ||
part.toLowerCase() === searchTerm.toLowerCase() ? ( | ||
<mark key={index} className="bg-yellow-400"> | ||
{part} | ||
</mark> | ||
) : ( | ||
part | ||
) | ||
) | ||
: prompt} | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; |
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
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
Oops, something went wrong.