Skip to content

Jupyter chat package reorganization #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions packages/jupyter-chat/src/chat-commands/registry.ts

This file was deleted.

68 changes: 68 additions & 0 deletions packages/jupyter-chat/src/components/avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) Jupyter Development Team.
* Distributed under the terms of the Modified BSD License.
*/

import { Avatar as MuiAvatar, Typography } from '@mui/material';
import type { SxProps, Theme } from '@mui/material';
import React from 'react';

import { IUser } from '../types';

/**
* The avatar props.
*/
type AvatarProps = {
/**
* The user to display an avatar.
*/
user: IUser;
/**
* Whether the avatar should be small.
*/
small?: boolean;
};

/**
* The avatar component.
*/
export function Avatar(props: AvatarProps): JSX.Element | null {
const { user } = props;

const sharedStyles: SxProps<Theme> = {
height: `${props.small ? '16' : '24'}px`,
width: `${props.small ? '16' : '24'}px`,
bgcolor: user.color,
fontSize: `var(--jp-ui-font-size${props.small ? '0' : '1'})`
};

const name =
user.display_name ?? user.name ?? (user.username || 'User undefined');
return user.avatar_url ? (
<MuiAvatar
sx={{
...sharedStyles
}}
src={user.avatar_url}
alt={name}
title={name}
></MuiAvatar>
) : user.initials ? (
<MuiAvatar
sx={{
...sharedStyles
}}
alt={name}
title={name}
>
<Typography
sx={{
fontSize: `var(--jp-ui-font-size${props.small ? '0' : '1'})`,
color: 'var(--jp-ui-inverse-font-color1)'
}}
>
{user.initials}
</Typography>
</MuiAvatar>
) : null;
}
Loading
Loading