This commit is contained in:
parent
23c4585bc1
commit
7bc6d002a9
90 changed files with 13401 additions and 1 deletions
98
src/screens/util.tsx
Normal file
98
src/screens/util.tsx
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
import { cn } from "../lib/utils";
|
||||
import Controls from "../windowControls";
|
||||
import { isTauri } from "@tauri-apps/api/core";
|
||||
|
||||
export default function CreateScreen({
|
||||
children,
|
||||
className,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"bg-background w-screen h-screen flex flex-col justify-center items-center",
|
||||
className,
|
||||
)}
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<>
|
||||
<Controls className="fixed top-0 right-0 m-1.75 mr-[7.6px]! ring-foreground/15" />
|
||||
{children}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
import { Button } from "../cmp/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from "../cmp/alert-dialog";
|
||||
import { useIsMobile } from "../lib/utils";
|
||||
|
||||
export function ClearStorageButton({ className }: { className?: string }) {
|
||||
const isMobile = useIsMobile();
|
||||
return (
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger
|
||||
render={
|
||||
<Button
|
||||
variant="destructive"
|
||||
className={cn(isMobile ? "w-full" : "", className)}
|
||||
>
|
||||
Clear storage
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
Are you sure you want to clear storage?
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
This action cannot be undone. It will clear all your settings and
|
||||
credentials.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogAction
|
||||
onClick={async () => {
|
||||
localStorage.clear();
|
||||
for (const db of await indexedDB.databases()) {
|
||||
indexedDB.deleteDatabase(db.name!);
|
||||
}
|
||||
location.reload();
|
||||
}}
|
||||
>
|
||||
Continue
|
||||
</AlertDialogAction>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
);
|
||||
}
|
||||
|
||||
export function StorageDestoryer() {
|
||||
const isMobile = useIsMobile();
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"fixed p-5 bottom-0",
|
||||
isMobile ? "w-full" : "right-0",
|
||||
isTauri() ? "py-10" : "",
|
||||
)}
|
||||
>
|
||||
<ClearStorageButton />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue