Skip to content

Commit 708e407

Browse files
Add icons & descriptions to chat commands menu (#185)
* Added icons & descriptions to chat commands menu * Simplified code to display command icons --------- Co-authored-by: Venkata Sai Keerthi Swarna <[email protected]>
1 parent f5dc9bc commit 708e407

File tree

4 files changed

+52
-6
lines changed

4 files changed

+52
-6
lines changed

packages/jupyter-chat/src/chat-commands/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type ChatCommand = {
2121
* If set, this will be rendered as the icon for the command in the chat
2222
* commands menu. Jupyter Chat will choose a default if this is unset.
2323
*/
24-
icon?: LabIcon;
24+
icon?: LabIcon | string;
2525

2626
/**
2727
* If set, this will be rendered as the description for the command in the

packages/jupyter-chat/src/components/input/use-chat-commands.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,21 @@ export function useChatCommands(
143143
___: unknown
144144
) => {
145145
const { key, ...listItemProps } = defaultProps;
146+
const commandIcon: JSX.Element = (
147+
<span>
148+
{typeof command.icon === 'object' ? (
149+
<command.icon.react />
150+
) : (
151+
command.icon
152+
)}
153+
</span>
154+
);
146155
return (
147156
<Box key={key} component="li" {...listItemProps}>
148-
{command.name}
157+
{commandIcon}
158+
<p className="jp-chat-command-name">{command.name}</p>
159+
<span> - </span>
160+
<p className="jp-chat-command-description">{command.description}</p>
149161
</Box>
150162
);
151163
},

packages/jupyterlab-chat/style/base.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@
2020
.jp-lab-chat-title-unread .lm-TabBar-tabLabel::before {
2121
content: '* ';
2222
}
23+
24+
.jp-chat-command-name {
25+
font-weight: normal;
26+
margin: 5px;
27+
}
28+
29+
.jp-chat-command-description {
30+
color: gray;
31+
margin: 5px;
32+
}

python/jupyterlab-chat/src/chat-commands/providers/emoji.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,34 @@ import {
1313
export class EmojiCommandProvider implements IChatCommandProvider {
1414
public id: string = 'jupyter-chat:emoji-commands';
1515
private _slash_commands: ChatCommand[] = [
16-
{ name: ':heart:', replaceWith: '❤ ', providerId: this.id },
17-
{ name: ':smile:', replaceWith: '🙂 ', providerId: this.id },
18-
{ name: ':thinking:', replaceWith: '🤔 ', providerId: this.id },
19-
{ name: ':cool:', replaceWith: '😎 ', providerId: this.id }
16+
{
17+
name: ':heart:',
18+
replaceWith: '❤ ',
19+
providerId: this.id,
20+
description: 'Emoji',
21+
icon: '❤'
22+
},
23+
{
24+
name: ':smile:',
25+
replaceWith: '🙂 ',
26+
providerId: this.id,
27+
description: 'Emoji',
28+
icon: '🙂'
29+
},
30+
{
31+
name: ':thinking:',
32+
replaceWith: '🤔 ',
33+
providerId: this.id,
34+
description: 'Emoji',
35+
icon: '🤔'
36+
},
37+
{
38+
name: ':cool:',
39+
replaceWith: '😎 ',
40+
providerId: this.id,
41+
description: 'Emoji',
42+
icon: '😎'
43+
}
2044
];
2145

2246
// regex used to test the current word

0 commit comments

Comments
 (0)