-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathWordStatsCard.jsx
More file actions
54 lines (49 loc) · 2.01 KB
/
WordStatsCard.jsx
File metadata and controls
54 lines (49 loc) · 2.01 KB
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
import { MdAdd } from "react-icons/md";
const WordStatsCard = ({ text, activeDraftId, setActiveDraftId, drafts, onAddDraft }) => {
const wordCount = text.trim().split(/\s+/).filter(Boolean).length;
const charCount = text.length;
return (
<div className="bg-card-light dark:bg-card-dark border border-border-light dark:border-border-dark shadow-md mt-8 py-3 px-4 w-full max-w-[1200px] transition-all duration-300">
<div className="flex items-center justify-between flex-wrap gap-3">
{/* Word & Character Count */}
<p className="text-2xl font-medium">
<span className="text-secondary-light dark:text-secondary-dark font-bold">
{wordCount}
</span>{" "}
words
<span className="text-secondary-light dark:text-secondary-dark font-bold">
{charCount}
</span>{" "}
characters
</p>
{/* Draft Buttons */}
<div className="flex items-center gap-2 flex-wrap">
{Object.keys(drafts).map(id => (
<div key={id} className="flex items-center gap-1">
<button
onClick={() => setActiveDraftId(id)}
className={`px-3 py-1 rounded text-sm font-medium transition ${
activeDraftId === id
? "bg-purple-600 text-white"
: "bg-gray-800 text-gray-300 hover:bg-gray-700"
}`}
>
Draft {id}
</button>
</div>
))}
{Object.keys(drafts).length < 5 && (
<button
onClick={onAddDraft}
className="flex items-center gap-1 px-3 py-1 rounded bg-green-600 text-white text-sm font-medium hover:bg-green-700 transition active:ring-2 active:ring-offset-1 active:ring-secondary-light dark:active:ring-secondary-dark"
>
<MdAdd size={16} />
Add Draft
</button>
)}
</div>
</div>
</div>
);
};
export default WordStatsCard;