bullet-journal-app.tsx
bullet-journal-app.tsx
return (
<div className="p-4 bg-white rounded-lg shadow-md">
<h2 className="text-xl font-bold mb-4 flex items-center">
<Smile className="mr-2 text-purple-500" /> Mood Tracker
</h2>
<div className="flex justify-between">
{moods.map((mood) => (
<button
key={mood.label}
onClick={() => setSelectedMood(mood)}
className={`text-4xl p-2 rounded-full transition-all ${
selectedMood?.label === mood.label
? 'bg-purple-100 scale-110'
: 'hover:bg-purple-50'
}`}
>
{mood.emoji}
</button>
))}
</div>
{selectedMood && (
<p className="mt-4 text-center">
Today you feel: {selectedMood.label}
</p>
)}
</div>
);
};
// Diary Component
const Diary = () => {
const [entry, setEntry] = useState('');
const [entries, setEntries] = useState([]);
return (
<div className="p-4 bg-white rounded-lg shadow-md">
<h2 className="text-xl font-bold mb-4 flex items-center">
<Book className="mr-2 text-blue-500" /> Diary
</h2>
<textarea
value={entry}
onChange={(e) => setEntry(e.target.value)}
placeholder="Write your thoughts..."
className="w-full h-32 border p-2 rounded mb-4"
/>
<button
onClick={addEntry}
className="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600"
>
Save Entry
</button>
<div className="mt-4 max-h-48 overflow-y-auto">
{entries.map((entry, index) => (
<div key={index} className="border-b py-2">
<p className="text-sm text-gray-500">{entry.date}</p>
<p>{entry.text}</p>
</div>
))}
</div>
</div>
);
};
return (
<div className="p-4 bg-white rounded-lg shadow-md">
<h2 className="text-xl font-bold mb-4 flex items-center">
<DollarSign className="mr-2 text-green-600" /> Money Tracker
</h2>
<div className="grid grid-cols-2 gap-2 mb-4">
<select
value={type}
onChange={(e) => setType(e.target.value)}
className="border p-2 rounded"
>
<option value="expense">Expense</option>
<option value="income">Income</option>
</select>
<input
type="number"
value={amount}
onChange={(e) => setAmount(e.target.value)}
placeholder="Amount"
className="border p-2 rounded"
/>
<input
value={category}
onChange={(e) => setCategory(e.target.value)}
placeholder="Category"
className="border p-2 rounded col-span-2"
/>
<button
onClick={addTransaction}
className="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600
col-span-2"
>
Add Transaction
</button>
</div>
<div>
<h3 className="font-bold">Total Balance:
${calculateTotal().toFixed(2)}</h3>
<div className="max-h-48 overflow-y-auto">
{transactions.map((transaction, index) => (
<div
key={index}
className={`border-b py-2 ${
transaction.type === 'income' ? 'text-green-600' : 'text-red-600'
}`}
>
<p>{transaction.date} - {transaction.category}: $
{transaction.amount}</p>
</div>
))}
</div>
</div>
</div>
);
};
return (
<div className="p-4 bg-white rounded-lg shadow-md">
<h2 className="text-xl font-bold mb-4 flex items-center">
<Calendar className="mr-2 text-orange-500" /> Weekly Overview
</h2>
{tasks.map((dayObj) => (
<div key={dayObj.day} className="mb-4">
<h3 className="font-semibold">{dayObj.day}</h3>
<div className="flex mb-2">
<input
placeholder="Add task"
onKeyPress={(e) => {
if (e.key === 'Enter' && e.target.value.trim()) {
addTask(dayObj.day, e.target.value.trim());
e.target.value = '';
}
}}
className="border p-1 rounded flex-grow mr-2"
/>
</div>
{dayObj.tasks.map((task, index) => (
<div key={index} className="flex items-center">
<input
type="checkbox"
className="mr-2"
/>
<span>{task}</span>
</div>
))}
</div>
))}
</div>
);
};