added the way to edit using json for now, will add real ui soon!

This commit is contained in:
RezHackXYZ 2025-06-12 10:06:58 +05:30
parent 032c712641
commit 8824a81972
No known key found for this signature in database
GPG key ID: C4C90E569C9669E2
4 changed files with 46 additions and 3 deletions

View file

@ -1 +1,27 @@
<div class="border-2 rounded bg-zinc-800">heyyy</div>
<script>
import { SetNewDeck, deck } from "./logic.svelte";
import toast from "svelte-5-french-toast";
let LocalDeck = $state.snapshot(deck);
let deckText = JSON.stringify(LocalDeck, null, 2); // Pretty print for textarea
function saveDeck() {
try {
const parsedDeck = JSON.parse(deckText);
localStorage.setItem("deck", JSON.stringify(parsedDeck));
SetNewDeck(parsedDeck);
toast.success("Deck saved successfully! You can now close this window.");
} catch (e) {
toast.error("Invalid JSON format!");
}
}
</script>
<div class="flex flex-col items-center gap-2 rounded border-2 bg-zinc-800 p-3">
<textarea bind:value={deckText} class="input"></textarea>
<button on:click={saveDeck} class="btn">
<i class="nf nf-fa-save"></i>
Save
</button>
</div>