parent
4692dda8f3
commit
3e045cf8a8
|
|
@ -23,7 +23,7 @@ type BehaviourType =
|
||||||
behaviour: "multi";
|
behaviour: "multi";
|
||||||
onChange: (files: File[]) => void;
|
onChange: (files: File[]) => void;
|
||||||
append?: (files: File[]) => void;
|
append?: (files: File[]) => void;
|
||||||
}
|
};
|
||||||
|
|
||||||
type StyleType =
|
type StyleType =
|
||||||
| {
|
| {
|
||||||
|
|
@ -32,7 +32,7 @@ type StyleType =
|
||||||
height?: number;
|
height?: number;
|
||||||
previewURL?: string;
|
previewURL?: string;
|
||||||
defaultPreview?: string;
|
defaultPreview?: string;
|
||||||
desaturateDefault?: boolean
|
desaturateDefault?: boolean;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
style: "attachment";
|
style: "attachment";
|
||||||
|
|
@ -40,13 +40,19 @@ type StyleType =
|
||||||
uploading: boolean;
|
uploading: boolean;
|
||||||
cancel: () => void;
|
cancel: () => void;
|
||||||
size?: number;
|
size?: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
type Props = BehaviourType & StyleType & {
|
type Props = BehaviourType &
|
||||||
fileType: "backgrounds" | "icons" | "avatars" | "attachments" | "banners";
|
StyleType & {
|
||||||
|
fileType:
|
||||||
|
| "backgrounds"
|
||||||
|
| "icons"
|
||||||
|
| "avatars"
|
||||||
|
| "attachments"
|
||||||
|
| "banners";
|
||||||
maxFileSize: number;
|
maxFileSize: number;
|
||||||
remove: () => Promise<void>;
|
remove: () => Promise<void>;
|
||||||
}
|
};
|
||||||
|
|
||||||
export async function uploadFile(
|
export async function uploadFile(
|
||||||
autumnURL: string,
|
autumnURL: string,
|
||||||
|
|
@ -75,6 +81,7 @@ export function grabFiles(
|
||||||
) {
|
) {
|
||||||
const input = document.createElement("input");
|
const input = document.createElement("input");
|
||||||
input.type = "file";
|
input.type = "file";
|
||||||
|
input.accept = "*";
|
||||||
input.multiple = multiple ?? false;
|
input.multiple = multiple ?? false;
|
||||||
|
|
||||||
input.onchange = async (e) => {
|
input.onchange = async (e) => {
|
||||||
|
|
@ -226,7 +233,12 @@ export function FileUploader(props: Props) {
|
||||||
})}
|
})}
|
||||||
data-uploading={uploading}>
|
data-uploading={uploading}>
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.image, props.desaturateDefault && previewURL == null && styles.desaturate)}
|
className={classNames(
|
||||||
|
styles.image,
|
||||||
|
props.desaturateDefault &&
|
||||||
|
previewURL == null &&
|
||||||
|
styles.desaturate,
|
||||||
|
)}
|
||||||
style={{
|
style={{
|
||||||
backgroundImage:
|
backgroundImage:
|
||||||
style === "icon"
|
style === "icon"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue