fixed chat container not showing in SB + minor changes
This commit is contained in:
@@ -9,11 +9,17 @@
|
|||||||
|
|
||||||
.toBottomWrap {
|
.toBottomWrap {
|
||||||
display: flex;
|
display: flex;
|
||||||
opacity: 0.9;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 75px;
|
bottom: 50px;
|
||||||
|
color: var(--text-color-secondary);
|
||||||
|
& .toBottomWrap {
|
||||||
|
& .toBottomBtn {
|
||||||
|
border: none;
|
||||||
|
background-color: gray;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.nameChangeView {
|
.nameChangeView {
|
||||||
@@ -36,6 +42,7 @@
|
|||||||
.chatContainer {
|
.chatContainer {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: 1fr 65px;
|
grid-template-rows: 1fr 65px;
|
||||||
|
background-color: var(--theme-color-background-chat);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
.virtuoso {
|
.virtuoso {
|
||||||
|
|||||||
@@ -30,15 +30,17 @@ const AddMessagesChatExample = args => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<RecoilRoot>
|
<RecoilRoot>
|
||||||
<button type="button" onClick={() => setChatMessages([...chatMessages, chatMessages[0]])}>
|
<div style={{ height: '70vh', position: 'relative' }}>
|
||||||
Add message
|
<button type="button" onClick={() => setChatMessages([...chatMessages, chatMessages[0]])}>
|
||||||
</button>
|
Add message
|
||||||
<ChatContainer
|
</button>
|
||||||
messages={chatMessages}
|
<ChatContainer
|
||||||
usernameToHighlight="testuser"
|
messages={chatMessages}
|
||||||
chatUserId="testuser"
|
usernameToHighlight="testuser"
|
||||||
isModerator={false}
|
chatUserId="testuser"
|
||||||
/>
|
isModerator={false}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</RecoilRoot>
|
</RecoilRoot>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Button } from 'antd';
|
|
||||||
import { Virtuoso } from 'react-virtuoso';
|
import { Virtuoso } from 'react-virtuoso';
|
||||||
import { useState, useMemo, useRef, CSSProperties, FC } from 'react';
|
import { useState, useMemo, useRef, CSSProperties, FC } from 'react';
|
||||||
import { EditFilled, VerticalAlignBottomOutlined } from '@ant-design/icons';
|
import { EditFilled } from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
ConnectedClientInfoEvent,
|
ConnectedClientInfoEvent,
|
||||||
MessageType,
|
MessageType,
|
||||||
@@ -15,6 +14,7 @@ import { ChatModeratorNotification } from '../ChatModeratorNotification/ChatMode
|
|||||||
// import ChatActionMessage from '../ChatAction/ChatActionMessage';
|
// import ChatActionMessage from '../ChatAction/ChatActionMessage';
|
||||||
import { ChatSystemMessage } from '../ChatSystemMessage/ChatSystemMessage';
|
import { ChatSystemMessage } from '../ChatSystemMessage/ChatSystemMessage';
|
||||||
import { ChatJoinMessage } from '../ChatJoinMessage/ChatJoinMessage';
|
import { ChatJoinMessage } from '../ChatJoinMessage/ChatJoinMessage';
|
||||||
|
import { ScrollToBotBtn } from './ScrollToBotBtn';
|
||||||
|
|
||||||
export type ChatContainerProps = {
|
export type ChatContainerProps = {
|
||||||
messages: ChatMessage[];
|
messages: ChatMessage[];
|
||||||
@@ -176,22 +176,7 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
|||||||
alignToBottom
|
alignToBottom
|
||||||
atBottomStateChange={bottom => setAtBottom(bottom)}
|
atBottomStateChange={bottom => setAtBottom(bottom)}
|
||||||
/>
|
/>
|
||||||
{!atBottom && (
|
{!atBottom && <ScrollToBotBtn chatContainerRef={chatContainerRef} messages={messages} />}
|
||||||
<div className={styles.toBottomWrap}>
|
|
||||||
<Button
|
|
||||||
type="default"
|
|
||||||
icon={<VerticalAlignBottomOutlined />}
|
|
||||||
onClick={() =>
|
|
||||||
chatContainerRef.current.scrollToIndex({
|
|
||||||
index: messages.length - 1,
|
|
||||||
behavior: 'smooth',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Go to last message
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
[messages, usernameToHighlight, chatUserId, isModerator, atBottom],
|
[messages, usernameToHighlight, chatUserId, isModerator, atBottom],
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.3rem;
|
padding: 0.3rem;
|
||||||
color: var(--theme-color-components-form-field-text);
|
color: var(--theme-color-components-form-field-text);
|
||||||
|
border-radius: var(--theme-rounded-corners);
|
||||||
|
outline: 1px solid gray;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|
||||||
div[role='textbox'] {
|
div[role='textbox'] {
|
||||||
|
|||||||
@@ -197,45 +197,40 @@ export const ChatTextField: FC<ChatTextFieldProps> = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className={styles.root}>
|
||||||
<div className={styles.root}>
|
<Slate editor={editor} value={defaultEditorValue}>
|
||||||
<Slate editor={editor} value={defaultEditorValue}>
|
<Editable
|
||||||
<Editable
|
onKeyDown={onKeyDown}
|
||||||
onKeyDown={onKeyDown}
|
renderElement={renderElement}
|
||||||
renderElement={renderElement}
|
placeholder="Chat message goes here..."
|
||||||
placeholder="Chat message goes here..."
|
style={{ width: '100%' }}
|
||||||
style={{ width: '100%' }}
|
autoFocus
|
||||||
autoFocus
|
|
||||||
/>
|
|
||||||
<Popover
|
|
||||||
content={
|
|
||||||
<EmojiPicker
|
|
||||||
onEmojiSelect={onEmojiSelect}
|
|
||||||
onCustomEmojiSelect={onCustomEmojiSelect}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
trigger="click"
|
|
||||||
onVisibleChange={visible => setShowEmojis(visible)}
|
|
||||||
visible={showEmojis}
|
|
||||||
/>
|
|
||||||
</Slate>
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className={styles.emojiButton}
|
|
||||||
title="Emoji picker button"
|
|
||||||
onClick={() => setShowEmojis(!showEmojis)}
|
|
||||||
>
|
|
||||||
<SmileOutlined />
|
|
||||||
</button>
|
|
||||||
<Button
|
|
||||||
className={styles.sendButton}
|
|
||||||
size="large"
|
|
||||||
type="ghost"
|
|
||||||
icon={<SendOutlined />}
|
|
||||||
onClick={sendMessage}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
<Popover
|
||||||
|
content={
|
||||||
|
<EmojiPicker onEmojiSelect={onEmojiSelect} onCustomEmojiSelect={onCustomEmojiSelect} />
|
||||||
|
}
|
||||||
|
trigger="click"
|
||||||
|
onVisibleChange={visible => setShowEmojis(visible)}
|
||||||
|
visible={showEmojis}
|
||||||
|
/>
|
||||||
|
</Slate>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={styles.emojiButton}
|
||||||
|
title="Emoji picker button"
|
||||||
|
onClick={() => setShowEmojis(!showEmojis)}
|
||||||
|
>
|
||||||
|
<SmileOutlined />
|
||||||
|
</button>
|
||||||
|
<Button
|
||||||
|
className={styles.sendButton}
|
||||||
|
size="large"
|
||||||
|
type="ghost"
|
||||||
|
icon={<SendOutlined />}
|
||||||
|
onClick={sendMessage}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user