1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-28 14:16:41 +07:00

refactored comment form

This commit is contained in:
Fedor Katurov 2020-11-09 17:55:00 +07:00
parent af9b206a78
commit 9db25afb28
19 changed files with 235 additions and 153 deletions

View file

@ -0,0 +1,36 @@
import React, { FC, useCallback } from 'react';
import { ButtonGroup } from '~/components/input/ButtonGroup';
import { Button } from '~/components/input/Button';
interface IProps {
onUpload: (files: File[]) => void;
}
const CommentFormButtons: FC<IProps> = ({ onUpload }) => {
const onInputChange = useCallback(
event => {
event.preventDefault();
const files: File[] = Array.from(event.target?.files);
if (!files || !files.length) return;
onUpload(files);
},
[onUpload]
);
return (
<ButtonGroup>
<Button iconLeft="photo" size="small" color="gray" iconOnly>
<input type="file" onInput={onInputChange} multiple accept="image/*" />
</Button>
<Button iconRight="audio" size="small" color="gray" iconOnly>
<input type="file" onInput={onInputChange} multiple accept="audio/*" />
</Button>
</ButtonGroup>
);
};
export { CommentFormButtons };