@lobehub/chat 0.1.6 → 0.3.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/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 0.3.0](https://github.com/lobehub/lobe-chat/compare/v0.2.0...v0.3.0)
6
+
7
+ <sup>Released on **2023-07-18**</sup>
8
+
9
+ #### ✨ Features
10
+
11
+ - **misc**: Add new files, modify components, and adjust layout and styling.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's improved
19
+
20
+ - **misc**: Add new files, modify components, and adjust layout and styling ([b8c3b38](https://github.com/lobehub/lobe-chat/commit/b8c3b38))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ## [Version 0.2.0](https://github.com/lobehub/lobe-chat/compare/v0.1.6...v0.2.0)
31
+
32
+ <sup>Released on **2023-07-18**</sup>
33
+
34
+ #### ✨ Features
35
+
36
+ - **misc**: Add import statement and define CSS styles for Avatar component.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's improved
44
+
45
+ - **misc**: Add import statement and define CSS styles for Avatar component ([8c23a8d](https://github.com/lobehub/lobe-chat/commit/8c23a8d))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ### [Version 0.1.6](https://github.com/lobehub/lobe-chat/compare/v0.1.5...v0.1.6)
6
56
 
7
57
  <sup>Released on **2023-07-18**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.1.6",
3
+ "version": "0.3.0",
4
4
  "description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -0,0 +1,3 @@
1
+ export const HEADER_HEIGHT = 64;
2
+ export const CHAT_TEXTAREA_HEIGHT = 200;
3
+ export const CHAT_SIDEBAR_WIDTH = 280;
@@ -1,27 +1,47 @@
1
1
  import { Avatar, Logo } from '@lobehub/ui';
2
2
  import { Upload } from 'antd';
3
+ import { createStyles } from 'antd-style';
3
4
  import { memo } from 'react';
4
5
  import { shallow } from 'zustand/shallow';
5
6
 
6
7
  import { useSettings } from '@/store/settings';
7
8
  import { createUploadImageHandler } from '@/utils/uploadFIle';
8
9
 
10
+ const useStyle = createStyles(
11
+ ({ css, token }) => css`
12
+ cursor: pointer;
13
+ border-radius: 50%;
14
+ transition: scale 400ms ${token.motionEaseOut}, box-shadow 100ms ${token.motionEaseOut};
15
+
16
+ &:hover {
17
+ box-shadow: 0 0 0 3px ${token.colorText};
18
+ }
19
+
20
+ &:active {
21
+ scale: 0.8;
22
+ }
23
+ `,
24
+ );
25
+
9
26
  interface AvatarWithUploadProps {
10
27
  size?: number;
11
28
  }
12
29
 
13
- export default memo<AvatarWithUploadProps>(({ size = 40 }) => {
30
+ const AvatarWithUpload = memo<AvatarWithUploadProps>(({ size = 40 }) => {
14
31
  const [avatar, setSettings] = useSettings((st) => [st.settings.avatar, st.setSettings], shallow);
32
+ const { styles } = useStyle();
15
33
 
16
34
  const handleUploadAvatar = createUploadImageHandler((avatar) => {
17
35
  setSettings({ avatar });
18
36
  });
19
37
 
20
38
  return (
21
- <div style={{ maxHeight: size, maxWidth: size }}>
39
+ <div className={styles} style={{ maxHeight: size, maxWidth: size }}>
22
40
  <Upload beforeUpload={handleUploadAvatar} itemRender={() => void 0} maxCount={1}>
23
41
  {avatar ? <Avatar avatar={avatar} size={size} /> : <Logo size={size} />}
24
42
  </Upload>
25
43
  </div>
26
44
  );
27
45
  });
46
+
47
+ export default AvatarWithUpload;
@@ -14,7 +14,7 @@ export const useStyles = createStyles(({ css, token }) => ({
14
14
  `,
15
15
  }));
16
16
 
17
- export default memo<PropsWithChildren>(({ children }) => {
17
+ const FolderPanel = memo<PropsWithChildren>(({ children }) => {
18
18
  const { styles } = useStyles();
19
19
  const [sessionsWidth, sessionExpandable] = useSettings(
20
20
  (s) => [s.sessionsWidth, s.sessionExpandable],
@@ -53,3 +53,5 @@ export default memo<PropsWithChildren>(({ children }) => {
53
53
  </DraggablePanel>
54
54
  );
55
55
  });
56
+
57
+ export default FolderPanel;
@@ -0,0 +1,7 @@
1
+ import { memo } from 'react';
2
+
3
+ import { HEADER_HEIGHT } from '@/const/layoutTokens';
4
+
5
+ const HeaderSpacing = memo(() => <div style={{ flex: 'none', height: HEADER_HEIGHT }} />);
6
+
7
+ export default HeaderSpacing;
@@ -2,20 +2,23 @@ import { ActionIcon, DraggablePanel, DraggablePanelContainer } from '@lobehub/ui
2
2
  import { createStyles } from 'antd-style';
3
3
  import { LucideEdit, LucideX } from 'lucide-react';
4
4
  import Router from 'next/router';
5
+ import { rgba } from 'polished';
5
6
  import { useTranslation } from 'react-i18next';
6
7
  import { Flexbox } from 'react-layout-kit';
7
8
  import { shallow } from 'zustand/shallow';
8
9
 
10
+ import { CHAT_SIDEBAR_WIDTH, HEADER_HEIGHT } from '@/const/layoutTokens';
9
11
  import { useSessionStore } from '@/store/session';
10
12
 
11
13
  import ReadMode from './ReadMode';
12
14
 
13
- const WIDTH = 280;
14
-
15
- const useStyles = createStyles(({ css, token }) => ({
16
- drawer: css`
17
- background: ${token.colorBgLayout};
18
- `,
15
+ const useStyles = createStyles(({ cx, css, token, stylish }) => ({
16
+ drawer: cx(
17
+ stylish.blurStrong,
18
+ css`
19
+ background: ${rgba(token.colorBgLayout, 0.4)};
20
+ `,
21
+ ),
19
22
  header: css`
20
23
  border-bottom: 1px solid ${token.colorBorder};
21
24
  `,
@@ -34,14 +37,15 @@ const Config = () => {
34
37
  className={styles.drawer}
35
38
  expand={showAgentSettings}
36
39
  expandable={false}
37
- maxWidth={WIDTH}
38
- minWidth={WIDTH}
40
+ headerHeight={HEADER_HEIGHT}
41
+ maxWidth={CHAT_SIDEBAR_WIDTH}
42
+ minWidth={CHAT_SIDEBAR_WIDTH}
39
43
  mode={'float'}
40
44
  pin
41
45
  placement={'right'}
42
46
  resize={{ left: false }}
43
47
  >
44
- <DraggablePanelContainer style={{ flex: 'none', minWidth: WIDTH }}>
48
+ <DraggablePanelContainer style={{ flex: 'none', minWidth: CHAT_SIDEBAR_WIDTH }}>
45
49
  <Flexbox
46
50
  align={'center'}
47
51
  className={styles.header}
@@ -5,6 +5,7 @@ import { Archive, Eraser, Languages } from 'lucide-react';
5
5
  import { memo, useMemo, useState } from 'react';
6
6
  import { shallow } from 'zustand/shallow';
7
7
 
8
+ import { CHAT_TEXTAREA_HEIGHT, HEADER_HEIGHT } from '@/const/layoutTokens';
8
9
  import { ModelTokens } from '@/const/modelTokens';
9
10
  import { agentSelectors, chatSelectors, useSessionStore } from '@/store/session';
10
11
  import { useSettings } from '@/store/settings';
@@ -29,7 +30,8 @@ const ChatInput = () => {
29
30
  <DraggablePanel
30
31
  expandable={false}
31
32
  fullscreen={expand}
32
- minHeight={200}
33
+ headerHeight={HEADER_HEIGHT}
34
+ minHeight={CHAT_TEXTAREA_HEIGHT}
33
35
  onSizeChange={(_, size) => {
34
36
  if (!size) return;
35
37
  useSettings.setState({
@@ -38,6 +40,7 @@ const ChatInput = () => {
38
40
  }}
39
41
  placement="bottom"
40
42
  size={{ height: inputHeight, width: '100%' }}
43
+ style={{ zIndex: 10 }}
41
44
  >
42
45
  <ChatInputArea
43
46
  actions={
@@ -49,7 +52,7 @@ const ChatInput = () => {
49
52
  }
50
53
  expand={expand}
51
54
  footer={<Button icon={<Icon icon={Archive} />} />}
52
- minHeight={200}
55
+ minHeight={CHAT_TEXTAREA_HEIGHT}
53
56
  onExpandChange={setExpand}
54
57
  onInputChange={setText}
55
58
  onSend={sendMessage}
@@ -1,30 +1,18 @@
1
- import { createStyles } from 'antd-style';
2
1
  import { memo } from 'react';
3
- import { Flexbox } from 'react-layout-kit';
4
2
 
3
+ import HeaderSpacing from '@/features/HeaderSpacing';
5
4
  import ChatInput from '@/pages/chat/[id]/Conversation/Input';
6
5
 
7
6
  import ChatList from './ChatList';
8
7
 
9
- const useStyles = createStyles(({ css, token }) => ({
10
- input: css`
11
- position: sticky;
12
- z-index: 10;
13
- bottom: 0;
14
- background: ${token.colorBgLayout};
15
- `,
16
- }));
17
-
18
8
  const Conversation = () => {
19
- const { styles } = useStyles();
20
9
  return (
21
10
  <>
22
11
  <div style={{ flex: 1, overflowY: 'scroll' }}>
12
+ <HeaderSpacing />
23
13
  <ChatList />
24
14
  </div>
25
- <Flexbox className={styles.input}>
26
- <ChatInput />
27
- </Flexbox>
15
+ <ChatInput />
28
16
  </>
29
17
  );
30
18
  };
@@ -6,6 +6,8 @@ import { memo } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { Flexbox } from 'react-layout-kit';
8
8
 
9
+ import HeaderSpacing from '@/features/HeaderSpacing';
10
+
9
11
  import ChatLayout from '../../layout';
10
12
  import AgentConfig from './AgentConfig';
11
13
  import AgentMeta from './AgentMeta';
@@ -51,6 +53,7 @@ const EditPage = memo(() => {
51
53
  />
52
54
  {/*form*/}
53
55
  <Flexbox className={styles.form} flex={1} gap={10} padding={24}>
56
+ <HeaderSpacing />
54
57
  <AgentMeta />
55
58
  <AgentConfig />
56
59
  </Flexbox>
@@ -23,16 +23,10 @@ const Chat = memo(() => {
23
23
  <Head>
24
24
  <title>{pageTitle}</title>
25
25
  </Head>
26
-
27
- <Flexbox flex={1}>
26
+ <Flexbox id={'lobe-conversion-container'} style={{ height: '100vh', position: 'relative' }}>
28
27
  <Header />
29
- <Flexbox
30
- id={'lobe-conversion-container'}
31
- style={{ height: 'calc(100vh - 64px)', position: 'relative' }}
32
- >
33
- <Conversation />
34
- <Config />
35
- </Flexbox>
28
+ <Conversation />
29
+ <Config />
36
30
  </Flexbox>
37
31
  </Layout>
38
32
  );
@@ -43,7 +43,7 @@ const ChatLayout = memo<PropsWithChildren>(({ children }) => {
43
43
  <Flexbox horizontal width={'100%'}>
44
44
  <SideBar />
45
45
  <Sessions />
46
- {children}
46
+ <Flexbox flex={1}>{children}</Flexbox>
47
47
  </Flexbox>
48
48
  );
49
49
  });
@@ -8,8 +8,8 @@ import { useTranslation } from 'react-i18next';
8
8
  import { shallow } from 'zustand/shallow';
9
9
 
10
10
  import AvatarWithUpload from '@/features/AvatarWithUpload';
11
+ import SliderWithInput from '@/features/SliderWithInput';
11
12
  import { options } from '@/locales/options';
12
- import SliderWithInput from '@/pages/setting/SliderWithInput';
13
13
  import { settingsSelectors, useSettings } from '@/store/settings';
14
14
  import { DEFAULT_SETTINGS } from '@/store/settings/initialState';
15
15
  import { ConfigKeys } from '@/types/exportConfig';
@@ -3,6 +3,7 @@ import { memo, useEffect } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { Flexbox } from 'react-layout-kit';
5
5
 
6
+ import HeaderSpacing from '@/features/HeaderSpacing';
6
7
  import SideBar from '@/features/SideBar';
7
8
  import { createI18nNext } from '@/locales/create';
8
9
  import { Sessions } from '@/pages/chat/SessionList';
@@ -30,6 +31,7 @@ const SettingLayout = memo(() => {
30
31
  <Flexbox flex={1}>
31
32
  <Header />
32
33
  <Flexbox align={'center'} flex={1} padding={24} style={{ overflow: 'auto' }}>
34
+ <HeaderSpacing />
33
35
  <SettingForm />
34
36
  </Flexbox>
35
37
  </Flexbox>