-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3461e32
commit f87d8b9
Showing
62 changed files
with
1,081 additions
and
3,272 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,79 @@ | ||
import { FC } from 'react' | ||
import { useRecoilState } from 'recoil' | ||
import { base64FilePromptState } from 'src/stores/conversation' | ||
import { SolidCloseIcon } from '../Icons' | ||
|
||
interface Props { | ||
className?: string | ||
} | ||
|
||
const AttachmentPreview: FC<Props> = ({ className }) => { | ||
const [base64FilePrompt, setBase64FilePrompt] = useRecoilState( | ||
base64FilePromptState | ||
) | ||
|
||
const deleteBase64FilePrompt = (id: string) => { | ||
setBase64FilePrompt(base64FilePrompt.filter((prompt) => prompt.id !== id)) | ||
} | ||
|
||
return ( | ||
<section className={className}> | ||
{base64FilePrompt.map((prompt) => { | ||
if (prompt.mimeType.includes('image')) { | ||
return ( | ||
<section | ||
className="mb-2 ml-4 mt-4 flex w-full flex-row gap-2" | ||
key={prompt.id} | ||
> | ||
<section className="group relative"> | ||
<span className="absolute -right-2 -top-2 hidden rounded-full bg-white group-hover:block"> | ||
<SolidCloseIcon | ||
className="h-6 w-6 text-black" | ||
onClick={() => deleteBase64FilePrompt(prompt.id)} | ||
/> | ||
</span> | ||
<img | ||
src={prompt.data} | ||
className="h-16 w-16 rounded-xl object-cover" | ||
/> | ||
</section> | ||
</section> | ||
) | ||
} | ||
|
||
if (prompt.mimeType.includes('audio')) { | ||
return ( | ||
<section | ||
className="ml-4 mt-4 flex w-1/2 rounded-3xl bg-main-purple" | ||
key={prompt.id} | ||
> | ||
<audio src={prompt.data} controls /> | ||
</section> | ||
) | ||
} | ||
|
||
if (prompt.mimeType.includes('video')) { | ||
return ( | ||
<section | ||
className="ml-4 mt-4 flex w-1/2 rounded-3xl bg-main-purple" | ||
key={prompt.id} | ||
> | ||
<video src={prompt.data} controls /> | ||
</section> | ||
) | ||
} | ||
|
||
return ( | ||
<section | ||
className="ml-4 mt-4 flex w-1/2 rounded-3xl bg-main-purple" | ||
key={prompt.id} | ||
> | ||
{prompt.name} | ||
</section> | ||
) | ||
})} | ||
</section> | ||
) | ||
} | ||
|
||
export default AttachmentPreview |
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.