From 6ff2012e26a6e8cd4daf9b0220d58b3621e8bf31 Mon Sep 17 00:00:00 2001
From: ryan
Date: Wed, 1 Oct 2025 13:23:27 -0700
Subject: [PATCH] half-working flashcards
---
hindki/astro.config.mjs | 9 ++-
hindki/src/components/FlashCard.tsx | 41 ++++++++++++
hindki/src/components/PageSidebar.astro | 85 +++++++++++++++++++++++++
hindki/src/components/VocabWord.astro | 12 ++++
hindki/src/content.config.ts | 1 +
hindki/src/pages/learn/index.astro | 15 +++++
hindki/src/styles/custom.css | 10 +--
hindki/src/vocab_list.yaml | 31 ++++++---
8 files changed, 188 insertions(+), 16 deletions(-)
create mode 100644 hindki/src/components/FlashCard.tsx
create mode 100644 hindki/src/components/PageSidebar.astro
create mode 100644 hindki/src/pages/learn/index.astro
diff --git a/hindki/astro.config.mjs b/hindki/astro.config.mjs
index c358b2e..5d1eadc 100644
--- a/hindki/astro.config.mjs
+++ b/hindki/astro.config.mjs
@@ -72,10 +72,13 @@ export default defineConfig({
link: "/edit/add-vocab",
},
{
- label: "Edit YAML",
- link: "/edit",
+ label: "Learn",
+ link: "/learn",
},
],
+ components: {
+ PageSidebar: "@/components/PageSidebar.astro",
+ },
}),
react(),
],
@@ -83,4 +86,4 @@ export default defineConfig({
adapter: node({
mode: "standalone",
}),
-});
\ No newline at end of file
+});
diff --git a/hindki/src/components/FlashCard.tsx b/hindki/src/components/FlashCard.tsx
new file mode 100644
index 0000000..34e5e6a
--- /dev/null
+++ b/hindki/src/components/FlashCard.tsx
@@ -0,0 +1,41 @@
+import React, { useState, useEffect } from "react";
+
+export default function FlashCard(word: any) {
+ // Get state of all checkboxes on page
+ const [numCheckedBoxes, setNumCheckedBoxes] = useState(0);
+
+ const updateCheckboxCount = () => {
+ const checkboxes = document.querySelectorAll('input[type="checkbox"]');
+ const checkedBoxes = Array.from(checkboxes).filter(
+ (checkbox) => (checkbox as HTMLInputElement).checked,
+ );
+ setNumCheckedBoxes(checkedBoxes.length);
+ };
+
+ useEffect(() => {
+ // Initial count
+ updateCheckboxCount();
+
+ // Listen for checkbox changes
+ const handleCheckboxChange = (event: Event) => {
+ const target = event.target as HTMLInputElement;
+ if (target.type === "checkbox") {
+ updateCheckboxCount();
+ }
+ };
+
+ // Add event listener to the document to catch all checkbox changes
+ document.addEventListener("change", handleCheckboxChange);
+
+ // Cleanup event listener on unmount
+ return () => {
+ document.removeEventListener("change", handleCheckboxChange);
+ };
+ }, []);
+
+ return (
+
+
Word
+
+ );
+}
diff --git a/hindki/src/components/PageSidebar.astro b/hindki/src/components/PageSidebar.astro
new file mode 100644
index 0000000..32d35c2
--- /dev/null
+++ b/hindki/src/components/PageSidebar.astro
@@ -0,0 +1,85 @@
+---
+import Default from '@astrojs/starlight/components/PageSidebar.astro';
+
+const isLearningPage = Astro.locals.starlightRoute.id === 'learn';
+
+import { getCollection } from "astro:content";
+
+const categories = await getCollection("vocabList");
+const typesSet = new Set();
+categories.forEach((category) => {
+ category.data.words.forEach((word) => {
+ if (word.type) {
+ typesSet.add(word.type);
+ }
+ });
+});
+const types = Array.from(typesSet).sort();
+---
+
+{
+ isLearningPage ? (
+ <>
+
+ Help we're on mobile
+
+
+ >
+ ) : (
+
+
+
+ )
+}
+
+
\ No newline at end of file
diff --git a/hindki/src/components/VocabWord.astro b/hindki/src/components/VocabWord.astro
index 64deeed..0483d78 100644
--- a/hindki/src/components/VocabWord.astro
+++ b/hindki/src/components/VocabWord.astro
@@ -17,6 +17,7 @@ interface Props {
note?: string;
}>
see_also?: string[];
+ tags?: string[];
}
}
@@ -82,4 +83,15 @@ word.examples &&(
)) }
)}
+ { word.tags && (
+
+ {
+ word.tags.map((tag, i) => (
+ <>
+ { i < word.tags!.length - 1 ? " " : '' }
+ >
+ ))
+ }
+
+ )}
\ No newline at end of file
diff --git a/hindki/src/content.config.ts b/hindki/src/content.config.ts
index 013e64f..dca40e8 100644
--- a/hindki/src/content.config.ts
+++ b/hindki/src/content.config.ts
@@ -27,6 +27,7 @@ export const collections = {
)
.optional(),
see_also: z.array(z.string()).optional(),
+ tags: z.array(z.string()).optional(),
}),
),
}),
diff --git a/hindki/src/pages/learn/index.astro b/hindki/src/pages/learn/index.astro
new file mode 100644
index 0000000..0ab098a
--- /dev/null
+++ b/hindki/src/pages/learn/index.astro
@@ -0,0 +1,15 @@
+---
+import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
+import FlashCard from "@/components/FlashCard";
+const checkboxes = 3;
+---
+
+
+
+
diff --git a/hindki/src/styles/custom.css b/hindki/src/styles/custom.css
index bd4d3be..ae30ba9 100644
--- a/hindki/src/styles/custom.css
+++ b/hindki/src/styles/custom.css
@@ -147,7 +147,6 @@
/* Magenta for feminine */
--sl-badge-tip-bg: #cc3366;
--sl-badge-tip-border: #bb3355;
-
}
/* Dark theme overrides */
@@ -223,6 +222,10 @@ h6,
vertical-align: middle;
font-family: var(--font-sans);
}
+.tag-badge {
+ font-family: var(--font-sans);
+ background: transparent;
+}
.word-entry {
margin-bottom: 2em;
@@ -278,10 +281,9 @@ mark {
margin-top: 0 !important;
}
-.sl-container {
+/* .sl-container {
max-width: 100%;
-}
-
+} */
/* =================================================================
LANGUAGE-SPECIFIC STYLES
diff --git a/hindki/src/vocab_list.yaml b/hindki/src/vocab_list.yaml
index cc66eb1..fb18858 100644
--- a/hindki/src/vocab_list.yaml
+++ b/hindki/src/vocab_list.yaml
@@ -15,7 +15,8 @@
hindi: बात करना
gender: f
hindi: बात
- note: More abstract than "[चीज़](#चीज़)", often used for matters or topics -- as
+ note:
+ More abstract than "[चीज़](#चीज़)", often used for matters or topics -- as
in, things that are discussed.
see_also:
- "[चीज़](#चीज़)"
@@ -28,7 +29,8 @@
hindi: क्या आपकी मदद हुई है?
gender: f
hindi: मदद
- note: Used with का/के/की to indicate who is receiving help, and with either करना
+ note:
+ Used with का/के/की to indicate who is receiving help, and with either करना
(to actively help someone), or होना (to passively be helped). See the
links below for the generalized rules of these.
see_also:
@@ -43,6 +45,12 @@
- english: etc.
hindi: वग़ैरह
type: noun
+ - type: verb
+ english: to load
+ hindi: लादना
+ note: Load, as in a cart or lorry.
+ tags:
+ - cognate
- about: Hindi often uses repetition of words for emphasis or to indicate a
variety of related meanings.
slug: repetition
@@ -100,7 +108,8 @@
type: adjective
- english: Indian
hindi: भारतीय, हिंदुस्तानी
- note: There is some cultural context here, as obviously [not everyone in India
+ note:
+ There is some cultural context here, as obviously [not everyone in India
is Hindu](/culture/bharat-hindustan).
type: adjective
- english: Iranian
@@ -198,7 +207,8 @@
- english: jeweler
hindi: जौहरी
type: noun
- note: In addition to being a cognate (in my opinion at least), this was the name
+ note:
+ In addition to being a cognate (in my opinion at least), this was the name
of a favorite hotel ("The Johri") in Jaipur's Johri Bazaar (Jeweller's
Market).
- english: judge
@@ -249,19 +259,21 @@
- english: potter
hindi: कुम्हार
type: noun
- note: Interesting that "Kumar" is a common surname in Hindi, as "Potter" is
+ note:
+ Interesting that "Kumar" is a common surname in Hindi, as "Potter" is
fairly common in English.
- english: president
hindi: राष्ट्रपति
type: noun
- note: 'Literally: "Nation Husband". Weird, but I guess kind of makes sense?
+ note:
+ 'Literally: "Nation Husband". Weird, but I guess kind of makes sense?
Would they change this if India ever had a female president? (Could
India ever?)'
- english: prime minister
hindi: प्रधानमंत्री
type: noun
- note: "As you'd hope: प्रधान means \"prime/head/chief\", मंत्री means
- \"minister.\""
+ note: 'As you''d hope: प्रधान means "prime/head/chief", मंत्री means
+ "minister."'
- english: publisher
hindi: प्रकाशक
type: noun
@@ -274,7 +286,8 @@
- english: security guard
hindi: सुरक्षा कर्मचारी
type: noun
- note: I put the translation as "security guard", but while सुरक्षा does mean
+ note:
+ I put the translation as "security guard", but while सुरक्षा does mean
"security", कर्मचारी just means "employee."
- english: shopkeeper
hindi: दुकानदार