Skip to content

Commit 870d4d4

Browse files
committed
feat(html): create chat quick reply component spec
1 parent 8099c65 commit 870d4d4

File tree

5 files changed

+79
-37
lines changed

5 files changed

+79
-37
lines changed
+12-33
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,33 @@
11
import { classNames } from '../misc';
22

3-
const CHATQUICKREPLY_CLASSNAME = 'k-quick-replies';
3+
const CHATQUICKREPLIES_CLASSNAME = 'k-quick-replies';
44

55
const states = [];
66

77
const options = {};
88

9-
const defaultOptions = {
10-
actions: [ 'Quick', 'Reply', 'Another quick', 'Reply with different length' ]
11-
};
12-
13-
14-
export type KendoChatQuickRepliesOptions = {
15-
actions?: Array<string>;
16-
};
9+
const defaultOptions = {};
1710

18-
export const ChatQuickReply = (
19-
props: KendoChatQuickRepliesOptions &
20-
React.HTMLAttributes<HTMLDivElement>
11+
export const ChatQuickReplies = (
12+
props: React.HTMLAttributes<HTMLDivElement>
2113
) => {
22-
const {
23-
actions = defaultOptions.actions,
24-
...other
25-
} = props;
26-
27-
const children: JSX.Element[] = [];
28-
29-
if (actions) {
30-
actions.map((action, index) => {
31-
children.push(
32-
<span className="k-quick-reply" key={index}>{action}</span>
33-
);
34-
});
35-
}
14+
const { ...other } = props;
3615

3716
return (
3817
<div
3918
{...other}
4019
className={classNames(
41-
CHATQUICKREPLY_CLASSNAME,
20+
CHATQUICKREPLIES_CLASSNAME,
4221
props.className
4322
)}>
44-
{children}
23+
{props.children}
4524
</div>
4625
);
4726
};
4827

49-
ChatQuickReply.states = states;
50-
ChatQuickReply.options = options;
51-
ChatQuickReply.className = CHATQUICKREPLY_CLASSNAME;
52-
ChatQuickReply.defaultOptions = defaultOptions;
28+
ChatQuickReplies.states = states;
29+
ChatQuickReplies.options = options;
30+
ChatQuickReplies.className = CHATQUICKREPLIES_CLASSNAME;
31+
ChatQuickReplies.defaultOptions = defaultOptions;
5332

54-
export default ChatQuickReply;
33+
export default ChatQuickReplies;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { classNames, stateClassNames, States } from '../misc';
2+
3+
const CHATQUICKREPLY_CLASSNAME = 'k-quick-reply';
4+
5+
const states = [
6+
States.focus,
7+
States.hover
8+
];
9+
10+
const options = {};
11+
12+
const defaultProps = {};
13+
14+
export type KendoChatQuickReplyProps = {
15+
text?: string;
16+
};
17+
18+
export type KendoChatQuickReplyState = { [K in (typeof states)[number]]?: boolean };
19+
20+
export const ChatQuickReply = (
21+
props: KendoChatQuickReplyProps &
22+
KendoChatQuickReplyState &
23+
React.HTMLAttributes<HTMLSpanElement>
24+
) => {
25+
const {
26+
focus,
27+
hover,
28+
text
29+
} = props;
30+
31+
return (
32+
<span
33+
className={classNames(
34+
CHATQUICKREPLY_CLASSNAME,
35+
stateClassNames(CHATQUICKREPLY_CLASSNAME, {
36+
focus,
37+
hover
38+
})
39+
)}>
40+
{text}
41+
</span>
42+
);
43+
};
44+
45+
ChatQuickReply.states = states;
46+
ChatQuickReply.options = options;
47+
ChatQuickReply.className = CHATQUICKREPLY_CLASSNAME;
48+
ChatQuickReply.defaultProps = defaultProps;
49+
50+
export default ChatQuickReply;

packages/html/src/chat/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export * from './chat.spec';
22
export * from './chat-message';
33
export * from './chat-message-group';
44
export * from './chat-quick-replies';
5+
export * from './chat-quick-reply';
56
export * from './templates/chat-normal';
67
export * from './templates/chat-with-toolbar';
78
export * from './templates/chat-with-options';

packages/html/src/chat/tests/chat-content-rtl.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Button } from '../../button';
22
import { Card, CardDeck, CardBody } from '../../card';
3-
import { ChatMessage, ChatMessageGroup, ChatNormal, ChatQuickReply } from '..';
3+
import { ChatMessage, ChatMessageGroup, ChatNormal, ChatQuickReplies, ChatQuickReply } from '..';
44

55

66
const styles = `
@@ -50,7 +50,13 @@ export default () =>(
5050
<ChatMessageGroup>
5151
<ChatMessage className="k-only" />
5252
</ChatMessageGroup>
53-
<ChatQuickReply />
53+
<ChatQuickReplies>
54+
<ChatQuickReply text="Quick" />
55+
<ChatQuickReply text="Reply" />
56+
<ChatQuickReply text="Focused" focus />
57+
<ChatQuickReply text="Hovered quick" hover />
58+
<ChatQuickReply text="Reply with different length" />
59+
</ChatQuickReplies>
5460
<div className="k-timestamp">Card Deck Normal</div>
5561
<CardDeck>
5662
<Card>

packages/html/src/chat/tests/chat-content.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Button } from '../../button';
22
import { Card, CardDeck, CardBody } from '../../card';
3-
import { ChatMessage, ChatMessageGroup, ChatNormal, ChatQuickReply } from '..';
3+
import { ChatMessage, ChatMessageGroup, ChatNormal, ChatQuickReplies, ChatQuickReply } from '..';
44

55

66
const styles = `
@@ -50,7 +50,13 @@ export default () =>(
5050
<ChatMessageGroup>
5151
<ChatMessage className="k-only" />
5252
</ChatMessageGroup>
53-
<ChatQuickReply />
53+
<ChatQuickReplies>
54+
<ChatQuickReply text="Quick" />
55+
<ChatQuickReply text="Reply" />
56+
<ChatQuickReply text="Focused" focus />
57+
<ChatQuickReply text="Hovered quick" hover />
58+
<ChatQuickReply text="Reply with different length" />
59+
</ChatQuickReplies>
5460
<div className="k-timestamp">Card Deck Normal</div>
5561
<CardDeck>
5662
<Card>

0 commit comments

Comments
 (0)