feat: stream cards improvements

- edit toggle
- reorder with drag and drop
- delete button inside edit modal
- add ability to clear image from card
- make card textarea taller and avoid horizontal resize
This commit is contained in:
Alejandro Gomez
2023-07-28 08:09:55 +02:00
parent 3e2336129c
commit 4e4ea9efa6
12 changed files with 419 additions and 78 deletions

View File

@ -38,8 +38,8 @@ async function voidCatUpload(file: File | Blob): Promise<UploadResult> {
}
}
export function FileUploader({ onFileUpload }) {
const [img, setImg] = useState();
export function FileUploader({ defaultImage, onClear, onFileUpload }) {
const [img, setImg] = useState(defaultImage);
const [isUploading, setIsUploading] = useState(false);
async function onFileChange(ev) {
@ -63,13 +63,25 @@ export function FileUploader({ onFileUpload }) {
}
}
function clearImage() {
setImg("");
onClear();
}
return (
<div className="file-uploader-container">
<label className="file-uploader">
<input type="file" onChange={onFileChange} />
{isUploading ? "Uploading..." : "Add File"}
</label>
{img && <img className="image-preview" src={img} />}
<div className="file-uploader-preview">
{img?.length > 0 && (
<button className="btn btn-primary clear-button" onClick={clearImage}>
Clear
</button>
)}
{img && <img className="image-preview" src={img} />}
</div>
</div>
);
}