Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AC-3912] feat: added stack direction to message list and set as bottom #369

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/chat/ui/ChatMessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const ChatMessageList = () => {
scrollPositionRef={scrollSource.scrollPositionRef}
scrollDistanceFromBottomRef={scrollSource.scrollDistanceFromBottomRef}
onScrollPosition={(it) => scrollSource.setIsScrollBottomReached(it === 'bottom')}
stackDirection={'bottom'}
messages={filteredMessages}
onLoadPrev={dataSource.loadPrevious}
onLoadNext={dataSource.loadNext}
Expand Down
2 changes: 1 addition & 1 deletion src/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

.sendbird-suggested-replies {
margin: 0 !important;
padding: 8px 0 16px;
padding: 8px 0 4px 0;
}

.sendbird-form-chip__container {
Expand Down
4 changes: 4 additions & 0 deletions src/foundation/components/InfiniteMessageList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type Props = {

scrollPositionRef?: MutableRefObject<number>;
scrollDistanceFromBottomRef?: MutableRefObject<number>;

stackDirection?: 'top' | 'bottom';
};

export const InfiniteMessageList = forwardRef<HTMLDivElement, Props>(function InfiniteMessageList(props, ref) {
Expand All @@ -49,6 +51,7 @@ export const InfiniteMessageList = forwardRef<HTMLDivElement, Props>(function In

scrollPositionRef: _scrollPositionRef,
scrollDistanceFromBottomRef: _scrollDistanceFromBottomRef,
stackDirection = 'top',
} = props;

const listRef = ref && 'current' in ref ? ref : { current: null };
Expand Down Expand Up @@ -112,6 +115,7 @@ export const InfiniteMessageList = forwardRef<HTMLDivElement, Props>(function In
return (
<div id={'infinite-list-container'} className={infiniteListContainer}>
<div id={'infinite-list-inner'} ref={listRef} onScroll={handleScroll} className={infiniteListInner}>
{stackDirection === 'bottom' && <div style={{ flexGrow: 1 }} />}
{messageTopArea}
{messages.map((message, index) => renderMessage({ message, index }))}
{messageBottomArea}
Expand Down
9 changes: 3 additions & 6 deletions src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { getColorBasedOnSaturation, generateColorVariants } from './colors';
export interface CommonTheme {
bgColor: {
base: string;
chatBottom: string;
messageInput: string;
incomingMessage: string;
outgoingMessage: string;
Expand Down Expand Up @@ -131,7 +130,6 @@ export function getTheme({
light: {
bgColor: {
base: 'var(--sendbird-light-background-50)',
chatBottom: 'var(--sendbird-light-background-50)',
messageInput: 'var(--sendbird-light-background-100)',
incomingMessage: botMessageBGColor ?? 'var(--sendbird-dark-background-100)',
outgoingMessage: accentColor ?? 'var(--sendbird-light-primary-300)',
Expand Down Expand Up @@ -237,14 +235,13 @@ export function getTheme({
},
dark: {
bgColor: {
base: 'var(--sendbird-light-background-600)',
chatBottom: 'var(--sendbird-dark-background-600)',
base: 'var(--sendbird-dark-background-700)',
messageInput: 'var(--sendbird-dark-background-500)',
incomingMessage: botMessageBGColor ?? 'var(--sendbird-dark-background-400)',
outgoingMessage: accentColor ?? 'var(--sendbird-dark-primary-200)',
suggestedReply: 'var(--sendbird-dark-background-600)',
bottomBanner: 'var(--sendbird-dark-background-600)',
loadingScreen: 'var(--sendbird-dark-background-600)',
bottomBanner: 'var(--sendbird-dark-background-700)',
loadingScreen: 'var(--sendbird-dark-background-700)',
hover: {
// Give 1 level lighter color for hover
incomingMessage: colorVarsForBotMessageBGColor
Expand Down