Skip to content

Commit 52dc614

Browse files
committed
example: Update customization example
1 parent 1a0caaa commit 52dc614

File tree

11 files changed

+147
-40
lines changed

11 files changed

+147
-40
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ Run `npm start` and navigate to `http://localhost:4200/`.
8181

8282
## Customization examples
8383

84-
This repository includes a sample app that showcases the different customization options of our SDK:
84+
This repository includes a sample app that showcases how you can provide your own template for different components within the SDK:
8585

86-
To test the app:
86+
To run the app:
8787

8888
Create a file named `.env` in the root directory with the following content:
8989

@@ -93,6 +93,7 @@ STREAM_USER_ID=<Your user ID>
9393
STREAM_USER_TOKEN=<Your user token>
9494
```
9595

96+
x
9697
Run `npm start:customizations-example` and navigate to `http://localhost:4200/`.
9798

9899
## Local development

projects/customizations-example/src/app/app.component.html

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
<div id="root">
22
<stream-channel-list></stream-channel-list>
33
<stream-channel>
4-
<stream-channel-header></stream-channel-header>
5-
<stream-message-list></stream-message-list>
4+
<stream-channel-header
5+
style="--white-snow: #e8f5e9"
6+
></stream-channel-header>
7+
<stream-message-list style="--primary-color: #8bc34a"></stream-message-list>
68
<stream-notification-list></stream-notification-list>
79
<stream-message-input
8-
style="--grey-whisper: rgba(255, 192, 203, 0.4)"
10+
style="--grey-whisper: rgba(165, 214, 167, 0.4); --primary-color: #8bc34a"
911
></stream-message-input>
1012
<stream-thread name="thread">
1113
<stream-message-list
1214
name="thread-message-list"
1315
mode="thread"
1416
></stream-message-list>
1517
<stream-message-input
16-
style="--grey-whisper: rgba(255, 192, 203, 0.4)"
18+
style="
19+
--grey-whisper: rgba(165, 214, 167, 0.4);
20+
--primary-color: #8bc34a;
21+
"
1722
name="thread-message-input"
1823
mode="thread"
1924
></stream-message-input>
@@ -29,7 +34,7 @@
2934
<div
3035
style="
3136
padding: 10px;
32-
background-color: rgba(255, 192, 203, 0.4);
37+
background-color: #f1f8e9;
3338
border-radius: var(--border-radius-md);
3439
margin: 10px;
3540
cursor: pointer;
@@ -48,15 +53,13 @@
4853
let-enabledMessageActions="enabledMessageActions"
4954
let-mode="mode"
5055
>
51-
<div
52-
style="
53-
padding: 15px;
54-
margin: 15px;
55-
background-color: rgba(255, 192, 203, 0.4);
56-
border-radius: var(--border-radius-md);
57-
"
58-
>
56+
<div>
5957
<stream-message
58+
style="
59+
--grey-whisper: #c8e6c9;
60+
--white-snow: #f1f8e9;
61+
--primary-color: #689f38;
62+
"
6063
[message]="message"
6164
[isLastSentMessage]="isLastSentMessage"
6265
[enabledMessageActions]="enabledMessageActions"
@@ -76,7 +79,7 @@
7679
let-messageUpdateHandler="messageUpdateHandler"
7780
>
7881
<stream-message-input
79-
style="--grey-whisper: rgba(255, 192, 203, 0.4)"
82+
style="--grey-whisper: rgba(165, 214, 167, 0.4); --primary-color: #8bc34a"
8083
[message]="message"
8184
[isFileUploadEnabled]="isFileUploadEnabled"
8285
[areMentionsEnabled]="areMentionsEnabled"
@@ -88,14 +91,14 @@
8891
</ng-template>
8992

9093
<ng-template #mentionTemplate let-user="user">
91-
<span style="color: pink; font-weight: bold">{{
94+
<span style="color: #7cb342; font-weight: bold">{{
9295
user?.id || user?.name
9396
}}</span>
9497
</ng-template>
9598

9699
<ng-template #typingIndicator let-usersTyping$="usersTyping$">
97100
<div
98-
style="color: pink"
101+
style="color: #7cb342"
99102
*ngIf="$any(usersTyping$ | async)?.length"
100103
class="str-chat__typing-indicator str-chat__typing-indicator--typing"
101104
>
@@ -108,20 +111,31 @@
108111
</ng-template>
109112

110113
<ng-template #mentionAutocompleteItemTemplate let-item="item">
111-
<div style="color: pink">{{ item.autocompleteLabel }} - {{ item.role }}</div>
114+
<div style="color: #7cb342">
115+
{{ item.autocompleteLabel }} - {{ item.role }}
116+
</div>
112117
</ng-template>
113118

114119
<ng-template #commandAutocompleteItemTemplate let-item="item">
115-
<div style="color: pink">
120+
<div style="color: #7cb342">
116121
{{ item.autocompleteLabel | uppercase }} ({{ item.description }})
117122
</div>
118123
</ng-template>
119124

120125
<ng-template #channelActionsTemplate let-channel="channel">
121-
<span style="color: pink">
122-
You can add action buttons to manage
123-
{{ channel?.data?.name || channel?.id }} channel
124-
</span>
126+
<button
127+
(click)="inviteClicked(channel)"
128+
style="
129+
background-color: #388e3c;
130+
color: white;
131+
border-radius: var(--border-radius-md);
132+
border: none;
133+
padding: 10px;
134+
cursor: pointer;
135+
"
136+
>
137+
Invite
138+
</button>
125139
</ng-template>
126140

127141
<ng-template
@@ -131,7 +145,7 @@
131145
>
132146
<span
133147
style="
134-
color: pink;
148+
color: #7cb342;
135149
position: absolute;
136150
left: 50%;
137151
top: 50%;
@@ -156,7 +170,7 @@
156170
<stream-attachment-preview-list
157171
style="
158172
border-radius: var(--border-radius-md);
159-
background-color: rgba(255, 192, 203, 0.4);
173+
background-color: rgba(241, 248, 233, 0.4);
160174
"
161175
[attachmentUploads$]="attachmentUploads$"
162176
(retryAttachmentUpload)="retryUploadHandler($event)"
@@ -172,25 +186,21 @@
172186
let-size="size"
173187
>
174188
<stream-avatar
175-
style="--primary-color: pink"
189+
style="--primary-color: #8bc34a"
176190
[name]="name"
177191
[imageUrl]="imageUrl"
178192
[size]="size"
179193
></stream-avatar>
180194
</ng-template>
181195

182196
<ng-template #iconTemplate let-icon="icon" let-size="size">
183-
<stream-icon
184-
style="border: 1px solid pink"
185-
[icon]="icon"
186-
[size]="size"
187-
></stream-icon>
197+
<app-icon [icon]="icon" [size]="size"></app-icon>
188198
</ng-template>
189199

190200
<ng-template #loadingIndicatorTemplate let-size="size" let-color="color">
191201
<stream-loading-indicator
192202
[size]="size"
193-
color="pink"
203+
color="#F1F8E9"
194204
></stream-loading-indicator>
195205
</ng-template>
196206

@@ -204,7 +214,7 @@
204214
let-isEditingChangeHandler="isEditingChangeHandler"
205215
>
206216
<stream-message-actions-box
207-
style="--primary-color: pink"
217+
style="--primary-color: #33691e"
208218
[isOpen]="isOpen"
209219
[isMine]="isMine"
210220
[enabledActions]="enabledActions"
@@ -237,7 +247,7 @@
237247
let-ownReactions="ownReactions"
238248
>
239249
<stream-message-reactions
240-
style="--black: rgba(255, 192, 203, 0.8)"
250+
style="--black: rgba(51, 105, 30, 0.8)"
241251
[messageReactionCounts]="messageReactionCounts"
242252
[latestReactions]="latestReactions"
243253
[isSelectorOpen]="isSelectorOpen"
@@ -254,7 +264,7 @@
254264
let-content="content"
255265
>
256266
<stream-modal
257-
style="--white: #faf2f6"
267+
style="--white: #f1f8e9"
258268
[isOpen]="isOpen"
259269
(isOpenChange)="isOpenChangeHandler($event)"
260270
[content]="content"
@@ -265,7 +275,7 @@
265275
<ng-template #notificationTemplate let-type="type" let-content="content">
266276
<div
267277
class="str-chat__custom-notification"
268-
style="background-color: #fff0f9; color: pink"
278+
style="background-color: #f1f8e9; color: #2e7d32"
269279
>
270280
{{ type | uppercase }}
271281
<ng-container *ngTemplateOutlet="content"></ng-container>

projects/customizations-example/src/app/app.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
TemplateRef,
55
ViewChild,
66
} from '@angular/core';
7+
import { Channel } from 'stream-chat';
78
import {
89
ChatClientService,
910
ChannelService,
@@ -149,4 +150,12 @@ export class AppComponent implements AfterViewInit {
149150
this.threadHeaderTemplate
150151
);
151152
}
153+
154+
inviteClicked(channel: Channel) {
155+
alert(
156+
`You can add channel actions to the channel header to manage the ${
157+
channel.data?.name || (channel.data?.id as string)
158+
} channel`
159+
);
160+
}
152161
}

projects/customizations-example/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import { EmojiPickerComponent } from './emoji-picker/emoji-picker.component';
1111
import { PickerModule } from '@ctrl/ngx-emoji-mart';
1212
import { MessageActionComponent } from './message-action/message-action.component';
1313
import { ThreadHeaderComponent } from './thread-header/thread-header.component';
14+
import { IconComponent } from './icon/icon.component';
1415

1516
@NgModule({
1617
declarations: [
1718
AppComponent,
1819
EmojiPickerComponent,
1920
MessageActionComponent,
2021
ThreadHeaderComponent,
22+
IconComponent,
2123
],
2224
imports: [
2325
BrowserModule,

projects/customizations-example/src/app/emoji-picker/emoji-picker.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
preserveAspectRatio="xMinYMin"
66
xmlns="http://www.w3.org/2000/svg"
77
>
8-
<g clip-rule="evenodd" fill-rule="evenodd" fill="pink">
8+
<g clip-rule="evenodd" fill-rule="evenodd" fill="#33691e">
99
<path
1010
d="M14 4.4C8.6 4.4 4.4 8.6 4.4 14c0 5.4 4.2 9.6 9.6 9.6c5.4 0 9.6-4.2 9.6-9.6c0-5.4-4.2-9.6-9.6-9.6zM2 14c0-6.6 5.4-12 12-12s12 5.4 12 12s-5.4 12-12 12s-12-5.4-12-12zM12.8 11c0 1-.8 1.8-1.8 1.8s-1.8-.8-1.8-1.8s.8-1.8 1.8-1.8s1.8.8 1.8 1.8zM18.8 11c0 1-.8 1.8-1.8 1.8s-1.8-.8-1.8-1.8s.8-1.8 1.8-1.8s1.8.8 1.8 1.8zM8.6 15.4c.6-.4 1.2-.2 1.6.2c.6.8 1.6 1.8 3 2c1.2.4 2.8.2 4.8-2c.4-.4 1.2-.6 1.6 0c.4.4.6 1.2 0 1.6c-2.2 2.6-4.8 3.4-7 3c-2-.4-3.6-1.8-4.4-3c-.4-.6-.2-1.2.4-1.8z"
1111
></path>
@@ -15,7 +15,7 @@
1515

1616
<emoji-mart
1717
class="picker"
18-
color="pink"
18+
color="#33691e"
1919
*ngIf="isOpened"
2020
title="Pick your emoji…"
2121
emoji="point_up"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<span
2+
class="material-icons"
3+
[ngStyle]="{ 'font-size': size || defaultSize + 'px' }"
4+
>
5+
{{ mapToMaterialIcon() }}
6+
</span>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.material-icons {
2+
color: #33691e;
3+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { IconComponent } from './icon.component';
4+
5+
describe('IconComponent', () => {
6+
let component: IconComponent;
7+
let fixture: ComponentFixture<IconComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [IconComponent],
12+
}).compileComponents();
13+
});
14+
15+
beforeEach(() => {
16+
fixture = TestBed.createComponent(IconComponent);
17+
component = fixture.componentInstance;
18+
fixture.detectChanges();
19+
});
20+
21+
it('should create', () => {
22+
expect(component).toBeTruthy();
23+
});
24+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Component, Input } from '@angular/core';
2+
import { Icon } from 'stream-chat-angular';
3+
4+
@Component({
5+
selector: 'app-icon',
6+
templateUrl: './icon.component.html',
7+
styleUrls: ['./icon.component.scss'],
8+
})
9+
export class IconComponent {
10+
@Input() icon: Icon | undefined;
11+
@Input() size: number | undefined;
12+
defaultSize = 18;
13+
14+
constructor() {}
15+
16+
mapToMaterialIcon() {
17+
const map: { [key in Icon]: string } = {
18+
'action-icon': 'more_horiz',
19+
'arrow-left': 'keyboard_arrow_left',
20+
'arrow-right': 'keyboard_arrow_right',
21+
close: 'close',
22+
'close-no-outline': 'close',
23+
'connection-error': 'error',
24+
'delivered-icon': 'check',
25+
file: 'folder',
26+
'file-upload': 'file_upload',
27+
menu: 'menu',
28+
'reaction-icon': 'face',
29+
reply: 'swap_horiz',
30+
'reply-in-thread': 'reply',
31+
retry: 'replay',
32+
send: 'send',
33+
};
34+
35+
return map[this.icon!];
36+
}
37+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.str-chat__thread-header {
2-
color: pink;
2+
--white: #e8f5e9;
33
}

0 commit comments

Comments
 (0)