Skip to content

Commit ff62fa6

Browse files
committed
feat: Image gallery #204
1 parent 56e2941 commit ff62fa6

File tree

10 files changed

+457
-33
lines changed

10 files changed

+457
-33
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
@@ -86,7 +86,7 @@
8686
"@ctrl/ngx-emoji-mart": "^6.2.0",
8787
"@ngx-translate/core": "^13.0.0",
8888
"@ngx-translate/http-loader": "^6.0.0",
89-
"@stream-io/stream-chat-css": "2.4.0",
89+
"@stream-io/stream-chat-css": "2.5.0",
9090
"@stream-io/transliterate": "^1.5.2",
9191
"angular-mentions": "^1.4.0",
9292
"dayjs": "^1.10.7",

projects/stream-chat-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@angular/core": "^12.2.0 || ^13.0.0",
1414
"@ngx-translate/core": "^13.0.0 || ^14.0.0",
1515
"stream-chat": "^4.3.0 || ^5.0.0",
16-
"@stream-io/stream-chat-css": "2.4.0"
16+
"@stream-io/stream-chat-css": "2.5.0"
1717
},
1818
"dependencies": {
1919
"angular-mentions": "^1.4.0",

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

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,64 @@
1616
[src]="attachment.img_url || attachment.thumb_url || attachment.image_url"
1717
[alt]="attachment?.fallback"
1818
(load)="imageLoaded()"
19+
(click)="openImageModal([attachment])"
20+
(keyup.enter)="openImageModal([attachment])"
1921
/>
22+
<div
23+
class="str-chat__gallery"
24+
data-testid="image-gallery"
25+
*ngIf="isGallery(attachment)"
26+
[class.str-chat__gallery--square]="(attachment?.images)!.length > 3"
27+
>
28+
<ng-container
29+
*ngFor="
30+
let galleryImage of attachment.images;
31+
let index = index;
32+
let isLast = last;
33+
trackBy: trackByImageUrl
34+
"
35+
>
36+
<button
37+
*ngIf="index < 3 || (index === 3 && isLast)"
38+
class="str-chat__gallery-image"
39+
data-testclass="gallery-image"
40+
(click)="openImageModal(attachment.images!, index)"
41+
(keyup.enter)="openImageModal(attachment.images!, index)"
42+
>
43+
<img
44+
[src]="
45+
galleryImage.img_url ||
46+
galleryImage.thumb_url ||
47+
galleryImage.image_url
48+
"
49+
[alt]="galleryImage.fallback"
50+
(load)="imageLoaded()"
51+
/>
52+
</button>
53+
<button
54+
*ngIf="index === 3 && !isLast"
55+
class="str-chat__gallery-placeholder"
56+
data-testclass="gallery-image"
57+
(click)="openImageModal(attachment.images!, index)"
58+
(keyup.enter)="openImageModal(attachment.images!, index)"
59+
[ngStyle]="{
60+
'background-image':
61+
'url(' +
62+
(galleryImage.img_url ||
63+
galleryImage.thumb_url ||
64+
galleryImage.image_url) +
65+
')'
66+
}"
67+
>
68+
<p
69+
[innerHTML]="
70+
'streamChat.{{ imageCount }} more'
71+
| translate: { imageCount: attachment!.images!.length - 4 }
72+
"
73+
></p>
74+
</button>
75+
</ng-container>
76+
</div>
2077
<div
2178
*ngIf="isFile(attachment)"
2279
class="
@@ -105,3 +162,46 @@
105162
</div>
106163
</div>
107164
</ng-container>
165+
166+
<stream-modal
167+
*ngIf="imagesToView && imagesToView.length > 0"
168+
[isOpen]="imagesToView && imagesToView.length > 0"
169+
(isOpenChange)="$event ? null : closeImageModal()"
170+
>
171+
<div class="stream-chat-angular__image-modal">
172+
<button
173+
class="stream-chat-angular__image-modal-stepper"
174+
[ngStyle]="{
175+
visibility: isImageModalPrevButtonVisible ? 'visible' : 'hidden'
176+
}"
177+
data-testid="image-modal-prev"
178+
type="button"
179+
(click)="stepImages(-1)"
180+
(keyup.enter)="stepImages(-1)"
181+
>
182+
<stream-icon icon="arrow-left"></stream-icon>
183+
</button>
184+
<img
185+
class="stream-chat-angular__image-modal-image"
186+
data-testid="modal-image"
187+
[src]="
188+
imagesToView[imagesToViewCurrentIndex].img_url ||
189+
imagesToView[imagesToViewCurrentIndex].thumb_url ||
190+
imagesToView[imagesToViewCurrentIndex].image_url
191+
"
192+
[alt]="imagesToView[imagesToViewCurrentIndex].fallback"
193+
/>
194+
<button
195+
class="stream-chat-angular__image-modal-stepper"
196+
type="button"
197+
[ngStyle]="{
198+
visibility: isImageModalNextButtonVisible ? 'visible' : 'hidden'
199+
}"
200+
data-testid="image-modal-next"
201+
(click)="stepImages(1)"
202+
(keyup.enter)="stepImages(1)"
203+
>
204+
<stream-icon icon="arrow-right"></stream-icon>
205+
</button>
206+
</div>
207+
</stream-modal>

0 commit comments

Comments
 (0)