Skip to content

Commit 85bb70f

Browse files
committed
feat: add selectMessageModal
1 parent f3f3a04 commit 85bb70f

File tree

6 files changed

+64
-9
lines changed

6 files changed

+64
-9
lines changed

src/components/ModalsLayer.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
showConversationEditModal,
33
showConversationSidebar,
44
showEmojiPickerModal,
5+
showSelectMessageModal,
56
showSettingsSidebar,
67
showShareModal,
78
} from '@/stores/ui'
@@ -10,6 +11,7 @@ import SettingsSidebar from './settings/SettingsSidebar'
1011
import ConversationEditModal from './conversations/ConversationEditModal'
1112
import EmojiPickerModal from './ui/EmojiPickerModal'
1213
import ShareModal from './ui/ShareModal'
14+
import SelectMessageModal from './ui/SelectMessageModal'
1315
import Modal from './ui/Modal'
1416

1517
export default () => {
@@ -40,6 +42,11 @@ export default () => {
4042
<ShareModal />
4143
</div>
4244
</Modal>
45+
<Modal bindValue={showSelectMessageModal} direction="bottom" closeBtnClass="top-4 right-4">
46+
<div class="max-h-[70vh] w-full">
47+
<SelectMessageModal />
48+
</div>
49+
</Modal>
4350
</>
4451
)
4552
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { useStore } from '@nanostores/solid'
2+
import { For } from 'solid-js'
3+
import { useI18n } from '@/hooks'
4+
import { currentConversationId } from '@/stores/conversation'
5+
import { getMessagesByConversationId } from '@/stores/messages'
6+
import { Checkbox } from '../ui/base'
7+
8+
export default () => {
9+
const { t } = useI18n()
10+
const $currentConversationId = useStore(currentConversationId)
11+
const messages = getMessagesByConversationId($currentConversationId())
12+
13+
console.log($currentConversationId(), messages)
14+
return (
15+
<div class="w-full">
16+
<div class="fi px-6 py-4 border-base b-b-1">
17+
<div class="text-base">{t('conversations.share.messages.title')}</div>
18+
</div>
19+
<div class="flex flex-col p-6 h-100 overflow-auto relative">
20+
<For each={messages}>
21+
{item => (
22+
<div class="border border-base b-b-0 last:b-b-1 p-4" >
23+
<Checkbox initValue label={`${item.role}: ${item.content}`} />
24+
</div>
25+
)}
26+
</For>
27+
</div>
28+
<div class="fcc px-2 py-2 bg-darker border border-base hv-base hover:border-base-100" >{t('settings.save')}</div>
29+
</div>
30+
)
31+
}

src/components/ui/ShareModal.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { For } from 'solid-js'
33
import { useClipboardCopy, useI18n } from '@/hooks'
44
import { currentConversationId } from '@/stores/conversation'
55
import { getMessagesByConversationId } from '@/stores/messages'
6+
import { showSelectMessageModal, showShareModal } from '@/stores/ui'
67
import { Tabs } from '../ui/base'
78
import type { TabItem } from './base/Tabs'
89

@@ -20,7 +21,7 @@ export default () => {
2021
value: 'context',
2122
label: t('conversations.share.tabs.context'),
2223
content: <div class="flex flex-col gap-2">
23-
<div class="emerald-light-button mt-0 cursor-pointer" onClick={() => copy()}>{copied() ? t('copyed') : t('conversations.share.copy')}</div>
24+
<div class="emerald-light-button mt-0 cursor-pointer mb-2" onClick={() => copy()}>{copied() ? t('copyed') : t('conversations.share.copy')}</div>
2425
<For each={messages}>
2526
{item => (
2627
<div class="flex space-x-2">
@@ -45,7 +46,13 @@ export default () => {
4546
<button class="button mt-0">{t('conversations.share.link.create')}</button>
4647
</div>
4748
<div class="fcc flex-col space-y-2 p-6">
48-
<div class="border w-full border-base fi justify-between box-border p-4 rounded-md hv-base">
49+
<div
50+
class="border w-full border-base fi justify-between box-border p-4 rounded-md hv-base"
51+
onclick={() => {
52+
showShareModal.set(false)
53+
showSelectMessageModal.set(true)
54+
}}
55+
>
4956
<span class="text-xs">{t('conversations.share.messages.selected')}</span>
5057
<span class="text-xs op-60">2 Messages</span>
5158
</div>

src/components/ui/base/Checkbox.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,26 @@ interface Props {
88
}
99

1010
export const Checkbox = (props: Props) => {
11-
const [state, send] = useMachine(checkbox.machine({ id: createUniqueId(), checked: props.initValue ?? false }))
11+
const [state, send] = useMachine(checkbox.machine({
12+
id: createUniqueId(),
13+
checked: props.initValue ?? false,
14+
onChange(detail) {
15+
console.log('onChange', detail)
16+
},
17+
}))
1218

1319
const api = createMemo(() => checkbox.connect(state, send, normalizeProps))
1420

1521
return (
1622
<label {...api().rootProps}>
17-
<span {...api().labelProps}>
18-
{props.label}
19-
</span>
20-
<input {...api().inputProps} />
21-
<div {...api().controlProps} />
23+
<div class="fi justify-revert cursor-pointer text-sm">
24+
<input {...api().inputProps} />
25+
{api().isChecked ? <div class="i-carbon:checkbox-checked text-xl" /> : <div class="i-carbon:checkbox text-xl" />}
26+
<div {...api().labelProps} class="ml-2 truncate flex-1">
27+
{props.label}
28+
</div>
29+
<div {...api().controlProps} />
30+
</div>
2231
</label>
2332
)
2433
}

src/components/ui/base/Tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const Tabs = (props: Props) => {
2323

2424
return (
2525
<div {...api().rootProps} class="w-full text-sm font-medium text-center">
26-
<div {...api().tablistProps} class={`flex flex-wrap -mb-px border-b border-base ${props.sticky && 'sticky top-0 bottom-0'} ${props.tabClass}`}>
26+
<div {...api().tablistProps} class={`flex flex-wrap -mb-px border-b border-base ${props.sticky && 'sticky top-0 bottom-0 bg-white'} ${props.tabClass}`}>
2727
<For each={props.tabs}>
2828
{item => (
2929
<button class={`inline-block p-4 border-b-2 border-transparent hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-300 cursor-pointer ${api().value === item.value && '!border-emerald-600 !text-emerald-600'}`} {...api().getTriggerProps({ value: item.value })}>

src/stores/ui.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const showConversationEditModal = atom(false)
77
export const showEmojiPickerModal = atom(false)
88
export const showConfirmModal = atom(false)
99
export const showShareModal = atom(false)
10+
export const showSelectMessageModal = atom(false)
1011

1112
export const isSendBoxFocus = atom(false)
1213
export const currentErrorMessage = atom<ErrorMessage | null>(null)

0 commit comments

Comments
 (0)