this.gui 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/package.json +27 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +38 -0
- package/public/manifest.json +15 -0
- package/src/App.tsx +22 -0
- package/src/components/AvatarWithStatus.tsx +26 -0
- package/src/components/ChatBubble.tsx +135 -0
- package/src/components/ChatListItem.tsx +87 -0
- package/src/components/ChatsPane.tsx +110 -0
- package/src/components/ColorSchemeToggle.tsx +61 -0
- package/src/components/Header.tsx +47 -0
- package/src/components/MessageInput.tsx +97 -0
- package/src/components/MessagesPane.tsx +87 -0
- package/src/components/MessagesPaneHeader.tsx +105 -0
- package/src/components/MuiLogo.tsx +34 -0
- package/src/components/MyMessages.tsx +49 -0
- package/src/components/Sidebar.tsx +320 -0
- package/src/createServiceWorker.js +52 -0
- package/src/data.tsx +272 -0
- package/src/index.tsx +12 -0
- package/src/package.json +22 -0
- package/src/public/index.html +22 -0
- package/src/tsconfig.json +25 -0
- package/src/types.tsx +25 -0
- package/src/useScript.ts +101 -0
- package/src/utils.ts +53 -0
package/README.md
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@emotion/react": "latest",
|
|
4
|
+
"@emotion/styled": "latest",
|
|
5
|
+
"@mui/icons-material": "latest",
|
|
6
|
+
"@mui/joy": "latest",
|
|
7
|
+
"@mui/material": "latest",
|
|
8
|
+
"@types/react": "latest",
|
|
9
|
+
"@types/react-dom": "latest",
|
|
10
|
+
"react": "latest",
|
|
11
|
+
"react-dom": "latest",
|
|
12
|
+
"typescript": "latest"
|
|
13
|
+
},
|
|
14
|
+
"description": "https://github.com/mui/material-ui/blob/v5.14.10/docs/data/joy/templates/messages/App.tsx",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"react-scripts": "latest"
|
|
17
|
+
},
|
|
18
|
+
"main": "index.tsx",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"start": "react-scripts start",
|
|
21
|
+
"build": "react-scripts build",
|
|
22
|
+
"test": "react-scripts test --env=jsdom",
|
|
23
|
+
"eject": "react-scripts eject"
|
|
24
|
+
},
|
|
25
|
+
"name": "this.gui",
|
|
26
|
+
"version": "0.0.0"
|
|
27
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
6
|
+
<meta name="theme-color" content="#000000">
|
|
7
|
+
<!--
|
|
8
|
+
manifest.json provides metadata used when your web app is added to the
|
|
9
|
+
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
|
10
|
+
-->
|
|
11
|
+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
|
12
|
+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
|
13
|
+
<!--
|
|
14
|
+
Notice the use of %PUBLIC_URL% in the tags above.
|
|
15
|
+
It will be replaced with the URL of the `public` folder during the build.
|
|
16
|
+
Only files inside the `public` folder can be referenced from the HTML.
|
|
17
|
+
|
|
18
|
+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
19
|
+
work correctly both with client-side routing and a non-root public URL.
|
|
20
|
+
Learn how to configure a non-root public URL by running `npm run build`.
|
|
21
|
+
-->
|
|
22
|
+
<title>React App</title>
|
|
23
|
+
|
|
24
|
+
</head>
|
|
25
|
+
<body>
|
|
26
|
+
<div id="root"></div>
|
|
27
|
+
<!--
|
|
28
|
+
This HTML file is a template.
|
|
29
|
+
If you open it directly in the browser, you will see an empty page.
|
|
30
|
+
|
|
31
|
+
You can add webfonts, meta tags, or analytics to this file.
|
|
32
|
+
The build step will place the bundled scripts into the <body> tag.
|
|
33
|
+
|
|
34
|
+
To begin the development, run `npm start` or `yarn start`.
|
|
35
|
+
To create a production bundle, use `npm run build` or `yarn build`.
|
|
36
|
+
-->
|
|
37
|
+
</body>
|
|
38
|
+
</html>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "React App",
|
|
3
|
+
"name": "Create React App Sample",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "favicon.ico",
|
|
7
|
+
"sizes": "192x192",
|
|
8
|
+
"type": "image/png"
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"start_url": "./index.html",
|
|
12
|
+
"display": "standalone",
|
|
13
|
+
"theme_color": "#000000",
|
|
14
|
+
"background_color": "#ffffff"
|
|
15
|
+
}
|
package/src/App.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CssVarsProvider } from '@mui/joy/styles';
|
|
3
|
+
import CssBaseline from '@mui/joy/CssBaseline';
|
|
4
|
+
import Box from '@mui/joy/Box';
|
|
5
|
+
import Sidebar from './components/Sidebar';
|
|
6
|
+
import Header from './components/Header';
|
|
7
|
+
import MyMessages from './components/MyMessages';
|
|
8
|
+
|
|
9
|
+
export default function JoyMessagesTemplate() {
|
|
10
|
+
return (
|
|
11
|
+
<CssVarsProvider disableTransitionOnChange>
|
|
12
|
+
<CssBaseline />
|
|
13
|
+
<Box sx={{ display: 'flex', minHeight: '100dvh' }}>
|
|
14
|
+
<Sidebar />
|
|
15
|
+
<Header />
|
|
16
|
+
<Box component="main" className="MainContent" sx={{ flex: 1 }}>
|
|
17
|
+
<MyMessages />
|
|
18
|
+
</Box>
|
|
19
|
+
</Box>
|
|
20
|
+
</CssVarsProvider>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Badge from '@mui/joy/Badge';
|
|
3
|
+
import Avatar, { AvatarProps } from '@mui/joy/Avatar';
|
|
4
|
+
|
|
5
|
+
type AvatarWithStatusProps = AvatarProps & {
|
|
6
|
+
online?: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default function AvatarWithStatus({
|
|
10
|
+
online = false,
|
|
11
|
+
...rest
|
|
12
|
+
}: AvatarWithStatusProps) {
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
|
+
<Badge
|
|
16
|
+
color={online ? 'success' : 'neutral'}
|
|
17
|
+
variant={online ? 'solid' : 'soft'}
|
|
18
|
+
size="sm"
|
|
19
|
+
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
|
|
20
|
+
badgeInset="4px 4px"
|
|
21
|
+
>
|
|
22
|
+
<Avatar size="sm" {...rest} />
|
|
23
|
+
</Badge>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Avatar from '@mui/joy/Avatar';
|
|
3
|
+
import Box from '@mui/joy/Box';
|
|
4
|
+
import IconButton from '@mui/joy/IconButton';
|
|
5
|
+
import Stack from '@mui/joy/Stack';
|
|
6
|
+
import Sheet from '@mui/joy/Sheet';
|
|
7
|
+
import Typography from '@mui/joy/Typography';
|
|
8
|
+
import CelebrationOutlinedIcon from '@mui/icons-material/CelebrationOutlined';
|
|
9
|
+
import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder';
|
|
10
|
+
import InsertDriveFileRoundedIcon from '@mui/icons-material/InsertDriveFileRounded';
|
|
11
|
+
import { MessageProps } from '../types';
|
|
12
|
+
|
|
13
|
+
type ChatBubbleProps = MessageProps & {
|
|
14
|
+
variant: 'sent' | 'received';
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default function ChatBubble({
|
|
18
|
+
content,
|
|
19
|
+
variant,
|
|
20
|
+
timestamp,
|
|
21
|
+
attachment = undefined,
|
|
22
|
+
sender,
|
|
23
|
+
}: ChatBubbleProps) {
|
|
24
|
+
const isSent = variant === 'sent';
|
|
25
|
+
const [isHovered, setIsHovered] = React.useState<boolean>(false);
|
|
26
|
+
const [isLiked, setIsLiked] = React.useState<boolean>(false);
|
|
27
|
+
const [isCelebrated, setIsCelebrated] = React.useState<boolean>(false);
|
|
28
|
+
return (
|
|
29
|
+
<Box sx={{ maxWidth: '60%', minWidth: 'auto' }}>
|
|
30
|
+
<Stack
|
|
31
|
+
direction="row"
|
|
32
|
+
justifyContent="space-between"
|
|
33
|
+
spacing={2}
|
|
34
|
+
sx={{ mb: 0.25 }}
|
|
35
|
+
>
|
|
36
|
+
<Typography level="body-xs">
|
|
37
|
+
{sender === 'You' ? sender : sender.name}
|
|
38
|
+
</Typography>
|
|
39
|
+
<Typography level="body-xs">{timestamp}</Typography>
|
|
40
|
+
</Stack>
|
|
41
|
+
{attachment ? (
|
|
42
|
+
<Sheet
|
|
43
|
+
variant="outlined"
|
|
44
|
+
sx={{
|
|
45
|
+
px: 1.75,
|
|
46
|
+
py: 1.25,
|
|
47
|
+
borderRadius: 'lg',
|
|
48
|
+
borderTopRightRadius: isSent ? 0 : 'lg',
|
|
49
|
+
borderTopLeftRadius: isSent ? 'lg' : 0,
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<Stack direction="row" spacing={1.5} alignItems="center">
|
|
53
|
+
<Avatar color="primary" size="lg">
|
|
54
|
+
<InsertDriveFileRoundedIcon />
|
|
55
|
+
</Avatar>
|
|
56
|
+
<div>
|
|
57
|
+
<Typography fontSize="sm">{attachment.fileName}</Typography>
|
|
58
|
+
<Typography level="body-sm">{attachment.size}</Typography>
|
|
59
|
+
</div>
|
|
60
|
+
</Stack>
|
|
61
|
+
</Sheet>
|
|
62
|
+
) : (
|
|
63
|
+
<Box
|
|
64
|
+
sx={{ position: 'relative' }}
|
|
65
|
+
onMouseEnter={() => setIsHovered(true)}
|
|
66
|
+
onMouseLeave={() => setIsHovered(false)}
|
|
67
|
+
>
|
|
68
|
+
<Sheet
|
|
69
|
+
color={isSent ? 'primary' : 'neutral'}
|
|
70
|
+
variant={isSent ? 'solid' : 'soft'}
|
|
71
|
+
sx={{
|
|
72
|
+
p: 1.25,
|
|
73
|
+
borderRadius: 'lg',
|
|
74
|
+
borderTopRightRadius: isSent ? 0 : 'lg',
|
|
75
|
+
borderTopLeftRadius: isSent ? 'lg' : 0,
|
|
76
|
+
backgroundColor: isSent
|
|
77
|
+
? 'var(--joy-palette-primary-solidBg)'
|
|
78
|
+
: 'background.body',
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<Typography
|
|
82
|
+
level="body-sm"
|
|
83
|
+
sx={{
|
|
84
|
+
color: isSent
|
|
85
|
+
? 'var(--joy-palette-common-white)'
|
|
86
|
+
: 'var(--joy-palette-text-primary)',
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
{content}
|
|
90
|
+
</Typography>
|
|
91
|
+
</Sheet>
|
|
92
|
+
{(isHovered || isLiked || isCelebrated) && (
|
|
93
|
+
<Stack
|
|
94
|
+
direction="row"
|
|
95
|
+
justifyContent={isSent ? 'flex-end' : 'flex-start'}
|
|
96
|
+
spacing={0.5}
|
|
97
|
+
sx={{
|
|
98
|
+
position: 'absolute',
|
|
99
|
+
top: '50%',
|
|
100
|
+
p: 1.5,
|
|
101
|
+
...(isSent
|
|
102
|
+
? {
|
|
103
|
+
left: 0,
|
|
104
|
+
transform: 'translate(-100%, -50%)',
|
|
105
|
+
}
|
|
106
|
+
: {
|
|
107
|
+
right: 0,
|
|
108
|
+
transform: 'translate(100%, -50%)',
|
|
109
|
+
}),
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
<IconButton
|
|
113
|
+
variant={isLiked ? 'soft' : 'plain'}
|
|
114
|
+
color={isLiked ? 'danger' : 'neutral'}
|
|
115
|
+
size="sm"
|
|
116
|
+
onClick={() => setIsLiked((prevState) => !prevState)}
|
|
117
|
+
>
|
|
118
|
+
{isLiked ? '❤️' : <FavoriteBorderIcon />}
|
|
119
|
+
</IconButton>
|
|
120
|
+
|
|
121
|
+
<IconButton
|
|
122
|
+
variant={isCelebrated ? 'soft' : 'plain'}
|
|
123
|
+
color={isCelebrated ? 'warning' : 'neutral'}
|
|
124
|
+
size="sm"
|
|
125
|
+
onClick={() => setIsCelebrated((prevState) => !prevState)}
|
|
126
|
+
>
|
|
127
|
+
{isCelebrated ? '🎉' : <CelebrationOutlinedIcon />}
|
|
128
|
+
</IconButton>
|
|
129
|
+
</Stack>
|
|
130
|
+
)}
|
|
131
|
+
</Box>
|
|
132
|
+
)}
|
|
133
|
+
</Box>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Box from '@mui/joy/Box';
|
|
3
|
+
import ListDivider from '@mui/joy/ListDivider';
|
|
4
|
+
import ListItem from '@mui/joy/ListItem';
|
|
5
|
+
import ListItemButton, { ListItemButtonProps } from '@mui/joy/ListItemButton';
|
|
6
|
+
import Stack from '@mui/joy/Stack';
|
|
7
|
+
import Typography from '@mui/joy/Typography';
|
|
8
|
+
import CircleIcon from '@mui/icons-material/Circle';
|
|
9
|
+
import AvatarWithStatus from './AvatarWithStatus';
|
|
10
|
+
import { ChatProps, MessageProps, UserProps } from '../types';
|
|
11
|
+
import { toggleMessagesPane } from '../utils';
|
|
12
|
+
|
|
13
|
+
type ChatListItemProps = ListItemButtonProps & {
|
|
14
|
+
id: string;
|
|
15
|
+
unread?: boolean;
|
|
16
|
+
sender: UserProps;
|
|
17
|
+
messages: MessageProps[];
|
|
18
|
+
selectedChatId?: string;
|
|
19
|
+
setSelectedChat: (chat: ChatProps) => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default function ChatListItem({
|
|
23
|
+
id,
|
|
24
|
+
sender,
|
|
25
|
+
messages,
|
|
26
|
+
selectedChatId,
|
|
27
|
+
setSelectedChat,
|
|
28
|
+
}: ChatListItemProps) {
|
|
29
|
+
const selected = selectedChatId === id;
|
|
30
|
+
return (
|
|
31
|
+
<React.Fragment>
|
|
32
|
+
<ListItem>
|
|
33
|
+
<ListItemButton
|
|
34
|
+
onClick={() => {
|
|
35
|
+
toggleMessagesPane();
|
|
36
|
+
setSelectedChat({ id, sender, messages });
|
|
37
|
+
}}
|
|
38
|
+
selected={selected}
|
|
39
|
+
color="neutral"
|
|
40
|
+
sx={{
|
|
41
|
+
flexDirection: 'column',
|
|
42
|
+
alignItems: 'initial',
|
|
43
|
+
gap: 1,
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<Stack direction="row" spacing={1.5}>
|
|
47
|
+
<AvatarWithStatus online={sender.online} src={sender.avatar} />
|
|
48
|
+
<Box sx={{ flex: 1 }}>
|
|
49
|
+
<Typography level="title-sm">{sender.name}</Typography>
|
|
50
|
+
<Typography level="body-sm">{sender.username}</Typography>
|
|
51
|
+
</Box>
|
|
52
|
+
<Box
|
|
53
|
+
sx={{
|
|
54
|
+
lineHeight: 1.5,
|
|
55
|
+
textAlign: 'right',
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
{messages[0].unread && (
|
|
59
|
+
<CircleIcon sx={{ fontSize: 12 }} color="primary" />
|
|
60
|
+
)}
|
|
61
|
+
<Typography
|
|
62
|
+
level="body-xs"
|
|
63
|
+
display={{ xs: 'none', md: 'block' }}
|
|
64
|
+
noWrap
|
|
65
|
+
>
|
|
66
|
+
5 mins ago
|
|
67
|
+
</Typography>
|
|
68
|
+
</Box>
|
|
69
|
+
</Stack>
|
|
70
|
+
<Typography
|
|
71
|
+
level="body-sm"
|
|
72
|
+
sx={{
|
|
73
|
+
display: '-webkit-box',
|
|
74
|
+
WebkitLineClamp: '2',
|
|
75
|
+
WebkitBoxOrient: 'vertical',
|
|
76
|
+
overflow: 'hidden',
|
|
77
|
+
textOverflow: 'ellipsis',
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
{messages[0].content}
|
|
81
|
+
</Typography>
|
|
82
|
+
</ListItemButton>
|
|
83
|
+
</ListItem>
|
|
84
|
+
<ListDivider sx={{ margin: 0 }} />
|
|
85
|
+
</React.Fragment>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Stack from '@mui/joy/Stack';
|
|
3
|
+
import Sheet from '@mui/joy/Sheet';
|
|
4
|
+
import Typography from '@mui/joy/Typography';
|
|
5
|
+
import { Box, Chip, IconButton, Input } from '@mui/joy';
|
|
6
|
+
import List from '@mui/joy/List';
|
|
7
|
+
import EditNoteRoundedIcon from '@mui/icons-material/EditNoteRounded';
|
|
8
|
+
import SearchRoundedIcon from '@mui/icons-material/SearchRounded';
|
|
9
|
+
import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
|
|
10
|
+
import ChatListItem from './ChatListItem';
|
|
11
|
+
import { ChatProps } from '../types';
|
|
12
|
+
import { toggleMessagesPane } from '../utils';
|
|
13
|
+
|
|
14
|
+
type ChatsPaneProps = {
|
|
15
|
+
chats: ChatProps[];
|
|
16
|
+
setSelectedChat: (chat: ChatProps) => void;
|
|
17
|
+
selectedChatId: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default function ChatsPane({
|
|
21
|
+
chats,
|
|
22
|
+
setSelectedChat,
|
|
23
|
+
selectedChatId,
|
|
24
|
+
}: ChatsPaneProps) {
|
|
25
|
+
return (
|
|
26
|
+
<Sheet
|
|
27
|
+
sx={{
|
|
28
|
+
borderRight: '1px solid',
|
|
29
|
+
borderColor: 'divider',
|
|
30
|
+
height: 'calc(100dvh - var(--Header-height))',
|
|
31
|
+
overflowY: 'auto',
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
<Stack
|
|
35
|
+
direction="row"
|
|
36
|
+
spacing={1}
|
|
37
|
+
alignItems="center"
|
|
38
|
+
justifyContent="space-between"
|
|
39
|
+
p={2}
|
|
40
|
+
pb={1.5}
|
|
41
|
+
>
|
|
42
|
+
<Typography
|
|
43
|
+
fontSize={{ xs: 'md', md: 'lg' }}
|
|
44
|
+
component="h1"
|
|
45
|
+
fontWeight="lg"
|
|
46
|
+
endDecorator={
|
|
47
|
+
<Chip
|
|
48
|
+
variant="soft"
|
|
49
|
+
color="primary"
|
|
50
|
+
size="md"
|
|
51
|
+
slotProps={{ root: { component: 'span' } }}
|
|
52
|
+
>
|
|
53
|
+
4
|
|
54
|
+
</Chip>
|
|
55
|
+
}
|
|
56
|
+
sx={{ mr: 'auto' }}
|
|
57
|
+
>
|
|
58
|
+
Messages
|
|
59
|
+
</Typography>
|
|
60
|
+
|
|
61
|
+
<IconButton
|
|
62
|
+
variant="plain"
|
|
63
|
+
aria-label="edit"
|
|
64
|
+
color="neutral"
|
|
65
|
+
size="sm"
|
|
66
|
+
sx={{ display: { xs: 'none', sm: 'unset' } }}
|
|
67
|
+
>
|
|
68
|
+
<EditNoteRoundedIcon />
|
|
69
|
+
</IconButton>
|
|
70
|
+
|
|
71
|
+
<IconButton
|
|
72
|
+
variant="plain"
|
|
73
|
+
aria-label="edit"
|
|
74
|
+
color="neutral"
|
|
75
|
+
size="sm"
|
|
76
|
+
onClick={() => {
|
|
77
|
+
toggleMessagesPane();
|
|
78
|
+
}}
|
|
79
|
+
sx={{ display: { sm: 'none' } }}
|
|
80
|
+
>
|
|
81
|
+
<CloseRoundedIcon />
|
|
82
|
+
</IconButton>
|
|
83
|
+
</Stack>
|
|
84
|
+
<Box sx={{ px: 2, pb: 1.5 }}>
|
|
85
|
+
<Input
|
|
86
|
+
size="sm"
|
|
87
|
+
startDecorator={<SearchRoundedIcon />}
|
|
88
|
+
placeholder="Search"
|
|
89
|
+
aria-label="Search"
|
|
90
|
+
/>
|
|
91
|
+
</Box>
|
|
92
|
+
<List
|
|
93
|
+
sx={{
|
|
94
|
+
py: 0,
|
|
95
|
+
'--ListItem-paddingY': '0.75rem',
|
|
96
|
+
'--ListItem-paddingX': '1rem',
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
{chats.map((chat) => (
|
|
100
|
+
<ChatListItem
|
|
101
|
+
key={chat.id}
|
|
102
|
+
{...chat}
|
|
103
|
+
setSelectedChat={setSelectedChat}
|
|
104
|
+
selectedChatId={selectedChatId}
|
|
105
|
+
/>
|
|
106
|
+
))}
|
|
107
|
+
</List>
|
|
108
|
+
</Sheet>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useColorScheme } from '@mui/joy/styles';
|
|
3
|
+
import IconButton, { IconButtonProps } from '@mui/joy/IconButton';
|
|
4
|
+
|
|
5
|
+
import DarkModeRoundedIcon from '@mui/icons-material/DarkModeRounded';
|
|
6
|
+
import LightModeIcon from '@mui/icons-material/LightMode';
|
|
7
|
+
|
|
8
|
+
export default function ColorSchemeToggle({
|
|
9
|
+
onClick,
|
|
10
|
+
sx,
|
|
11
|
+
...props
|
|
12
|
+
}: IconButtonProps) {
|
|
13
|
+
const { mode, setMode } = useColorScheme();
|
|
14
|
+
const [mounted, setMounted] = React.useState(false);
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
setMounted(true);
|
|
17
|
+
}, []);
|
|
18
|
+
if (!mounted) {
|
|
19
|
+
return (
|
|
20
|
+
<IconButton
|
|
21
|
+
size="sm"
|
|
22
|
+
variant="outlined"
|
|
23
|
+
color="neutral"
|
|
24
|
+
{...props}
|
|
25
|
+
sx={sx}
|
|
26
|
+
disabled
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return (
|
|
31
|
+
<IconButton
|
|
32
|
+
id="toggle-mode"
|
|
33
|
+
size="sm"
|
|
34
|
+
variant="outlined"
|
|
35
|
+
color="neutral"
|
|
36
|
+
{...props}
|
|
37
|
+
onClick={(event) => {
|
|
38
|
+
if (mode === 'light') {
|
|
39
|
+
setMode('dark');
|
|
40
|
+
} else {
|
|
41
|
+
setMode('light');
|
|
42
|
+
}
|
|
43
|
+
onClick?.(event);
|
|
44
|
+
}}
|
|
45
|
+
sx={[
|
|
46
|
+
{
|
|
47
|
+
'& > *:first-of-type': {
|
|
48
|
+
display: mode === 'dark' ? 'none' : 'initial',
|
|
49
|
+
},
|
|
50
|
+
'& > *:last-of-type': {
|
|
51
|
+
display: mode === 'light' ? 'none' : 'initial',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
55
|
+
]}
|
|
56
|
+
>
|
|
57
|
+
<DarkModeRoundedIcon />
|
|
58
|
+
<LightModeIcon />
|
|
59
|
+
</IconButton>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import GlobalStyles from '@mui/joy/GlobalStyles';
|
|
3
|
+
import IconButton from '@mui/joy/IconButton';
|
|
4
|
+
import Sheet from '@mui/joy/Sheet';
|
|
5
|
+
import MenuRoundedIcon from '@mui/icons-material/MenuRounded';
|
|
6
|
+
import { toggleSidebar } from '../utils';
|
|
7
|
+
|
|
8
|
+
export default function Header() {
|
|
9
|
+
return (
|
|
10
|
+
<Sheet
|
|
11
|
+
sx={{
|
|
12
|
+
display: { xs: 'flex', sm: 'none' },
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
justifyContent: 'space-between',
|
|
15
|
+
position: 'fixed',
|
|
16
|
+
top: 0,
|
|
17
|
+
width: '100vw',
|
|
18
|
+
height: 'var(--Header-height)',
|
|
19
|
+
zIndex: 9995,
|
|
20
|
+
p: 2,
|
|
21
|
+
gap: 1,
|
|
22
|
+
borderBottom: '1px solid',
|
|
23
|
+
borderColor: 'background.level1',
|
|
24
|
+
boxShadow: 'sm',
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
<GlobalStyles
|
|
28
|
+
styles={(theme) => ({
|
|
29
|
+
':root': {
|
|
30
|
+
'--Header-height': '52px',
|
|
31
|
+
[theme.breakpoints.up('lg')]: {
|
|
32
|
+
'--Header-height': '0px',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
})}
|
|
36
|
+
/>
|
|
37
|
+
<IconButton
|
|
38
|
+
onClick={() => toggleSidebar()}
|
|
39
|
+
variant="outlined"
|
|
40
|
+
color="neutral"
|
|
41
|
+
size="sm"
|
|
42
|
+
>
|
|
43
|
+
<MenuRoundedIcon />
|
|
44
|
+
</IconButton>
|
|
45
|
+
</Sheet>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Box from '@mui/joy/Box';
|
|
3
|
+
import Button from '@mui/joy/Button';
|
|
4
|
+
import FormControl from '@mui/joy/FormControl';
|
|
5
|
+
import Textarea from '@mui/joy/Textarea';
|
|
6
|
+
import { IconButton, Stack } from '@mui/joy';
|
|
7
|
+
|
|
8
|
+
import FormatBoldRoundedIcon from '@mui/icons-material/FormatBoldRounded';
|
|
9
|
+
import FormatItalicRoundedIcon from '@mui/icons-material/FormatItalicRounded';
|
|
10
|
+
import StrikethroughSRoundedIcon from '@mui/icons-material/StrikethroughSRounded';
|
|
11
|
+
import FormatListBulletedRoundedIcon from '@mui/icons-material/FormatListBulletedRounded';
|
|
12
|
+
import SendRoundedIcon from '@mui/icons-material/SendRounded';
|
|
13
|
+
|
|
14
|
+
export type MessageInputProps = {
|
|
15
|
+
textAreaValue: string;
|
|
16
|
+
setTextAreaValue: (value: string) => void;
|
|
17
|
+
onSubmit: () => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default function MessageInput({
|
|
21
|
+
textAreaValue,
|
|
22
|
+
setTextAreaValue,
|
|
23
|
+
onSubmit,
|
|
24
|
+
}: MessageInputProps) {
|
|
25
|
+
const textAreaRef = React.useRef<HTMLDivElement>(null);
|
|
26
|
+
const handleClick = () => {
|
|
27
|
+
if (textAreaValue.trim() !== '') {
|
|
28
|
+
onSubmit();
|
|
29
|
+
setTextAreaValue('');
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return (
|
|
33
|
+
<Box sx={{ px: 2, pb: 3 }}>
|
|
34
|
+
<FormControl>
|
|
35
|
+
<Textarea
|
|
36
|
+
placeholder="Type something here…"
|
|
37
|
+
aria-label="Message"
|
|
38
|
+
ref={textAreaRef}
|
|
39
|
+
onChange={(e) => {
|
|
40
|
+
setTextAreaValue(e.target.value);
|
|
41
|
+
}}
|
|
42
|
+
value={textAreaValue}
|
|
43
|
+
minRows={3}
|
|
44
|
+
maxRows={10}
|
|
45
|
+
endDecorator={
|
|
46
|
+
<Stack
|
|
47
|
+
direction="row"
|
|
48
|
+
justifyContent="space-between"
|
|
49
|
+
alignItems="center"
|
|
50
|
+
flexGrow={1}
|
|
51
|
+
sx={{
|
|
52
|
+
py: 1,
|
|
53
|
+
pr: 1,
|
|
54
|
+
borderTop: '1px solid',
|
|
55
|
+
borderColor: 'divider',
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
<div>
|
|
59
|
+
<IconButton size="sm" variant="plain" color="neutral">
|
|
60
|
+
<FormatBoldRoundedIcon />
|
|
61
|
+
</IconButton>
|
|
62
|
+
<IconButton size="sm" variant="plain" color="neutral">
|
|
63
|
+
<FormatItalicRoundedIcon />
|
|
64
|
+
</IconButton>
|
|
65
|
+
<IconButton size="sm" variant="plain" color="neutral">
|
|
66
|
+
<StrikethroughSRoundedIcon />
|
|
67
|
+
</IconButton>
|
|
68
|
+
<IconButton size="sm" variant="plain" color="neutral">
|
|
69
|
+
<FormatListBulletedRoundedIcon />
|
|
70
|
+
</IconButton>
|
|
71
|
+
</div>
|
|
72
|
+
<Button
|
|
73
|
+
size="sm"
|
|
74
|
+
color="primary"
|
|
75
|
+
sx={{ alignSelf: 'center', borderRadius: 'sm' }}
|
|
76
|
+
endDecorator={<SendRoundedIcon />}
|
|
77
|
+
onClick={handleClick}
|
|
78
|
+
>
|
|
79
|
+
Send
|
|
80
|
+
</Button>
|
|
81
|
+
</Stack>
|
|
82
|
+
}
|
|
83
|
+
onKeyDown={(event) => {
|
|
84
|
+
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
|
|
85
|
+
handleClick();
|
|
86
|
+
}
|
|
87
|
+
}}
|
|
88
|
+
sx={{
|
|
89
|
+
'& textarea:first-of-type': {
|
|
90
|
+
minHeight: 72,
|
|
91
|
+
},
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
</FormControl>
|
|
95
|
+
</Box>
|
|
96
|
+
);
|
|
97
|
+
}
|