-
Notifications
You must be signed in to change notification settings - Fork 434
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
Showing
7 changed files
with
57 additions
and
4 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 |
---|---|---|
@@ -1,26 +1,34 @@ | ||
import { useStore } from '@nanostores/solid' | ||
import { currentConversationId } from '@/stores/conversation' | ||
import { scrollController } from '@/stores/ui' | ||
import { | ||
scrollController, | ||
showConfirmModal, | ||
} from '@/stores/ui' | ||
import { clearMessagesByConversationId } from '@/stores/messages' | ||
import { useI18n } from '@/hooks' | ||
import ConfirmModal from '../ui/ConfirmModal' | ||
|
||
export default () => { | ||
const $currentConversationId = useStore(currentConversationId) | ||
const { t } = useI18n() | ||
|
||
const handleClearMessage = () => { | ||
clearMessagesByConversationId($currentConversationId()) | ||
scrollController().scrollToBottom() | ||
showConfirmModal.set(false) | ||
} | ||
|
||
return ( | ||
<> | ||
{ $currentConversationId() && ( | ||
{$currentConversationId() && ( | ||
<div | ||
class="fcc p-2 rounded-md text-xl hv-foreground" | ||
onClick={handleClearMessage} | ||
onClick={() => { showConfirmModal.set(true) }} | ||
> | ||
<div i-carbon-clean /> | ||
</div> | ||
)} | ||
<ConfirmModal title={t('conversations.confirm.title')} description={t('conversations.confirm.desc')} onConfirm={handleClearMessage} onCancel={() => { showConfirmModal.set(false) }} /> | ||
</> | ||
) | ||
} |
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,29 @@ | ||
import { | ||
showConfirmModal, | ||
} from '@/stores/ui' | ||
import { useI18n } from '@/hooks' | ||
import Modal from './Modal' | ||
|
||
interface Props { | ||
title: string | ||
description: string | ||
onConfirm: () => void | ||
onCancel: () => void | ||
} | ||
|
||
export default (props: Props) => { | ||
const { t } = useI18n() | ||
return ( | ||
<Modal bindValue={showConfirmModal} direction="bottom" closeBtnClass="hidden" > | ||
<div class="max-h-[70vh] w-full"> | ||
<div class="grid w-full max-w-lg scale-100 gap-4 border-base sm:border bg-white dark:bg-zinc-900/90 dark:backdrop-blur-lg p-6 opacity-100 shadow-lg sm:rounded-lg md:w-full"> | ||
<div class="flex flex-col space-y-2 text-center sm:text-left"><h2 id="radix-:rl:" class="text-lg font-semibold">{props.title}</h2><p id="radix-:rm:" class="text-sm text-muted-foreground">{props.description}</p></div> | ||
<div class="flex flex-col-reverse sm:flex-row sm:justify-end gap-2"> | ||
<button class="button" onClick={() => props.onCancel()}>{t('conversations.confirm.cancel')}</button> | ||
<button class="emerald-button" onClick={() => props.onConfirm()}>{t('conversations.confirm.btn')}</button> | ||
</div> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} |
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