half-working flashcards
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 32s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 32s
This commit is contained in:
parent
8334a3cad8
commit
6ff2012e26
@ -72,10 +72,13 @@ export default defineConfig({
|
|||||||
link: "/edit/add-vocab",
|
link: "/edit/add-vocab",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Edit YAML",
|
label: "Learn",
|
||||||
link: "/edit",
|
link: "/learn",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
components: {
|
||||||
|
PageSidebar: "@/components/PageSidebar.astro",
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
react(),
|
react(),
|
||||||
],
|
],
|
||||||
|
|||||||
41
hindki/src/components/FlashCard.tsx
Normal file
41
hindki/src/components/FlashCard.tsx
Normal file
@ -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 (
|
||||||
|
<div className="flash-card">
|
||||||
|
<h2>Word</h2>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
85
hindki/src/components/PageSidebar.astro
Normal file
85
hindki/src/components/PageSidebar.astro
Normal file
@ -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<string>();
|
||||||
|
categories.forEach((category) => {
|
||||||
|
category.data.words.forEach((word) => {
|
||||||
|
if (word.type) {
|
||||||
|
typesSet.add(word.type);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const types = Array.from(typesSet).sort();
|
||||||
|
---
|
||||||
|
|
||||||
|
{
|
||||||
|
isLearningPage ? (
|
||||||
|
<>
|
||||||
|
<div class="lg:sl-hidden">
|
||||||
|
Help we're on mobile
|
||||||
|
</div>
|
||||||
|
<div class="right-sidebar-panel sl-hidden lg:sl-block">
|
||||||
|
<div class="sl-container">
|
||||||
|
<div class="filters">
|
||||||
|
<div class="category-filters">
|
||||||
|
<h2>Categories</h2>
|
||||||
|
<!-- Check boxes for each category -->
|
||||||
|
{
|
||||||
|
categories.map((category) => (
|
||||||
|
<div class="filter">
|
||||||
|
<input type="checkbox" id={category.id} name={category.id} value={category.id} checked />
|
||||||
|
<label for={category.id}>{category.id}</label>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<!-- Check boxes for each type of word -->
|
||||||
|
<div class="type-filters">
|
||||||
|
<h2>Types</h2>
|
||||||
|
{
|
||||||
|
types.map((type) => (
|
||||||
|
<div class="filter">
|
||||||
|
<input type="checkbox" id={type} name={type} value={type} checked />
|
||||||
|
<label for={type}>{type}</label>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Default>
|
||||||
|
<slot />
|
||||||
|
</Default>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.filters {
|
||||||
|
display: flex;
|
||||||
|
gap: 2em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
.sl-container{
|
||||||
|
padding: 1rem var(--sl-sidebar-pad-x);
|
||||||
|
}
|
||||||
|
.category-filters, .type-filters {
|
||||||
|
margin-top: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5em;
|
||||||
|
}
|
||||||
|
.filter {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
@ -17,6 +17,7 @@ interface Props {
|
|||||||
note?: string;
|
note?: string;
|
||||||
}>
|
}>
|
||||||
see_also?: string[];
|
see_also?: string[];
|
||||||
|
tags?: string[];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,4 +83,15 @@ word.examples &&(
|
|||||||
)) }
|
)) }
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
{ word.tags && (
|
||||||
|
<p>
|
||||||
|
{
|
||||||
|
word.tags.map((tag, i) => (
|
||||||
|
<>
|
||||||
|
<Badge text={tag} class="tag-badge"/>{ i < word.tags!.length - 1 ? " " : '' }
|
||||||
|
</>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</li>
|
</li>
|
||||||
@ -27,6 +27,7 @@ export const collections = {
|
|||||||
)
|
)
|
||||||
.optional(),
|
.optional(),
|
||||||
see_also: z.array(z.string()).optional(),
|
see_also: z.array(z.string()).optional(),
|
||||||
|
tags: z.array(z.string()).optional(),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
|||||||
15
hindki/src/pages/learn/index.astro
Normal file
15
hindki/src/pages/learn/index.astro
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
|
||||||
|
import FlashCard from "@/components/FlashCard";
|
||||||
|
const checkboxes = 3;
|
||||||
|
---
|
||||||
|
|
||||||
|
<StarlightPage
|
||||||
|
frontmatter={{
|
||||||
|
title: "Learning Mode ${checkboxes} checked",
|
||||||
|
tableOfContents: true,
|
||||||
|
prev: false,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FlashCard word="test" client:load />
|
||||||
|
</StarlightPage>
|
||||||
@ -147,7 +147,6 @@
|
|||||||
/* Magenta for feminine */
|
/* Magenta for feminine */
|
||||||
--sl-badge-tip-bg: #cc3366;
|
--sl-badge-tip-bg: #cc3366;
|
||||||
--sl-badge-tip-border: #bb3355;
|
--sl-badge-tip-border: #bb3355;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dark theme overrides */
|
/* Dark theme overrides */
|
||||||
@ -223,6 +222,10 @@ h6,
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
font-family: var(--font-sans);
|
font-family: var(--font-sans);
|
||||||
}
|
}
|
||||||
|
.tag-badge {
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
.word-entry {
|
.word-entry {
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
@ -278,10 +281,9 @@ mark {
|
|||||||
margin-top: 0 !important;
|
margin-top: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sl-container {
|
/* .sl-container {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
} */
|
||||||
|
|
||||||
|
|
||||||
/* =================================================================
|
/* =================================================================
|
||||||
LANGUAGE-SPECIFIC STYLES
|
LANGUAGE-SPECIFIC STYLES
|
||||||
|
|||||||
@ -15,7 +15,8 @@
|
|||||||
hindi: बात करना
|
hindi: बात करना
|
||||||
gender: f
|
gender: f
|
||||||
hindi: बात
|
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.
|
in, things that are discussed.
|
||||||
see_also:
|
see_also:
|
||||||
- "[चीज़](#चीज़)"
|
- "[चीज़](#चीज़)"
|
||||||
@ -28,7 +29,8 @@
|
|||||||
hindi: क्या आपकी मदद हुई है?
|
hindi: क्या आपकी मदद हुई है?
|
||||||
gender: f
|
gender: f
|
||||||
hindi: मदद
|
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
|
(to actively help someone), or होना (to passively be helped). See the
|
||||||
links below for the generalized rules of these.
|
links below for the generalized rules of these.
|
||||||
see_also:
|
see_also:
|
||||||
@ -43,6 +45,12 @@
|
|||||||
- english: etc.
|
- english: etc.
|
||||||
hindi: वग़ैरह
|
hindi: वग़ैरह
|
||||||
type: noun
|
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
|
- about: Hindi often uses repetition of words for emphasis or to indicate a
|
||||||
variety of related meanings.
|
variety of related meanings.
|
||||||
slug: repetition
|
slug: repetition
|
||||||
@ -100,7 +108,8 @@
|
|||||||
type: adjective
|
type: adjective
|
||||||
- english: Indian
|
- english: Indian
|
||||||
hindi: भारतीय, हिंदुस्तानी
|
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).
|
is Hindu](/culture/bharat-hindustan).
|
||||||
type: adjective
|
type: adjective
|
||||||
- english: Iranian
|
- english: Iranian
|
||||||
@ -198,7 +207,8 @@
|
|||||||
- english: jeweler
|
- english: jeweler
|
||||||
hindi: जौहरी
|
hindi: जौहरी
|
||||||
type: noun
|
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
|
of a favorite hotel ("The Johri") in Jaipur's Johri Bazaar (Jeweller's
|
||||||
Market).
|
Market).
|
||||||
- english: judge
|
- english: judge
|
||||||
@ -249,19 +259,21 @@
|
|||||||
- english: potter
|
- english: potter
|
||||||
hindi: कुम्हार
|
hindi: कुम्हार
|
||||||
type: noun
|
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.
|
fairly common in English.
|
||||||
- english: president
|
- english: president
|
||||||
hindi: राष्ट्रपति
|
hindi: राष्ट्रपति
|
||||||
type: noun
|
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
|
Would they change this if India ever had a female president? (Could
|
||||||
India ever?)'
|
India ever?)'
|
||||||
- english: prime minister
|
- english: prime minister
|
||||||
hindi: प्रधानमंत्री
|
hindi: प्रधानमंत्री
|
||||||
type: noun
|
type: noun
|
||||||
note: "As you'd hope: प्रधान means \"prime/head/chief\", मंत्री means
|
note: 'As you''d hope: प्रधान means "prime/head/chief", मंत्री means
|
||||||
\"minister.\""
|
"minister."'
|
||||||
- english: publisher
|
- english: publisher
|
||||||
hindi: प्रकाशक
|
hindi: प्रकाशक
|
||||||
type: noun
|
type: noun
|
||||||
@ -274,7 +286,8 @@
|
|||||||
- english: security guard
|
- english: security guard
|
||||||
hindi: सुरक्षा कर्मचारी
|
hindi: सुरक्षा कर्मचारी
|
||||||
type: noun
|
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."
|
"security", कर्मचारी just means "employee."
|
||||||
- english: shopkeeper
|
- english: shopkeeper
|
||||||
hindi: दुकानदार
|
hindi: दुकानदार
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user