2
0

Add user account page

This commit is contained in:
Baptiste Arnaud
2021-12-27 15:59:32 +01:00
parent 698867da5d
commit e10fe1a186
33 changed files with 911 additions and 129 deletions

View File

@ -0,0 +1,34 @@
import { Button, ButtonProps, chakra } from '@chakra-ui/react'
import React, { ChangeEvent } from 'react'
type UploadButtonProps = { onUploadChange: (file: File) => void } & ButtonProps
export const UploadButton = ({
onUploadChange,
...props
}: UploadButtonProps) => {
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
if (!e.target?.files) return
onUploadChange(e.target.files[0])
}
return (
<>
<chakra.input
type="file"
id="file-input"
display="none"
onChange={handleInputChange}
accept=".jpg, .jpeg, .png"
/>
<Button
as="label"
size="sm"
htmlFor="file-input"
cursor="pointer"
{...props}
>
{props.children}
</Button>
</>
)
}