Skip to content

Commit fe80cc1

Browse files
committed
chore(*): Added a dev sample for the Chat component
1 parent 91e241c commit fe80cc1

File tree

7 files changed

+167
-48
lines changed

7 files changed

+167
-48
lines changed

package-lock.json

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

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,16 @@
7373
"@igniteui/material-icons-extended": "^3.1.0",
7474
"@lit-labs/ssr-dom-shim": "^1.3.0",
7575
"@types/source-map": "0.5.2",
76+
"dompurify": "^3.2.7",
7677
"express": "^5.1.0",
7778
"fflate": "^0.8.1",
7879
"igniteui-theming": "^20.0.0",
7980
"igniteui-trial-watermark": "^3.1.0",
8081
"lodash-es": "^4.17.21",
82+
"marked": "^16.4.0",
83+
"marked-shiki": "^1.2.1",
8184
"rxjs": "^7.8.2",
85+
"shiki": "^3.13.0",
8286
"tslib": "^2.3.0",
8387
"zone.js": "~0.15.0"
8488
},

src/app/app.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ export class AppComponent implements OnInit {
127127
icon: 'view_carousel',
128128
name: 'Carousel'
129129
},
130+
{
131+
link: '/chat',
132+
icon: 'chat',
133+
name: 'Chat'
134+
},
130135
{
131136
link: '/chip',
132137
icon: 'android',

src/app/app.routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ButtonSampleComponent } from './button/button.sample';
66
import { CalendarSampleComponent } from './calendar/calendar.sample';
77
import { CardSampleComponent } from './card/card.sample';
88
import { CarouselSampleComponent } from './carousel/carousel.sample';
9+
import { ChatSampleComponent } from './chat/chat.sample';
910
import { InputControlsSampleComponent } from './input-controls/input-controls.sample';
1011
import { ChipsSampleComponent } from './chips/chips.sample';
1112
import { CircularProgressSampleComponent } from './circular-progress-showcase/circular-progress-showcase.sample'
@@ -199,6 +200,10 @@ export const appRoutes: Routes = [
199200
path: 'carousel',
200201
component: CarouselSampleComponent
201202
},
203+
{
204+
path: 'chat',
205+
component: ChatSampleComponent
206+
},
202207
{
203208
path: 'input-controls',
204209
component: InputControlsSampleComponent

src/app/chat/chat.sample.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div>
2+
<igx-chat [options]="options" [messages]="messages" [templates]="{ messageContent: renderer }"></igx-chat>
3+
<ng-template #renderer let-message igxChatMessageContext>
4+
{{ markdownRenderer()(message) }}
5+
<!-- {{ message.text.toUpperCase() }} -->
6+
</ng-template>
7+
</div>

src/app/chat/chat.sample.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.cards-wrapper {
2+
display: grid;
3+
grid-template-columns: repeat(2, minmax(340px, 1fr));
4+
justify-items: center;
5+
padding-block-start: 2rem;
6+
gap: 1rem;
7+
}
8+
9+
#igniteui-demo-app .sample-title {
10+
margin-bottom: 0;
11+
justify-self: center;
12+
}
13+
14+
#igniteui-demo-app .sample-wrapper {
15+
height: auto;
16+
}
17+
18+
#igniteui-demo-app .content {
19+
padding-bottom: 1rem;
20+
}

src/app/chat/chat.sample.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
2+
import {
3+
Component,
4+
CUSTOM_ELEMENTS_SCHEMA,
5+
OnInit,
6+
signal,
7+
ViewEncapsulation,
8+
} from '@angular/core';
9+
import { FormsModule } from '@angular/forms';
10+
import {
11+
IgxChatComponent,
12+
IgxChatMessageContextDirective,
13+
} from 'igniteui-angular';
14+
import { createMarkdownRenderer } from 'igniteui-webcomponents/extras';
15+
16+
@Component({
17+
encapsulation: ViewEncapsulation.None,
18+
selector: 'app-chat-sample',
19+
styleUrls: ['chat.sample.scss'],
20+
templateUrl: 'chat.sample.html',
21+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
22+
imports: [
23+
FormsModule,
24+
IgxChatComponent,
25+
IgxChatMessageContextDirective,
26+
]
27+
})
28+
export class ChatSampleComponent implements OnInit {
29+
public messages: any[] = [];
30+
public options = {
31+
disableAutoScroll: false,
32+
disableInputAttachments: false,
33+
suggestions: [`It's there. Thanks.`, `It's not there.`],
34+
inputPlaceholder: 'Type your message here...',
35+
headerText: 'Customer Support',
36+
};
37+
public markdownRenderer = signal<any>(null);
38+
39+
constructor() {
40+
}
41+
42+
public ngOnInit() {
43+
this.messages = [
44+
{
45+
id: '1',
46+
text: `Hello. How can we assist you today?`,
47+
sender: 'support',
48+
timestamp: (Date.now() - 3500000).toString()
49+
},
50+
{
51+
id: '2',
52+
text: `Hello. I have problem with styling IgcAvatarComponent. Can you take a look at the attached file and help me?`,
53+
sender: 'user',
54+
timestamp: (Date.now() - 3400000).toString(),
55+
attachments: [
56+
{
57+
id: 'AvatarStyles.css',
58+
name: 'AvatarStyles.css',
59+
url: './styles/AvatarStyles.css',
60+
type: 'text/css'
61+
},
62+
],
63+
},
64+
{
65+
id: '3',
66+
text: `Sure, give me a moment to check the file.`,
67+
sender: 'support',
68+
timestamp: (Date.now() - 3300000).toString()
69+
},
70+
{
71+
id: '4',
72+
text: `Thank you for your patience. It seems that the issue is the name of the CSS part. Here is the fixed code:
73+
\`\`\`css
74+
igc-avatar::part(base) {
75+
--size: 60px;
76+
color: var(--ig-success-500-contrast);
77+
background: var(--ig-success-500);
78+
border-radius: 20px;
79+
}
80+
\`\`\`
81+
`,
82+
sender: 'support',
83+
timestamp: (Date.now() - 3200000).toString()
84+
},
85+
];
86+
87+
createMarkdownRenderer().then((renderer) => {
88+
this.markdownRenderer.set(renderer);
89+
});
90+
}
91+
}

0 commit comments

Comments
 (0)