added background removal

This commit is contained in:
SethBurkart123
2023-10-20 07:09:38 +11:00
parent 7525a9041e
commit 310ff7a281
2 changed files with 67 additions and 51 deletions
+12 -2
View File
@@ -88,16 +88,25 @@ const Themes: FC = () => {
setBackgrounds(prev => prev.filter(bg => bg.id !== fileId)); setBackgrounds(prev => prev.filter(bg => bg.id !== fileId));
}; };
const selectNoBackground = (): void => {
setSelectedBackground(null);
localStorage.removeItem('selectedBackground');
};
useEffect(() => { useEffect(() => {
loadBackgrounds(); loadBackgrounds();
}, []); }, []);
return ( return (
<div> <div>
<button className="absolute top-0 right-0 p-2 text-lg text-blue-500" onClick={() => setIsEditMode(!isEditMode)}> <button className="p-2 my-4 text-white bg-red-600 rounded" onClick={() => selectNoBackground()}>
No Background
</button>
<div className="relative">
<button className="absolute top-0 right-0 p-2 text-[0.8rem] text-blue-500" onClick={() => setIsEditMode(!isEditMode)}>
{isEditMode ? 'Done' : 'Edit'} {isEditMode ? 'Done' : 'Edit'}
</button> </button>
<h2 className="py-2 text-lg font-bold">Images</h2> <h2 className="pb-2 text-lg font-bold">Images</h2>
<div className="flex flex-wrap gap-4"> <div className="flex flex-wrap gap-4">
{/* Image uploader swatch */} {/* Image uploader swatch */}
<div className="relative w-16 h-16 overflow-hidden transition rounded-xl bg-zinc-900"> <div className="relative w-16 h-16 overflow-hidden transition rounded-xl bg-zinc-900">
@@ -154,6 +163,7 @@ const Themes: FC = () => {
))} ))}
</div> </div>
</div> </div>
</div>
); );
}; };
+6
View File
@@ -37,6 +37,12 @@ const updateBackground = async () => {
const data = await readData(); const data = await readData();
if (!data) { if (!data) {
console.log("No data found in IndexedDB."); console.log("No data found in IndexedDB.");
const container = document.getElementById("media-container");
const currentMedia = container.querySelector(".current-media");
if (currentMedia) {
currentMedia.remove();
}
return; return;
} }