diff --git a/src/components/Inbox/DialogCard.module.scss b/src/components/Inbox/DialogCard.module.scss index a3b62656..0bd82c0f 100644 --- a/src/components/Inbox/DialogCard.module.scss +++ b/src/components/Inbox/DialogCard.module.scss @@ -7,6 +7,7 @@ padding: 12px; transition: background 0.3s ease-in-out; cursor: pointer; + width: 100%; &:hover { background: #f7f7f7; @@ -24,6 +25,7 @@ .name, .message { + width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; diff --git a/src/components/Inbox/DialogCard.tsx b/src/components/Inbox/DialogCard.tsx index 45483cf5..a35d5196 100644 --- a/src/components/Inbox/DialogCard.tsx +++ b/src/components/Inbox/DialogCard.tsx @@ -1,8 +1,9 @@ -import styles from './DialogCard.module.scss' +import { Show, Switch, Match, createMemo, For } from 'solid-js' import DialogAvatar from './DialogAvatar' import type { ChatMember } from '../../graphql/types.gen' import GroupDialogAvatar from './GroupDialogAvatar' -import { Show } from 'solid-js' +import { clsx } from 'clsx' +import styles from './DialogCard.module.scss' type DialogProps = { online?: boolean @@ -11,37 +12,50 @@ type DialogProps = { title?: string ownSlug: string members: ChatMember[] - onClick: () => void + onClick?: () => void + isChatHeader?: boolean } const DialogCard = (props: DialogProps) => { - const companions = props.members && props.members.filter((member) => member.slug !== props.ownSlug) + const companions = createMemo( + () => props.members && props.members.filter((member) => member.slug !== props.ownSlug) + ) + const names = createMemo(() => + companions() + .map((companion) => companion.name) + .join(', ') + ) + console.log('!!! names:', names()) return ( -
+
- {companions.length > 2 ? ( - - ) : ( - - )} + }> + 2}> + + +
- {companions.length > 1 ? ( -
{props.title}
- ) : ( -
{companions[0].name}
- )} + {companions()[0].name}
}> + 1}> +
{props.title}
+
+
- Указать предпочтительные языки для результатов поиска можно в разделе + + 1}>{names} +
-
-
22:22
-
- 12 + +
+
22:22
+
+ 12 +
-
+
) diff --git a/src/components/Inbox/DialogHeader.module.scss b/src/components/Inbox/DialogHeader.module.scss new file mode 100644 index 00000000..346311ed --- /dev/null +++ b/src/components/Inbox/DialogHeader.module.scss @@ -0,0 +1,9 @@ +.DialogHeader { + display: flex; + align-items: center; + border-bottom: 3px solid #141414; + + .avatar { + width: 40px; + } +} diff --git a/src/components/Inbox/DialogHeader.tsx b/src/components/Inbox/DialogHeader.tsx new file mode 100644 index 00000000..7d98d259 --- /dev/null +++ b/src/components/Inbox/DialogHeader.tsx @@ -0,0 +1,23 @@ +import type { Chat } from '../../graphql/types.gen' +import styles from './DialogHeader.module.scss' +import DialogCard from './DialogCard' + +type DialogHeader = { + chat: Chat + currentSlug: string +} + +const DialogHeader = (props: DialogHeader) => { + return ( +
+ +
+ ) +} + +export default DialogHeader diff --git a/src/components/Views/Inbox.tsx b/src/components/Views/Inbox.tsx index 497604c5..09c48f1a 100644 --- a/src/components/Views/Inbox.tsx +++ b/src/components/Views/Inbox.tsx @@ -16,6 +16,7 @@ import CreateModalContent from '../Inbox/CreateModalContent' import { clsx } from 'clsx' import '../../styles/Inbox.scss' import { useInbox } from '../../context/inbox' +import DialogHeader from '../Inbox/DialogHeader' const OWNER_ID = '501' const client = createClient({ @@ -70,6 +71,7 @@ export const InboxView = () => { const [loading, setLoading] = createSignal(false) const [sortByGroup, setSortByGroup] = createSignal(false) const [sortByPerToPer, setSortByPerToPer] = createSignal(false) + const [selectedChat, setSelectedChat] = createSignal(undefined) const { session } = useSession() const currentSlug = createMemo(() => session()?.user?.slug) @@ -84,10 +86,11 @@ export const InboxView = () => { } let chatWindow - const handleOpenChat = async (chatId) => { + const handleOpenChat = async (chat) => { setLoading(true) + setSelectedChat(chat) try { - await loadMessages({ chat: chatId }) + await loadMessages({ chat: chat.id }) } catch (error) { setLoading(false) console.error('[loadMessages]', error) @@ -193,7 +196,7 @@ export const InboxView = () => { {(chat) => ( handleOpenChat(chat.id)} + onClick={() => handleOpenChat(chat)} title={chat.title} members={chat.members} ownSlug={currentSlug()} @@ -205,10 +208,9 @@ export const InboxView = () => {
-
- -
Online
-
+ + +
diff --git a/src/styles/Inbox.scss b/src/styles/Inbox.scss index 812a9dae..cda39ebb 100644 --- a/src/styles/Inbox.scss +++ b/src/styles/Inbox.scss @@ -88,8 +88,7 @@ main { } } -.chat-list__search, -.interlocutor { +.chat-list__search { border-bottom: 3px solid #141414; padding: 1em 0; } @@ -122,44 +121,6 @@ main { } } -.interlocutor { - height: 56px; - box-sizing: content-box; - - .circlewrap { - height: 56px; - max-width: 56px; - width: 56px; - } - - .author { - margin-bottom: 0; - - &::before { - left: 40px !important; - height: 8px !important; - width: 8px !important; - } - } - - .author__name { - @include font-size(1.7rem); - - margin: 0.4em 0 0; - } - - .author__details, - .user-status { - margin-left: 6.8rem; - } - - .user-status { - @include font-size(1.2rem); - - color: #ccc; - } -} - .conversation { display: flex; flex-direction: column;