-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace antd uploads (#19942)
- Loading branch information
Showing
5 changed files
with
55 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,19 @@ | ||
import { Button, Upload } from 'antd' | ||
import { UploadFile } from 'antd/lib/upload/interface' | ||
import { LemonButton, LemonFileInput } from '@posthog/lemon-ui' | ||
import { IconUploadFile } from 'lib/lemon-ui/icons' | ||
|
||
export function UploadField({ | ||
value, | ||
onChange, | ||
}: { | ||
value?: UploadFile | null | ||
onChange?: (file?: UploadFile | null) => void | ||
}): JSX.Element { | ||
export function UploadField({ value, onChange }: { value?: File; onChange?: (file: File) => void }): JSX.Element { | ||
return ( | ||
<Upload | ||
<LemonFileInput | ||
accept={'image/*'} | ||
multiple={false} | ||
fileList={value?.size ? [value] : []} | ||
beforeUpload={(file) => { | ||
onChange?.(file) | ||
return false | ||
}} | ||
onRemove={() => { | ||
onChange?.(null) | ||
return false | ||
}} | ||
className="ph-ignore-input" | ||
> | ||
<Button icon={<IconUploadFile />}>Click to upload</Button> | ||
</Upload> | ||
onChange={(files) => onChange?.(files[0])} | ||
value={value?.size ? [value] : []} | ||
showUploadedFiles={false} | ||
callToAction={ | ||
<LemonButton className="ph-ignore-input" icon={<IconUploadFile />}> | ||
Click to upload | ||
</LemonButton> | ||
} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters