Skip to content

Commit 9199cbc

Browse files
authored
Jupyter chat package reorganization (#225)
* Split the chat-messages module * Move the chat-input module in input directory * Move the registers in a dedicated directory * Add an index file to the widgets
1 parent e54ed1a commit 9199cbc

26 files changed

+937
-870
lines changed

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

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) Jupyter Development Team.
3+
* Distributed under the terms of the Modified BSD License.
4+
*/
5+
6+
import { Avatar as MuiAvatar, Typography } from '@mui/material';
7+
import type { SxProps, Theme } from '@mui/material';
8+
import React from 'react';
9+
10+
import { IUser } from '../types';
11+
12+
/**
13+
* The avatar props.
14+
*/
15+
type AvatarProps = {
16+
/**
17+
* The user to display an avatar.
18+
*/
19+
user: IUser;
20+
/**
21+
* Whether the avatar should be small.
22+
*/
23+
small?: boolean;
24+
};
25+
26+
/**
27+
* The avatar component.
28+
*/
29+
export function Avatar(props: AvatarProps): JSX.Element | null {
30+
const { user } = props;
31+
32+
const sharedStyles: SxProps<Theme> = {
33+
height: `${props.small ? '16' : '24'}px`,
34+
width: `${props.small ? '16' : '24'}px`,
35+
bgcolor: user.color,
36+
fontSize: `var(--jp-ui-font-size${props.small ? '0' : '1'})`
37+
};
38+
39+
const name =
40+
user.display_name ?? user.name ?? (user.username || 'User undefined');
41+
return user.avatar_url ? (
42+
<MuiAvatar
43+
sx={{
44+
...sharedStyles
45+
}}
46+
src={user.avatar_url}
47+
alt={name}
48+
title={name}
49+
></MuiAvatar>
50+
) : user.initials ? (
51+
<MuiAvatar
52+
sx={{
53+
...sharedStyles
54+
}}
55+
alt={name}
56+
title={name}
57+
>
58+
<Typography
59+
sx={{
60+
fontSize: `var(--jp-ui-font-size${props.small ? '0' : '1'})`,
61+
color: 'var(--jp-ui-inverse-font-color1)'
62+
}}
63+
>
64+
{user.initials}
65+
</Typography>
66+
</MuiAvatar>
67+
) : null;
68+
}

0 commit comments

Comments
 (0)