From e839a5f61f0faa21ca8b4bd5767f7575d5e576ee Mon Sep 17 00:00:00 2001 From: polwex Date: Wed, 21 May 2025 14:00:28 +0700 Subject: the card flip animation is legit --- src/lib/types/cards.ts | 210 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 src/lib/types/cards.ts (limited to 'src/lib/types/cards.ts') diff --git a/src/lib/types/cards.ts b/src/lib/types/cards.ts new file mode 100644 index 0000000..0592a34 --- /dev/null +++ b/src/lib/types/cards.ts @@ -0,0 +1,210 @@ +// src/types.ts + +import { ReactNode } from "react"; + +// Language definition +export interface Language { + code: string; + name: string; + nativeName?: string; + supportsSource?: boolean; + supportsTarget?: boolean; + progress: number; + cardCount: number; +} + +// Translation service provider +export interface Provider { + id: string; + name: string; +} + +// Translation history item +export interface TranslationHistoryItem { + id: number; + text: string; + translation: string; + from: string; + to: string; + provider: string; + timestamp: number; +} + +// Response from translation API +export interface TranslationResponse { + translation: string; + source: string; + target: string; + provider: string; + characters: number; +} + +// Error response from API +export interface ErrorResponse { + error: string; + details?: any; +} + +// Props for components +export interface LanguageSelectorProps { + value: string; + onChange: (value: string) => void; + languages: Language[]; + showCharCount?: boolean; + charCount?: number; + showCopyButton?: boolean; + onCopy?: () => void; + setMore?: (t: { text: string; lang: string }) => void; + text?: string; + disabled?: boolean; +} + +export interface TextAreaProps { + value: string; + onChange: (value: string) => void; + lang?: string; + transliteration?: TransliterationOptions; + placeholder: string; + readOnly?: boolean; +} + +export interface ProviderSelectorProps { + value: string; + onChange: (value: string) => void; + providers: Provider[]; +} + +export interface TranslationHistoryProps { + items: TranslationHistoryItem[]; + languages: Language[]; + providers: Provider[]; +} + +export interface TransliterationOptions extends Language { + scripts: TransliterationLanguage[]; +} +export interface TransliterationLanguage extends Language { + toScripts: Language[]; +} + +export type Meaning = { + pos: string; // part of speech; + meaning: string[]; + etymology: string; + references?: any; +}; + +export type Prompts = { + translate: string; +}; +export type AnalyzeRes = { + word: string; + syllables: string[]; + ipa: string; + pos: POS; +}; +type POS = string; + +export type WordData = { + spelling: string; + lang: string; + ipa: string; + meanings: Meaning[]; + references?: any; +}; + +// app proper +// Mock data for the app +export type UserStats = { + streakDays: number; + cardsLearned: number; + minutesStudied: number; + dueToday: number; +}; +export type UserData = { + id: number; + name: string; + stats: UserStats; +}; +export type DeckResponse = { + lesson: { + name: string; + description: string; + language: string; + id: number; + cardCount: number; + }; + cards: CardResponse[]; +}; + +export interface SRSProgress { + repetitionCount: number; + easeFactor: number; + interval: number; + nextReviewDate: number; + lastReviewed: number; + isMastered: boolean; +} + +export interface ReviewResult { + cardId: number; + accuracy: number; + reviewTime: number; +} +export type CardResponse = { + id: number; + text: string; + note: string; + progress: SRSProgress; + expression: { + ipa: Array<{ ipa: string; tags: string[] }>; + spelling: string; + type: ExpressionType; + syllables: number; + confidence: number; + lang: string; + frequency: number; + prosody: any; + senses: Sense[]; + }; +}; +export type Sense = { + etymology: string; + pos: string; + forms: Array<{ form: string; tags: string[] }>; + related: any; + senses: Array<{ glosses: string[]; links: Array<[string, string]> }>; +}; + +export type SyllableProsody = { isLong: boolean; tone: number; lang: string }; + +export interface Deck { + id: number; + name: string; + description: string; + cardCount: number; + dueCards: number; + progress: number; + language: string; +} + +export interface Card { + id: number; + front: ReactNode; + back: ReactNode; + language: string; + difficulty: number; + nextReview: Date; + interval: number; + easeFactor: number; +} + +export type ExpressionType = "word" | "expression" | "syllable"; +export type ExpressionSearchParams = { + lang?: string; + spelling?: string; + pos?: string; + syllables?: { num: number; sign: string }; // ">" | "<" | "=" + frequency?: { num: number; above: boolean }; + type?: ExpressionType; +}; -- cgit v1.2.3