-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(FileField): rename from FileUpload and change types (#552)
- Loading branch information
Showing
83 changed files
with
2,118 additions
and
1,927 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
.badge { | ||
display: inline-block; | ||
padding: 0.2em 0.4em; | ||
padding: 0.2em 0.6em; | ||
background-color: hsl(201 96% 32%); | ||
color: white; | ||
border-radius: 12px; | ||
border-radius: 0.5rem; | ||
font-size: 0.875rem; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { FileField } from "@kobalte/core/file-field"; | ||
|
||
import style from "./file-field.module.css"; | ||
|
||
export function BasicExample() { | ||
return ( | ||
<FileField | ||
class={style.FileField} | ||
multiple | ||
maxFiles={5} | ||
onFileAccept={(data) => console.log("data", data)} | ||
onFileReject={(data) => console.log("data", data)} | ||
onFileChange={(data) => console.log("data", data)} | ||
> | ||
<FileField.Label class={style.FileField__label}> | ||
File Upload | ||
</FileField.Label> | ||
<FileField.Dropzone class={style.FileField__dropzone}> | ||
Drop your files here... | ||
<FileField.Trigger class={style.FileField__trigger}> | ||
Choose files! | ||
</FileField.Trigger> | ||
</FileField.Dropzone> | ||
<FileField.HiddenInput /> | ||
<FileField.ItemList class={style.FileField__itemGroup}> | ||
{(file) => ( | ||
<FileField.Item class={style.FileField__item}> | ||
<FileField.ItemPreviewImage | ||
class={style.FileField__itemPreviewImage} | ||
/> | ||
<FileField.ItemName class={style.FileField__itemName} /> | ||
<FileField.ItemSize class={style.FileField__itemSize} /> | ||
<FileField.ItemDeleteTrigger | ||
class={style.FileField__itemDeleteTrigger} | ||
> | ||
Delete | ||
</FileField.ItemDeleteTrigger> | ||
</FileField.Item> | ||
)} | ||
</FileField.ItemList> | ||
</FileField> | ||
); | ||
} | ||
|
||
export function HTMLFormExample() { | ||
let formRef: HTMLFormElement | undefined; | ||
|
||
const onSubmit = (event: SubmitEvent) => { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
|
||
const formData = new FormData(formRef); | ||
const uploadedFiles = formData.getAll("uploaded-files"); | ||
|
||
const fileNames = uploadedFiles | ||
.filter((file): file is File => file instanceof File) | ||
.map((file) => file.name); | ||
|
||
alert(JSON.stringify(fileNames, null, 2)); | ||
}; | ||
|
||
return ( | ||
<form class={style.formContainer} ref={formRef} onSubmit={onSubmit}> | ||
<FileField | ||
multiple | ||
maxFiles={5} | ||
onFileAccept={(data) => console.log("data", data)} | ||
onFileReject={(data) => console.log("data", data)} | ||
onFileChange={(data) => console.log("data", data)} | ||
> | ||
<FileField.Label class={style.FileField__label}> | ||
File Upload | ||
</FileField.Label> | ||
<FileField.Dropzone class={style.FileField__dropzone}> | ||
Drop your files here... | ||
<FileField.Trigger class={style.FileField__trigger}> | ||
Choose files! | ||
</FileField.Trigger> | ||
</FileField.Dropzone> | ||
<FileField.HiddenInput name="uploaded-files" /> | ||
<FileField.ItemList class={style.FileField__itemGroup}> | ||
{(file) => ( | ||
<FileField.Item class={style.FileField__item}> | ||
<FileField.ItemPreviewImage | ||
class={style.FileField__itemPreviewImage} | ||
/> | ||
<FileField.ItemName class={style.FileField__itemName} /> | ||
<FileField.ItemSize class={style.FileField__itemSize} /> | ||
<FileField.ItemDeleteTrigger | ||
class={style.FileField__itemDeleteTrigger} | ||
> | ||
Delete | ||
</FileField.ItemDeleteTrigger> | ||
</FileField.Item> | ||
)} | ||
</FileField.ItemList> | ||
</FileField> | ||
<button type="submit" class={style["submit-btn"]}> | ||
Submit Files | ||
</button> | ||
</form> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.