Skip to content

Commit

Permalink
✨ feat: Add import statement and define CSS styles for Avatar component
Browse files Browse the repository at this point in the history
- Add import statement for 'createStyles' from 'antd-style' in 'AvatarWithUpload/index.tsx'
- Define 'useStyle' constant containing CSS styles for Avatar component

feat: Remove unused constant and update component wrapping in Conversation

- Remove 'useStyles' constant and associated CSS styles from 'Conversation/index.tsx'
- Remove 'Flexbox' component wrapping 'ChatInput' component

feat: Update styles for Flexbox component in index page

- Set height of 'Flexbox' component to '100vh'
- Set 'overflow' style to 'hidden'
- Set 'position' style to 'relative'
  • Loading branch information
canisminor1990 committed Jul 18, 2023
1 parent 3a63ef3 commit 8c23a8d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
20 changes: 19 additions & 1 deletion src/features/AvatarWithUpload/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
import { Avatar, Logo } from '@lobehub/ui';
import { Upload } from 'antd';
import { createStyles } from 'antd-style';
import { memo } from 'react';
import { shallow } from 'zustand/shallow';

import { useSettings } from '@/store/settings';
import { createUploadImageHandler } from '@/utils/uploadFIle';

const useStyle = createStyles(
({ css, token }) => css`
cursor: pointer;
border-radius: 50%;
transition: scale 400ms ${token.motionEaseOut}, box-shadow 100ms ${token.motionEaseOut};
&:hover {
box-shadow: 0 0 0 3px ${token.colorText};
}
&:active {
scale: 0.8;
}
`,
);

interface AvatarWithUploadProps {
size?: number;
}

export default memo<AvatarWithUploadProps>(({ size = 40 }) => {
const [avatar, setSettings] = useSettings((st) => [st.settings.avatar, st.setSettings], shallow);
const { styles } = useStyle();

const handleUploadAvatar = createUploadImageHandler((avatar) => {
setSettings({ avatar });
});

return (
<div style={{ maxHeight: size, maxWidth: size }}>
<div className={styles} style={{ maxHeight: size, maxWidth: size }}>
<Upload beforeUpload={handleUploadAvatar} itemRender={() => void 0} maxCount={1}>
{avatar ? <Avatar avatar={avatar} size={size} /> : <Logo size={size} />}
</Upload>
Expand Down
16 changes: 1 addition & 15 deletions src/pages/chat/[id]/Conversation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
import { createStyles } from 'antd-style';
import { memo } from 'react';
import { Flexbox } from 'react-layout-kit';

import ChatInput from '@/pages/chat/[id]/Conversation/Input';

import ChatList from './ChatList';

const useStyles = createStyles(({ css, token }) => ({
input: css`
position: sticky;
z-index: 10;
bottom: 0;
background: ${token.colorBgLayout};
`,
}));

const Conversation = () => {
const { styles } = useStyles();
return (
<>
<div style={{ flex: 1, overflowY: 'scroll' }}>
<ChatList />
</div>
<Flexbox className={styles.input}>
<ChatInput />
</Flexbox>
<ChatInput />
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/chat/[id]/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Chat = memo(() => {
<title>{pageTitle}</title>
</Head>

<Flexbox flex={1}>
<Flexbox flex={1} height={'100vh'} style={{ overflow: 'hidden', position: 'relative' }}>
<Header />
<Flexbox
id={'lobe-conversion-container'}
Expand Down

0 comments on commit 8c23a8d

Please sign in to comment.