Skip to content

Commit 5bc71da

Browse files
IvanDanchevdimodi
andauthored
docs: add chat initial docs #11678 (#3193)
* docs: add chat initial docs #11678 * docs: add content to Chat articles part1 #11678 * docs: add content to Chat articles part2 #11678 * docs: fix code snippet #11678 * Add Chat to home page --------- Co-authored-by: Dimo Dimov <[email protected]>
1 parent 0c66e6f commit 5bc71da

File tree

12 files changed

+1868
-0
lines changed

12 files changed

+1868
-0
lines changed

accessibility/compliance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Also check the [notes below the table](#accessibility-compliance-notes).
4747
| Card | AA | N/A | [Documentation](slug:card-wai-aria-support) |
4848
| Carousel | AA | [Enhanced](https://demos.telerik.com/blazor-ui/carousel/keyboard-navigation) | [Documentation](slug:carousel-wai-aria-support) |
4949
| Chart | AA | [Enhanced](https://demos.telerik.com/blazor-ui/chart/keyboard-navigation) | [Documentation](slug:chart-wai-aria-support ) |
50+
| Chat | AA | [Enhanced](https://demos.telerik.com/blazor-ui/chat/overview) | [Documentation](slug:chat-wai-aria-support ) |
5051
| CheckBox | AA | [Standard](https://demos.telerik.com/blazor-ui/checkbox/overview) | [Documentation](slug:checkbox-wai-aria-support) |
5152
| Chip | AA | [Enhanced](https://demos.telerik.com/blazor-ui/chip/keyboard-navigation) | [Documentation](slug:chip-wai-aria-support) |
5253
| ChipList | AA | [Enhanced](https://demos.telerik.com/blazor-ui/chiplist/keyboard-navigation) | [Documentation](slug:chiplist-wai-aria-support) |
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: WAI-ARIA Support
3+
page_title: Chat WAI-ARIA Support
4+
slug: chat-wai-aria-support
5+
position: 10
6+
description: Learn about WAI-ARIA accessibility support in the Telerik UI for Blazor Chat component, including ARIA roles, attributes, and screen reader compatibility.
7+
tags: telerik,blazor,chat,accessibility,wai-aria
8+
published: True
9+
---
10+
11+
# WAI-ARIA Support in Telerik UI for Blazor Chat
12+
13+
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
14+
15+
Out of the box, the Telerik UI for Blazor Chat provides extensive accessibility support and enables users with disabilities to acquire complete control over its features.
16+
17+
18+
The Chat is compliant with the [Web Content Accessibility Guidelines (WCAG) 2.2 AA](https://www.w3.org/TR/WCAG22/) standards and [Section 508](https://www.section508.gov/) requirements, follows the [Web Accessibility Initiative - Accessible Rich Internet Applications (WAI-ARIA)](https://www.w3.org/WAI/ARIA/apg/) best practices for implementing the [keyboard navigation](#keyboard-navigation) for its `component` role, provides options for managing its focus and is tested against the most popular screen readers.
19+
20+
## ARIA Roles
21+
- `role="log"` for the message list
22+
- `role="textbox"` for the input area
23+
- `role="button"` for actionable elements (send, upload, speech-to-text)
24+
25+
## ARIA Attributes
26+
- `aria-live` for dynamic message updates
27+
- `aria-label` and `aria-labelledby` for descriptive labeling
28+
- `aria-disabled` for disabled actions
29+
30+
## Section 508
31+
32+
The Chat is fully compliant with the [Section 508 requirements](http://www.section508.gov/).
33+
34+
## Testing
35+
36+
The Chat has been extensively tested automatically with [axe-core](https://github.com/dequelabs/axe-core) and manually with the most popular screen readers.
37+
38+
> To report any accessibility issues, contact the team through the [Telerik Support System](https://www.telerik.com/account/support-center).
39+
40+
### Screen Readers
41+
42+
The Chat has been tested with the following screen readers and browsers combinations:
43+
44+
| Environment | Tool |
45+
| ----------- | ---- |
46+
| Firefox | NVDA |
47+
| Chrome | JAWS |
48+
| Microsoft Edge | JAWS |
49+
50+
## Keyboard Navigation
51+
52+
For details on how the keyboard navigation works in Telerik UI for Blazor, refer to the [Accessibility Overview](slug:accessibility-overview#keyboard-navigation) article.
53+
54+
## See Also
55+
56+
* [Blazor Chat Demos](https://demos.telerik.com/blazor-ui/chat/overview)
57+
* [Accessibility in Telerik UI for Blazor](slug:accessibility-overview)

components/chat/data-binding.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
title: Data Binding
3+
page_title: Chat Data Binding
4+
description: Learn how to bind data to the Telerik UI for Blazor Chat component, including message models and dynamic updates.
5+
slug: chat-data-binding
6+
tags: telerik,blazor,chat,data-binding,messages
7+
published: True
8+
position: 2
9+
---
10+
11+
# Data Binding
12+
13+
The Telerik UI for Blazor Chat component supports data binding to collections of messages and provides flexible field mapping to accommodate different data models.
14+
15+
## Bind to Data
16+
17+
To bind the Chat to data, set its `Data` parameter to an `IEnumerable<T>` where `T` represents your message model.
18+
19+
>caption Basic data binding
20+
21+
````Razor
22+
<TelerikChat Data="@Messages"
23+
AuthorId="@CurrentUserId"
24+
OnSendMessage="@HandleSendMessage">
25+
</TelerikChat>
26+
27+
@code {
28+
private List<ChatMessage> Messages { get; set; } = new List<ChatMessage>
29+
{
30+
new ChatMessage { Id = "1", Text = "Hello!", AuthorId = "user1", Timestamp = DateTime.Now.AddMinutes(-5) },
31+
new ChatMessage { Id = "2", Text = "Hi there!", AuthorId = "user2", Timestamp = DateTime.Now.AddMinutes(-3) }
32+
};
33+
34+
private string CurrentUserId { get; set; } = "user1";
35+
36+
private void HandleSendMessage(ChatSendMessageEventArgs args)
37+
{
38+
var newMessage = new ChatMessage
39+
{
40+
Id = Guid.NewGuid().ToString(),
41+
Text = args.Message,
42+
AuthorId = CurrentUserId,
43+
Timestamp = DateTime.Now
44+
};
45+
46+
Messages.Add(newMessage);
47+
}
48+
49+
public class ChatMessage
50+
{
51+
public string Id { get; set; }
52+
53+
public string AuthorId { get; set; }
54+
55+
public string AuthorName { get; set; }
56+
57+
public string AuthorImageUrl { get; set; }
58+
59+
public string Text { get; set; }
60+
61+
public string MessageToReplyId { get; set; }
62+
63+
public string Status { get; set; }
64+
65+
public bool IsDeleted { get; set; }
66+
67+
public bool IsPinned { get; set; }
68+
69+
public DateTime Timestamp { get; set; }
70+
71+
public List<string> SuggestedActions { get; set; }
72+
73+
public IEnumerable<FileSelectFileInfo> Attachments { get; set; } = new List<FileSelectFileInfo>();
74+
}
75+
}
76+
````
77+
78+
## Field Mapping
79+
80+
The Chat component provides field mapping parameters to work with different data models. Use these parameters to specify which properties in your data model correspond to Chat features:
81+
82+
| Parameter | Description | Default Value |
83+
|-----------|-------------|---------------|
84+
| `TextField` | Field containing message text content | `"Text"` |
85+
| `AuthorIdField` | Field containing the author/user ID | `"AuthorId"` |
86+
| `AuthorNameField` | Field containing the author display name | `"AuthorName"` |
87+
| `TimestampField` | Field containing the message timestamp | `"Timestamp"` |
88+
| `IdField` | Field containing the unique message ID | `"Id"` |
89+
| `FilesField` | Field containing file attachments | `"Files"` |
90+
| `StatusField` | Field containing message status | `"Status"` |
91+
| `IsDeletedField` | Field indicating if message is deleted | `"IsDeleted"` |
92+
| `IsPinnedField` | Field indicating if message is pinned | `"IsPinned"` |
93+
| `ReplyТоIdField` | Field containing the ID of replied message | `"ReplyТоId"` |
94+
| `SuggestedActionsField` | Field containing suggested actions | `"SuggestedActions"` |
95+
96+
## Dynamic Updates
97+
98+
The Chat component automatically reflects changes to the bound data collection. You can add, modify, or remove messages programmatically:
99+
100+
````Razor
101+
<TelerikChat @ref="@Chat1"
102+
Data="@Messages"
103+
TextField="Content"
104+
AuthorId="@CurrentUserId"
105+
OnSendMessage="@HandleSendMessage">
106+
</TelerikChat>
107+
108+
<div style="margin-top: 20px;">
109+
<TelerikButton OnClick="@AddSystemMessage">Add System Message</TelerikButton>
110+
<TelerikButton OnClick="@ClearMessages">Clear All Messages</TelerikButton>
111+
</div>
112+
113+
@code {
114+
private TelerikChat<ChatMessage> Chat1 { get; set; }
115+
private List<ChatMessage> Messages { get; set; } = new List<ChatMessage>();
116+
private string CurrentUserId = "user1";
117+
118+
private void HandleSendMessage(ChatSendMessageEventArgs args)
119+
{
120+
var newMessage = new ChatMessage
121+
{
122+
Id = Guid.NewGuid().ToString(),
123+
Content = args.Message,
124+
AuthorId = CurrentUserId,
125+
AuthorName = "User",
126+
Timestamp = DateTime.Now
127+
};
128+
129+
Messages.Add(newMessage);
130+
131+
Chat1?.Refresh();
132+
}
133+
134+
private void AddSystemMessage()
135+
{
136+
Messages.Add(new ChatMessage
137+
{
138+
Id = Guid.NewGuid().ToString(),
139+
Content = "System notification: New user joined the chat",
140+
AuthorId = "system",
141+
AuthorName = "System",
142+
Timestamp = DateTime.Now
143+
});
144+
145+
Chat1?.Refresh();
146+
}
147+
148+
private void ClearMessages()
149+
{
150+
Messages.Clear();
151+
Chat1?.Refresh();
152+
}
153+
154+
public class ChatMessage
155+
{
156+
public string Id { get; set; }
157+
public string AuthorId { get; set; }
158+
public string AuthorName { get; set; }
159+
public string Content { get; set; }
160+
public DateTime Timestamp { get; set; }
161+
public string Status { get; set; }
162+
public IEnumerable<FileSelectFileInfo> Attachments { get; set; } = new List<FileSelectFileInfo>();
163+
}
164+
}
165+
````
166+
167+
## See Also
168+
169+
* [Chat Overview](slug:chat-overview)
170+
* [Chat Integrations](slug:chat-integrations)

0 commit comments

Comments
 (0)