now you can learn from multiple decks, will implement editing the deaks soon!
This commit is contained in:
parent
dc4674f031
commit
dcf1fed0c3
4 changed files with 78 additions and 14 deletions
|
@ -8,20 +8,63 @@
|
||||||
import tempelateDeck from "./tempelateDeck.json";
|
import tempelateDeck from "./tempelateDeck.json";
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
SetNewDeck(JSON.parse(localStorage.getItem("deck")) || tempelateDeck);
|
SetNewDeck(JSON.parse(localStorage.getItem("deck")) || tempelateDeck, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let DemoDeck = [
|
||||||
|
{
|
||||||
|
deckName: "Tech",
|
||||||
|
cards: [
|
||||||
|
{ Q: "What is Svelte?", a: "A modern JavaScript framework for building user interfaces." },
|
||||||
|
{ Q: "What is a component?", a: "A reusable piece of UI in Svelte." },
|
||||||
|
{ Q: "How do you create a reactive variable?", a: "$: variableName = value;" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deckName: "Math Basics",
|
||||||
|
cards: [
|
||||||
|
{ Q: "What is 2 + 2?", a: "4" },
|
||||||
|
{ Q: "What is the square root of 16?", a: "4" },
|
||||||
|
{ Q: "What is 5 * 6?", a: "30" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deckName: "Geography",
|
||||||
|
cards: [
|
||||||
|
{ Q: "What is the capital of France?", a: "Paris" },
|
||||||
|
{ Q: "Which continent is Egypt in?", a: "Africa" },
|
||||||
|
{ Q: "What is the largest ocean?", a: "Pacific Ocean" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex h-full flex-col overflow-hidden">
|
<div class="flex h-full flex-col overflow-hidden">
|
||||||
{#if stats.isDeckEmpty}
|
{#if stats.isDeckEmpty}
|
||||||
<div class="flex flex-1 flex-col items-center justify-center gap-3">
|
<div class="flex flex-1 flex-col items-center justify-center gap-3">
|
||||||
<h1 class="text-4xl">Hey, You learned everything!</h1>
|
<h1 class="text-4xl">Choose a Deck To lean from!</h1>
|
||||||
<button onclick={() => resetDeck()} class="big btn green">Reset Deck</button>
|
<div>
|
||||||
|
<select
|
||||||
|
id="ChooseTheDeck"
|
||||||
|
onchange={(event) => {
|
||||||
|
const selectedDeck = DemoDeck.find((deck) => deck.deckName === event.target.value);
|
||||||
|
if (selectedDeck) {
|
||||||
|
SetNewDeck(selectedDeck.cards);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
class="input"
|
||||||
|
>
|
||||||
|
<option value="" disabled selected> goo ahead choose one! </option>
|
||||||
|
{#each DemoDeck as deckOption}
|
||||||
|
<option value={deckOption.deckName}>{deckOption.deckName}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex flex-1 flex-col items-center justify-center gap-2">
|
<div class="flex flex-1 flex-col items-center justify-center">
|
||||||
<div class="flex flex-col gap-1 text-center">
|
<div class="flex flex-col gap-1 text-center">
|
||||||
<div class="flex items-center justify-center p-2">
|
<div class="flex flex-col items-center justify-center gap-5 p-2">
|
||||||
<StatsAndButtons />
|
<StatsAndButtons />
|
||||||
</div>
|
</div>
|
||||||
<Card />
|
<Card />
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
export let card = $state({ Q: "", a: "" });
|
export let card = $state({ Q: "", a: "" });
|
||||||
|
|
||||||
export let statusOfCard = $state({
|
export let statusOfCard = $state({
|
||||||
|
@ -15,13 +14,14 @@ export let deck = [
|
||||||
{ Q: "Will @Shub go totally bankrupt?", a: "yes!" },
|
{ Q: "Will @Shub go totally bankrupt?", a: "yes!" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export function SetNewDeck (newDeck) {
|
export function SetNewDeck(newDeck, ThisIsOfPageLoad = false) {
|
||||||
deck = newDeck;
|
deck = newDeck;
|
||||||
resetDeck();
|
resetDeck();
|
||||||
|
stats.isDeckEmpty = ThisIsOfPageLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
export let stats = $state({
|
export let stats = $state({
|
||||||
isDeckEmpty: false,
|
isDeckEmpty: true,
|
||||||
AnswerKnown: 0,
|
AnswerKnown: 0,
|
||||||
AnswerNotKnown: 0,
|
AnswerNotKnown: 0,
|
||||||
AnswerNotChecked: deck.length,
|
AnswerNotChecked: deck.length,
|
||||||
|
|
|
@ -1,5 +1,26 @@
|
||||||
[
|
[
|
||||||
{ "Q": "Best programer in the world?", "a": "RezHackXYZ" },
|
{
|
||||||
{ "Q": "Best coding community?", "a": "HackClub" },
|
"deckName": "Tech",
|
||||||
{ "Q": "Will @Shub go totally bankrupt?", "a": "yes!" }
|
"cards": [
|
||||||
|
{ "Q": "What is Svelte?", "a": "Best web dev Framework ever." },
|
||||||
|
{ "Q": "What is a component?", "a": "A reusable piece of UI in Svelte." },
|
||||||
|
{ "Q": "How do you create a reactive variable?", "a": "$: variableName = value;" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"deckName": "Math Basics",
|
||||||
|
"cards": [
|
||||||
|
{ "Q": "What is 2 + 2?", "a": "4" },
|
||||||
|
{ "Q": "What is the square root of 16?", "a": "4" },
|
||||||
|
{ "Q": "What is 5 * 6?", "a": "30" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"deckName": "Geography",
|
||||||
|
"cards": [
|
||||||
|
{ "Q": "What is the capital of France?", "a": "Paris" },
|
||||||
|
{ "Q": "Which continent is Egypt in?", "a": "Africa" },
|
||||||
|
{ "Q": "What is the largest ocean?", "a": "Pacific Ocean" }
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
import { colseModal, ShowSeconds } from "./IdleScreen/logic/TimeAndTableData.svelte.js";
|
import { colseModal, ShowSeconds } from "./IdleScreen/logic/TimeAndTableData.svelte.js";
|
||||||
import EditTimetableDiv from "./IdleScreen/components/timetable/EditTimetable.svelte";
|
import EditTimetableDiv from "./IdleScreen/components/timetable/EditTimetable.svelte";
|
||||||
import { TabOpen } from "./randomname/+page.svelte";
|
import { TabOpen } from "./randomname/+page.svelte";
|
||||||
import { resetDeck } from "./flashcards/logic.svelte";
|
import { resetDeck, stats } from "./flashcards/logic.svelte";
|
||||||
import EditCards from "./flashcards/editCards.svelte";
|
import EditCards from "./flashcards/editCards.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
<button class="btn dull mini">Edit Decks</button>
|
<button class="btn dull mini">Edit Decks</button>
|
||||||
</Trigger>
|
</Trigger>
|
||||||
</Modal>
|
</Modal>
|
||||||
<button class="btn dull mini" onclick={() => resetDeck}> Reset current Deck </button>
|
<button class="btn dull mini" onclick={() => (stats.isDeckEmpty = true)}> Change Deck</button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue