Skip to content

Commit e88d5a2

Browse files
Restore simplified mobile support
1 parent 08e38e5 commit e88d5a2

File tree

2 files changed

+69
-85
lines changed

2 files changed

+69
-85
lines changed

examples/vite/src/index.scss

+63-84
Original file line numberDiff line numberDiff line change
@@ -12,112 +12,91 @@ body,
1212
height: 100%;
1313
}
1414

15-
#root {
16-
display: flex;
17-
height: 100%;
18-
19-
& > div.str-chat {
20-
height: 100%;
21-
width: 100%;
22-
display: flex;
23-
}
24-
25-
.str-chat__channel-list {
26-
position: fixed;
27-
z-index: 1;
28-
height: 100%;
29-
width: 0;
30-
flex-shrink: 0;
31-
box-shadow: 0 0 8px rgba(0, 0, 0, 0.15);
32-
33-
&--open {
15+
.str-chat__chat-view {
16+
.str-chat__chat-view__channels {
17+
.str-chat__channel {
18+
width: 100%;
19+
}
20+
.str-chat__channel-list {
21+
width: 350px;
22+
min-width: 350px;
23+
}
24+
.str-chat__thread {
25+
min-width: 350px;
3426
width: 30%;
35-
position: fixed;
3627
}
37-
transition: width 0.3s ease-out;
3828
}
3929

40-
.str-chat__channel {
41-
flex: 1;
42-
min-width: 0;
43-
}
44-
45-
.str-chat__main-panel {
46-
min-width: 0;
47-
flex: 1;
48-
49-
&--thread-open {
50-
display: none;
30+
.str-chat__chat-view__threads {
31+
.str-chat__thread-list-container {
32+
width: 350px;
33+
min-width: 350px;
5134
}
52-
}
5335

54-
.str-chat__thread {
55-
flex: 1;
56-
height: 100%;
57-
position: absolute;
58-
z-index: 1;
36+
.str-chat__channel {
37+
width: 100%;
38+
}
5939
}
40+
}
6041

61-
.str-chat__channel-header .str-chat__header-hamburger {
62-
width: 30px;
63-
height: 38px;
64-
padding: var(--xxs-p);
65-
margin-right: var(--xs-m);
42+
@media screen and (max-width: 1024px) {
43+
.str-chat__chat-view {
6644
display: flex;
67-
align-items: center;
68-
justify-content: center;
69-
cursor: pointer;
70-
border: none;
71-
background: transparent;
45+
flex-direction: column-reverse;
46+
47+
.str-chat__chat-view__selector {
48+
border-right: none;
49+
border-top: 1px solid var(--str-chat-selector-border-color);
50+
flex-direction: row;
51+
justify-content: center;
52+
padding-block: 8px;
53+
}
54+
55+
.str-chat__chat-view__channels {
56+
position: relative;
7257

73-
&:hover {
74-
svg path {
75-
fill: var(--primary-color);
58+
.str-chat__channel-header .str-chat__header-hamburger {
59+
background-color: unset;
60+
margin: unset;
61+
border: unset;
62+
padding-inline: 8px;
63+
display: flex;
64+
color: var(--str-chat__text-low-emphasis-color);
65+
& > svg {
66+
width: 25px;
67+
}
7668
}
77-
}
78-
}
7969

80-
@media screen and (min-width: 768px) {
81-
.str-chat__channel-list {
82-
width: 30%;
83-
position: initial;
84-
z-index: 0;
85-
}
70+
.str-chat__channel-list {
71+
display: none;
72+
}
8673

87-
.str-chat__chat-view__channels {
8874
.str-chat__thread {
89-
position: initial;
90-
z-index: 0;
75+
position: absolute;
76+
width: 100%;
9177
}
92-
}
9378

94-
.str-chat__channel-header .str-chat__header-hamburger {
95-
display: none;
79+
.str-chat__channel-list.str-chat__channel-list--open {
80+
position: absolute;
81+
width: 100%;
82+
display: block;
83+
z-index: 1;
84+
}
9685
}
97-
}
9886

99-
@media screen and (min-width: 1024px) {
100-
.str-chat__main-panel {
101-
min-width: 0;
87+
.str-chat__chat-view__threads {
88+
position: relative;
10289

103-
&--thread-open {
104-
max-width: 55%;
105-
display: flex;
90+
.str-chat__thread-list-container:has(~ .str-chat__channel .str-chat__container:empty) {
91+
position: absolute;
92+
height: 100%;
93+
width: 100%;
94+
z-index: 1;
10695
}
107-
}
10896

109-
.str-chat__chat-view__channels {
110-
.str-chat__thread {
111-
max-width: 45%;
97+
.str-chat__thread-list-container:has(~ .str-chat__channel .str-chat__container:not(:empty)) {
98+
display: none;
11299
}
113100
}
114-
115-
.str-chat__channel-header .str-chat__header-hamburger {
116-
display: none;
117-
}
118-
}
119-
120-
.str-chat__thread-list-container {
121-
max-width: 350px;
122101
}
123102
}

src/components/Thread/Thread.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from '../../context';
2121
import { useThreadContext } from '../Threads';
2222
import { useStateStore } from '../../store';
23+
import { useThreadsViewContext } from '../ChatView';
2324

2425
import type { MessageProps, MessageUIComponentProps } from '../Message/types';
2526
import type { MessageActionsArray } from '../Message/utils';
@@ -113,6 +114,7 @@ const ThreadInner = <
113114
threadSuppressAutoscroll,
114115
} = useChannelStateContext<StreamChatGenerics>('Thread');
115116
const { closeThread, loadMoreThread } = useChannelActionContext<StreamChatGenerics>('Thread');
117+
const { setActiveThread } = useThreadsViewContext();
116118
const { customClasses } = useChatContext<StreamChatGenerics>('Thread');
117119
const {
118120
ThreadInput: ContextInput,
@@ -184,7 +186,10 @@ const ThreadInner = <
184186

185187
return (
186188
<div className={threadClass}>
187-
<ThreadHeader closeThread={closeThread} thread={messageAsThread} />
189+
<ThreadHeader
190+
closeThread={threadInstance ? () => setActiveThread(undefined) : closeThread}
191+
thread={messageAsThread}
192+
/>
188193
<ThreadMessageList
189194
disableDateSeparator={!enableDateSeparator}
190195
head={head}

0 commit comments

Comments
 (0)