1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
// This is a Server Component
import React from "react";
import db from "@/lib/db";
import {
Card,
CardHeader,
CardDescription,
CardContent,
CardFooter,
CardTitle,
} from "@/components/ui/card";
import { NLP } from "sortug-ai";
import {
BookOpen,
Volume2,
Link as LinkIcon,
ChevronDown,
ChevronUp,
Search,
Info,
MessageSquareQuote,
Tags,
ListTree,
Lightbulb,
} from "lucide-react";
import {
Example,
SubSense,
RelatedEntry,
Sense,
WordData,
} from "@/zoom/logic/types";
import { isTonal } from "@/lib/lang/utils";
type WordProps = { text: string; lang: string };
export default async function (props: WordProps) {
const { text, lang } = props;
const data = db.fetchWordBySpelling(text, lang);
if (!data) return <p>oh...</p>;
console.log(data.senses[0]);
return (
<Card className="overflow-y-scroll max-h-[80vh]">
<CardHeader>
<CardTitle>
<h1 className="text-5xl">{text}</h1>
</CardTitle>
<CardDescription>
<IpaDisplay ipaEntries={data.ipa} />
</CardDescription>
</CardHeader>
<CardContent>
{isTonal(text) ? <Tones {...props} /> : <NotTones {...props} />}
</CardContent>
<CardFooter></CardFooter>
</Card>
);
// return (
// <div className="p-6">
// <h3 className="mb-2 text-2xl font-bold">{word}</h3>
// <p className="mb-1 text-xl text-green-600">${word.}</p>
// <p className="text-gray-700">{word}</p>
// <p className="mt-4 text-xs text-gray-500">
// Content rendered on the server at: {new Date().toLocaleTimeString()}
// </p>
// </div>
// );
}
// Helper component for IPA display
const IpaDisplay = ({
ipaEntries,
}: {
ipaEntries: Array<{ ipa: string; tags?: string[] }>;
}) => {
if (!ipaEntries || ipaEntries.length === 0) return null;
return (
<div className="flex items-center space-x-2 flex-wrap">
{ipaEntries.map((entry, index) => {
const tags = entry.tags ? entry.tags : [];
return (
<span key={index} className="text-lg text-blue-600 font-serif">
{entry.ipa}{" "}
{tags.length > 0 && (
<span className="text-xs text-gray-500">({tags.join(", ")})</span>
)}
</span>
);
})}
<button
className="p-1 text-blue-500 hover:text-blue-700 transition-colors"
title="Pronounce"
// onClick={() => {
// /* Pronunciation logic would be client-side or a server roundtrip for audio file. */ alert(
// "Pronunciation feature not implemented for server component.",
// );
// }}
>
<Volume2 size={20} />
</button>
</div>
);
};
function Tones({ text, lang }: WordProps) {
return <div></div>;
}
function NotTones({ text, lang }: WordProps) {
return <div></div>;
}
|