mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
Merge branch 'feat/filesystem_and_search' of https://github.com/toeverything/AFFiNE into feat/filesystem_and_search
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import Button from '@/ui/button/button';
|
||||
import { FC, useRef, ChangeEvent, ReactElement } from 'react';
|
||||
import { styled } from '@/styles';
|
||||
interface Props {
|
||||
uploadType?: string;
|
||||
view?: ReactElement;
|
||||
accept?: string;
|
||||
fileChange: (file: File) => void;
|
||||
}
|
||||
export const Upload: FC<Props> = props => {
|
||||
const { fileChange, accept } = props;
|
||||
const input_ref = useRef<HTMLInputElement>(null);
|
||||
const _chooseFile = () => {
|
||||
if (input_ref.current) {
|
||||
input_ref.current.click();
|
||||
}
|
||||
};
|
||||
const _handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const files = e.target.files;
|
||||
if (!files) {
|
||||
return;
|
||||
}
|
||||
const file = files[0];
|
||||
fileChange(file);
|
||||
if (input_ref.current) {
|
||||
input_ref.current.value = '';
|
||||
}
|
||||
};
|
||||
return (
|
||||
<UploadStyle onClick={_chooseFile}>
|
||||
{props.view ?? <Button>Upload</Button>}
|
||||
<input
|
||||
ref={input_ref}
|
||||
type="file"
|
||||
style={{ display: 'none' }}
|
||||
onChange={_handleInputChange}
|
||||
accept={accept}
|
||||
/>
|
||||
</UploadStyle>
|
||||
);
|
||||
};
|
||||
|
||||
const UploadStyle = styled('div')(() => {
|
||||
return {
|
||||
display: 'inline-block',
|
||||
};
|
||||
});
|
||||
@@ -16,6 +16,7 @@ import { WorkspaceDelete } from './delete';
|
||||
import { Workspace as StoreWorkspace } from '@blocksuite/store';
|
||||
import { debounce } from '@/utils';
|
||||
import { WorkspaceLeave } from './leave';
|
||||
import { Upload } from '@/components/file-upload';
|
||||
|
||||
export const GeneralPage = ({
|
||||
workspace,
|
||||
@@ -71,7 +72,14 @@ export const GeneralPage = ({
|
||||
|
||||
return workspace ? (
|
||||
<div>
|
||||
<StyledSettingH2 marginTop={56}>Workspace Avatar</StyledSettingH2>
|
||||
<StyledSettingH2 marginTop={56}>
|
||||
Workspace Avatar
|
||||
<Upload
|
||||
fileChange={file => {
|
||||
console.log(file);
|
||||
}}
|
||||
></Upload>
|
||||
</StyledSettingH2>
|
||||
<StyledSettingAvatarContent>
|
||||
<StyledSettingAvatar
|
||||
alt="workspace avatar"
|
||||
|
||||
Reference in New Issue
Block a user