Skip to content

Commit 2971094

Browse files
committed
feat: Message list supports top to bottom layout #212
1 parent 4cb3aa4 commit 2971094

File tree

8 files changed

+327
-74
lines changed

8 files changed

+327
-74
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"@ctrl/ngx-emoji-mart": "^6.2.0",
112112
"@ngx-translate/core": "^13.0.0",
113113
"@ngx-translate/http-loader": "^6.0.0",
114-
"@stream-io/stream-chat-css": "2.8.1",
114+
"@stream-io/stream-chat-css": "2.9.0",
115115
"@stream-io/transliterate": "^1.5.2",
116116
"angular-mentions": "^1.4.0",
117117
"dayjs": "^1.10.7",

projects/stream-chat-angular/src/lib/icon/icon.component.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,32 @@
254254
fill="black"
255255
/>
256256
</svg>
257+
258+
<svg
259+
data-testid="arrow-up"
260+
*ngIf="icon === 'arrow-up'"
261+
width="24"
262+
height="24"
263+
viewBox="0 0 24 24"
264+
fill="none"
265+
xmlns="http://www.w3.org/2000/svg"
266+
>
267+
<path
268+
d="M16.59 15.7051L12 11.1251L7.41 15.7051L6 14.2951L12 8.29508L18 14.2951L16.59 15.7051Z"
269+
fill="var(--primary-color)"
270+
/>
271+
</svg>
272+
<svg
273+
data-testid="arrow-down"
274+
*ngIf="icon === 'arrow-down'"
275+
width="24"
276+
height="24"
277+
viewBox="0 0 24 24"
278+
fill="none"
279+
xmlns="http://www.w3.org/2000/svg"
280+
>
281+
<path
282+
d="M7.41 8.29504L12 12.875L16.59 8.29504L18 9.70504L12 15.705L6 9.70504L7.41 8.29504Z"
283+
fill="var(--primary-color)"
284+
/>
285+
</svg>

projects/stream-chat-angular/src/lib/icon/icon.component.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ describe('IconComponent', () => {
124124
expect(queryIcon('arrow-left')).not.toBeNull();
125125
});
126126

127+
it('should display arrow-up icon', () => {
128+
component.icon = 'arrow-up';
129+
fixture.detectChanges();
130+
131+
expect(queryIcon('arrow-up')).not.toBeNull();
132+
});
133+
134+
it('should display arrow-down icon', () => {
135+
component.icon = 'arrow-down';
136+
fixture.detectChanges();
137+
138+
expect(queryIcon('arrow-down')).not.toBeNull();
139+
});
140+
127141
it('should not display anything if #icon is not provided', () => {
128142
expect(nativeElement.innerHTML).not.toContain('svg');
129143
});

projects/stream-chat-angular/src/lib/icon/icon.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export type Icon =
1515
| 'reply-in-thread'
1616
| 'arrow-left'
1717
| 'arrow-right'
18-
| 'menu';
18+
| 'menu'
19+
| 'arrow-up'
20+
| 'arrow-down';
1921

2022
/**
2123
* The `Icon` component can be used to display different icons (i. e. message delivered icon).

projects/stream-chat-angular/src/lib/message-list/message-list.component.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,25 @@
6666
</div>
6767
<div class="str-chat__list-notifications">
6868
<button
69-
data-testid="scroll-to-bottom"
70-
*ngIf="isUserScrolledUp"
69+
data-testid="scroll-to-latest"
70+
*ngIf="isUserScrolled"
7171
class="
7272
str-chat__message-notification
7373
str-chat__message-notification-right
74-
str-chat__message-notification-scroll-down
74+
str-chat__message-notification-scroll-to-latest
7575
"
76-
(keyup.enter)="scrollToBottom()"
77-
(click)="scrollToBottom()"
76+
(keyup.enter)="scrollToLatestMessage()"
77+
(click)="scrollToLatestMessage()"
7878
>
79+
<stream-icon
80+
style="display: inline-block; height: 24px"
81+
[icon]="direction === 'bottom-to-top' ? 'arrow-down' : 'arrow-up'"
82+
></stream-icon>
7983
<div
8084
*ngIf="unreadMessageCount > 0"
8185
class="
8286
str-chat__message-notification
83-
str-chat__message-notification-scroll-down-unread-count
87+
str-chat__message-notification-scroll-to-latest-unread-count
8488
"
8589
>
8690
{{ unreadMessageCount }}

0 commit comments

Comments
 (0)