Initial commit: React + Vite plant app with footer navigation
- Wiki page with 8 plant entries, search, and category/difficulty filters - Calendar page with monthly grid, task scheduling, and upcoming tasks - My Plants page with personal collection, health tracking, and add/edit/remove - Footer navigation with Wiki, Calendar, and My Plants tabs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,263 @@
|
||||
.cal-page {
|
||||
padding: 24px 20px 100px;
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.cal-header {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.cal-header h1 {
|
||||
margin: 0 0 6px;
|
||||
font-size: 28px;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
|
||||
.cal-header p {
|
||||
color: var(--text);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.cal-nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.cal-month-label {
|
||||
font-size: 17px;
|
||||
font-weight: 500;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
.cal-nav-btn {
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 6px 12px;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
color: var(--text-h);
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.cal-nav-btn:hover {
|
||||
background: var(--accent-bg);
|
||||
}
|
||||
|
||||
.cal-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
gap: 4px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.cal-day-name {
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
padding: 4px 0 6px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
|
||||
.cal-day {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 6px 2px 4px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
transition: background 0.15s, border-color 0.15s;
|
||||
min-height: 44px;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.cal-day:hover {
|
||||
background: var(--accent-bg);
|
||||
}
|
||||
|
||||
.cal-day.today .cal-day-num {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.cal-day.selected {
|
||||
border-color: var(--accent-border);
|
||||
background: var(--accent-bg);
|
||||
}
|
||||
|
||||
.cal-day-num {
|
||||
font-size: 13px;
|
||||
color: var(--text-h);
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.cal-dots {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.cal-dot {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.dot-water { background: #3b82f6; }
|
||||
.dot-fertilize { background: #22c55e; }
|
||||
.dot-repot { background: #a855f7; }
|
||||
.dot-prune { background: #f59e0b; }
|
||||
.cal-dot.done { opacity: 0.3; }
|
||||
|
||||
.cal-selected-tasks,
|
||||
.cal-upcoming {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.cal-selected-tasks h2,
|
||||
.cal-upcoming h2 {
|
||||
font-size: 17px;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.cal-empty {
|
||||
color: var(--text);
|
||||
font-size: 14px;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.task-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0 0 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.task-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
font-size: 14px;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
.task-item.done {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.task-item.done .task-label {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.task-check {
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
color: var(--accent);
|
||||
padding: 0;
|
||||
width: 20px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.task-icon {
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.task-label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.task-date {
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.task-remove {
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
color: var(--text);
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
flex-shrink: 0;
|
||||
transition: color 0.15s;
|
||||
}
|
||||
|
||||
.task-remove:hover {
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
.add-task-form {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.task-type-select {
|
||||
padding: 8px 10px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg);
|
||||
color: var(--text-h);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.task-input {
|
||||
flex: 1;
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg);
|
||||
color: var(--text-h);
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.task-input:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.task-add-btn {
|
||||
padding: 8px 16px;
|
||||
border-radius: 8px;
|
||||
border: none;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
|
||||
.task-add-btn:hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
import { useState } from 'react'
|
||||
import './Calendar.css'
|
||||
|
||||
const MONTHS = [
|
||||
'January','February','March','April','May','June',
|
||||
'July','August','September','October','November','December',
|
||||
]
|
||||
const DAYS = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
|
||||
|
||||
const today = new Date()
|
||||
|
||||
const initialTasks = [
|
||||
{ id: 1, date: fmt(today), type: 'water', label: 'Water Monstera' },
|
||||
{ id: 2, date: fmt(addDays(today, 1)), type: 'water', label: 'Water Pothos' },
|
||||
{ id: 3, date: fmt(addDays(today, 2)), type: 'fertilize', label: 'Fertilize Snake Plant' },
|
||||
{ id: 4, date: fmt(addDays(today, 3)), type: 'water', label: 'Water Peace Lily' },
|
||||
{ id: 5, date: fmt(addDays(today, 5)), type: 'repot', label: 'Repot Fiddle Leaf Fig' },
|
||||
{ id: 6, date: fmt(addDays(today, 7)), type: 'water', label: 'Water Echeveria' },
|
||||
{ id: 7, date: fmt(addDays(today, 10)), type: 'prune', label: 'Prune Basil' },
|
||||
{ id: 8, date: fmt(addDays(today, 14)), type: 'fertilize', label: 'Fertilize Monstera' },
|
||||
]
|
||||
|
||||
function fmt(d) {
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
function addDays(d, n) {
|
||||
const r = new Date(d)
|
||||
r.setDate(r.getDate() + n)
|
||||
return r
|
||||
}
|
||||
|
||||
function getDaysInMonth(year, month) {
|
||||
return new Date(year, month + 1, 0).getDate()
|
||||
}
|
||||
|
||||
function getFirstDay(year, month) {
|
||||
return new Date(year, month, 1).getDay()
|
||||
}
|
||||
|
||||
const typeIcon = { water: '💧', fertilize: '🌿', repot: '🪴', prune: '✂️' }
|
||||
const typeLabel = { water: 'Water', fertilize: 'Fertilize', repot: 'Repot', prune: 'Prune' }
|
||||
|
||||
export default function Calendar() {
|
||||
const [year, setYear] = useState(today.getFullYear())
|
||||
const [month, setMonth] = useState(today.getMonth())
|
||||
const [tasks, setTasks] = useState(initialTasks)
|
||||
const [selected, setSelected] = useState(fmt(today))
|
||||
const [newLabel, setNewLabel] = useState('')
|
||||
const [newType, setNewType] = useState('water')
|
||||
const [nextId, setNextId] = useState(initialTasks.length + 1)
|
||||
|
||||
const daysInMonth = getDaysInMonth(year, month)
|
||||
const firstDay = getFirstDay(year, month)
|
||||
|
||||
function prevMonth() {
|
||||
if (month === 0) { setMonth(11); setYear(y => y - 1) }
|
||||
else setMonth(m => m - 1)
|
||||
}
|
||||
|
||||
function nextMonth() {
|
||||
if (month === 11) { setMonth(0); setYear(y => y + 1) }
|
||||
else setMonth(m => m + 1)
|
||||
}
|
||||
|
||||
function addTask(e) {
|
||||
e.preventDefault()
|
||||
if (!newLabel.trim()) return
|
||||
setTasks(prev => [...prev, { id: nextId, date: selected, type: newType, label: newLabel.trim() }])
|
||||
setNextId(n => n + 1)
|
||||
setNewLabel('')
|
||||
}
|
||||
|
||||
function removeTask(id) {
|
||||
setTasks(prev => prev.filter(t => t.id !== id))
|
||||
}
|
||||
|
||||
function toggleDone(id) {
|
||||
setTasks(prev => prev.map(t => t.id === id ? { ...t, done: !t.done } : t))
|
||||
}
|
||||
|
||||
const tasksForDay = (dateStr) => tasks.filter(t => t.date === dateStr)
|
||||
const selectedTasks = tasksForDay(selected)
|
||||
|
||||
const todayStr = fmt(today)
|
||||
const upcoming = tasks
|
||||
.filter(t => t.date >= todayStr && !t.done)
|
||||
.sort((a, b) => a.date.localeCompare(b.date))
|
||||
.slice(0, 5)
|
||||
|
||||
return (
|
||||
<div className="cal-page">
|
||||
<div className="cal-header">
|
||||
<h1>Care Calendar</h1>
|
||||
<p>Schedule and track your plant care tasks</p>
|
||||
</div>
|
||||
|
||||
<div className="cal-nav">
|
||||
<button className="cal-nav-btn" onClick={prevMonth}>‹</button>
|
||||
<span className="cal-month-label">{MONTHS[month]} {year}</span>
|
||||
<button className="cal-nav-btn" onClick={nextMonth}>›</button>
|
||||
</div>
|
||||
|
||||
<div className="cal-grid">
|
||||
{DAYS.map(d => <div key={d} className="cal-day-name">{d}</div>)}
|
||||
{Array.from({ length: firstDay }).map((_, i) => <div key={`empty-${i}`} />)}
|
||||
{Array.from({ length: daysInMonth }).map((_, i) => {
|
||||
const day = i + 1
|
||||
const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`
|
||||
const dayTasks = tasksForDay(dateStr)
|
||||
const isToday = dateStr === todayStr
|
||||
const isSelected = dateStr === selected
|
||||
return (
|
||||
<button
|
||||
key={day}
|
||||
className={`cal-day ${isToday ? 'today' : ''} ${isSelected ? 'selected' : ''}`}
|
||||
onClick={() => setSelected(dateStr)}
|
||||
>
|
||||
<span className="cal-day-num">{day}</span>
|
||||
{dayTasks.length > 0 && (
|
||||
<span className="cal-dots">
|
||||
{dayTasks.slice(0, 3).map(t => (
|
||||
<span key={t.id} className={`cal-dot dot-${t.type} ${t.done ? 'done' : ''}`} />
|
||||
))}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="cal-selected-tasks">
|
||||
<h2>
|
||||
{selected === todayStr ? 'Today' : selected} tasks
|
||||
</h2>
|
||||
{selectedTasks.length === 0 && (
|
||||
<p className="cal-empty">No tasks — add one below.</p>
|
||||
)}
|
||||
<ul className="task-list">
|
||||
{selectedTasks.map(t => (
|
||||
<li key={t.id} className={`task-item ${t.done ? 'done' : ''}`}>
|
||||
<button className="task-check" onClick={() => toggleDone(t.id)}>
|
||||
{t.done ? '✓' : '○'}
|
||||
</button>
|
||||
<span className="task-icon">{typeIcon[t.type]}</span>
|
||||
<span className="task-label">{t.label}</span>
|
||||
<button className="task-remove" onClick={() => removeTask(t.id)} aria-label="Remove">×</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
<form className="add-task-form" onSubmit={addTask}>
|
||||
<select
|
||||
className="task-type-select"
|
||||
value={newType}
|
||||
onChange={e => setNewType(e.target.value)}
|
||||
>
|
||||
{Object.entries(typeLabel).map(([val, lbl]) => (
|
||||
<option key={val} value={val}>{typeIcon[val]} {lbl}</option>
|
||||
))}
|
||||
</select>
|
||||
<input
|
||||
className="task-input"
|
||||
type="text"
|
||||
placeholder="Add task…"
|
||||
value={newLabel}
|
||||
onChange={e => setNewLabel(e.target.value)}
|
||||
/>
|
||||
<button className="task-add-btn" type="submit">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div className="cal-upcoming">
|
||||
<h2>Upcoming</h2>
|
||||
{upcoming.length === 0 ? (
|
||||
<p className="cal-empty">All caught up!</p>
|
||||
) : (
|
||||
<ul className="task-list">
|
||||
{upcoming.map(t => (
|
||||
<li key={t.id} className="task-item">
|
||||
<span className="task-icon">{typeIcon[t.type]}</span>
|
||||
<span className="task-label">{t.label}</span>
|
||||
<span className="task-date">{t.date}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
.myplants {
|
||||
padding: 24px 20px 100px;
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.myplants-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.myplants-header h1 {
|
||||
margin: 0 0 6px;
|
||||
font-size: 28px;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
|
||||
.myplants-header p {
|
||||
color: var(--text);
|
||||
font-size: 15px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.add-plant-btn {
|
||||
padding: 9px 16px;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
|
||||
.add-plant-btn:hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.plants-empty {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.empty-emoji {
|
||||
font-size: 48px;
|
||||
display: block;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.plants-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.plant-card {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.plant-card-header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
color: var(--text-h);
|
||||
font-size: 15px;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.plant-card-header:hover {
|
||||
background: var(--accent-bg);
|
||||
}
|
||||
|
||||
.plant-emoji {
|
||||
font-size: 24px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.plant-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.plant-species {
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.health-badge {
|
||||
font-size: 12px;
|
||||
padding: 3px 9px;
|
||||
border-radius: 999px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.health-thriving { background: #d1fae5; color: #065f46; }
|
||||
.health-good { background: #dbeafe; color: #1e40af; }
|
||||
.health-needs-care { background: #fef9c3; color: #854d0e; }
|
||||
.health-critical { background: #fee2e2; color: #991b1b; }
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.health-thriving { background: rgba(6,95,70,0.3); color: #6ee7b7; }
|
||||
.health-good { background: rgba(30,64,175,0.3); color: #93c5fd; }
|
||||
.health-needs-care { background: rgba(133,77,14,0.3); color: #fde68a; }
|
||||
.health-critical { background: rgba(153,27,27,0.3); color: #fca5a5; }
|
||||
}
|
||||
|
||||
.plant-chevron {
|
||||
font-size: 11px;
|
||||
color: var(--text);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.plant-card-body {
|
||||
padding: 12px 16px 16px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.plant-meta {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
flex: 1;
|
||||
background: var(--code-bg);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.meta-label {
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.meta-value {
|
||||
font-size: 14px;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
.plant-notes {
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
line-height: 1.5;
|
||||
margin: 0 0 12px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.plant-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
padding: 7px 14px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
background: transparent;
|
||||
color: var(--text-h);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, border-color 0.15s;
|
||||
}
|
||||
|
||||
.action-btn:hover {
|
||||
background: var(--accent-bg);
|
||||
border-color: var(--accent-border);
|
||||
}
|
||||
|
||||
.water-btn {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.water-btn:hover {
|
||||
opacity: 0.85;
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.remove-btn:hover {
|
||||
background: #fee2e2;
|
||||
border-color: #fca5a5;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.remove-btn:hover {
|
||||
background: rgba(153,27,27,0.3);
|
||||
border-color: #fca5a5;
|
||||
color: #fca5a5;
|
||||
}
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0,0,0,0.4);
|
||||
z-index: 100;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.modal {
|
||||
background: var(--bg);
|
||||
border-radius: 20px 20px 0 0;
|
||||
padding: 24px 20px 40px;
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
max-height: 90svh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal h2 {
|
||||
margin: 0 0 20px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.plant-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.plant-form label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
|
||||
.plant-form input,
|
||||
.plant-form select,
|
||||
.plant-form textarea {
|
||||
padding: 9px 12px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg);
|
||||
color: var(--text-h);
|
||||
font-size: 15px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.plant-form input:focus,
|
||||
.plant-form select:focus,
|
||||
.plant-form textarea:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 4px;
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
import { useState } from 'react'
|
||||
import './MyPlants.css'
|
||||
|
||||
const healthOptions = ['Thriving', 'Good', 'Needs care', 'Critical']
|
||||
const locationOptions = ['Living room', 'Bedroom', 'Kitchen', 'Bathroom', 'Office', 'Balcony', 'Other']
|
||||
|
||||
const initialPlants = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Monstera',
|
||||
species: 'Monstera deliciosa',
|
||||
emoji: '🌿',
|
||||
location: 'Living room',
|
||||
health: 'Thriving',
|
||||
lastWatered: '2026-04-11',
|
||||
notes: 'New leaf unfurling — so excited!',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Snakey',
|
||||
species: 'Sansevieria trifasciata',
|
||||
emoji: '🐍',
|
||||
location: 'Bedroom',
|
||||
health: 'Good',
|
||||
lastWatered: '2026-04-01',
|
||||
notes: 'Barely needs water. Rock solid.',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Basil bunch',
|
||||
species: 'Ocimum basilicum',
|
||||
emoji: '🌱',
|
||||
location: 'Kitchen',
|
||||
health: 'Needs care',
|
||||
lastWatered: '2026-04-12',
|
||||
notes: 'Getting a bit leggy, needs pruning.',
|
||||
},
|
||||
]
|
||||
|
||||
const healthColor = {
|
||||
Thriving: 'health-thriving',
|
||||
Good: 'health-good',
|
||||
'Needs care': 'health-needs-care',
|
||||
Critical: 'health-critical',
|
||||
}
|
||||
|
||||
function fmt(d) {
|
||||
const date = new Date(d)
|
||||
return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' })
|
||||
}
|
||||
|
||||
export default function MyPlants() {
|
||||
const [plants, setPlants] = useState(initialPlants)
|
||||
const [nextId, setNextId] = useState(initialPlants.length + 1)
|
||||
const [showForm, setShowForm] = useState(false)
|
||||
const [editId, setEditId] = useState(null)
|
||||
const [expanded, setExpanded] = useState(null)
|
||||
const [form, setForm] = useState({
|
||||
name: '', species: '', emoji: '🪴', location: 'Living room',
|
||||
health: 'Good', lastWatered: '', notes: '',
|
||||
})
|
||||
|
||||
function openAdd() {
|
||||
setForm({ name: '', species: '', emoji: '🪴', location: 'Living room', health: 'Good', lastWatered: '', notes: '' })
|
||||
setEditId(null)
|
||||
setShowForm(true)
|
||||
}
|
||||
|
||||
function openEdit(plant) {
|
||||
setForm({ ...plant })
|
||||
setEditId(plant.id)
|
||||
setShowForm(true)
|
||||
}
|
||||
|
||||
function handleSubmit(e) {
|
||||
e.preventDefault()
|
||||
if (!form.name.trim()) return
|
||||
if (editId !== null) {
|
||||
setPlants(prev => prev.map(p => p.id === editId ? { ...form, id: editId } : p))
|
||||
} else {
|
||||
setPlants(prev => [...prev, { ...form, id: nextId }])
|
||||
setNextId(n => n + 1)
|
||||
}
|
||||
setShowForm(false)
|
||||
setEditId(null)
|
||||
}
|
||||
|
||||
function removePlant(id) {
|
||||
setPlants(prev => prev.filter(p => p.id !== id))
|
||||
if (expanded === id) setExpanded(null)
|
||||
}
|
||||
|
||||
function waterNow(id) {
|
||||
const today = new Date().toISOString().split('T')[0]
|
||||
setPlants(prev => prev.map(p => p.id === id ? { ...p, lastWatered: today, health: p.health === 'Critical' ? 'Needs care' : p.health } : p))
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="myplants">
|
||||
<div className="myplants-header">
|
||||
<div>
|
||||
<h1>My Plants</h1>
|
||||
<p>{plants.length} plant{plants.length !== 1 ? 's' : ''} in your collection</p>
|
||||
</div>
|
||||
<button className="add-plant-btn" onClick={openAdd}>+ Add plant</button>
|
||||
</div>
|
||||
|
||||
{plants.length === 0 && (
|
||||
<div className="plants-empty">
|
||||
<span className="empty-emoji">🌱</span>
|
||||
<p>Your collection is empty. Add your first plant!</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<ul className="plants-list">
|
||||
{plants.map(plant => (
|
||||
<li key={plant.id} className="plant-card">
|
||||
<button
|
||||
className="plant-card-header"
|
||||
onClick={() => setExpanded(expanded === plant.id ? null : plant.id)}
|
||||
aria-expanded={expanded === plant.id}
|
||||
>
|
||||
<span className="plant-emoji">{plant.emoji}</span>
|
||||
<div className="plant-info">
|
||||
<strong>{plant.name}</strong>
|
||||
<span className="plant-species">{plant.species}</span>
|
||||
</div>
|
||||
<span className={`health-badge ${healthColor[plant.health]}`}>{plant.health}</span>
|
||||
<span className="plant-chevron">{expanded === plant.id ? '▲' : '▼'}</span>
|
||||
</button>
|
||||
|
||||
{expanded === plant.id && (
|
||||
<div className="plant-card-body">
|
||||
<div className="plant-meta">
|
||||
<div className="meta-item">
|
||||
<span className="meta-label">Location</span>
|
||||
<span className="meta-value">📍 {plant.location}</span>
|
||||
</div>
|
||||
<div className="meta-item">
|
||||
<span className="meta-label">Last watered</span>
|
||||
<span className="meta-value">💧 {plant.lastWatered ? fmt(plant.lastWatered) : '—'}</span>
|
||||
</div>
|
||||
</div>
|
||||
{plant.notes && (
|
||||
<p className="plant-notes">{plant.notes}</p>
|
||||
)}
|
||||
<div className="plant-actions">
|
||||
<button className="action-btn water-btn" onClick={() => waterNow(plant.id)}>
|
||||
💧 Water now
|
||||
</button>
|
||||
<button className="action-btn edit-btn" onClick={() => openEdit(plant)}>
|
||||
Edit
|
||||
</button>
|
||||
<button className="action-btn remove-btn" onClick={() => removePlant(plant.id)}>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
{showForm && (
|
||||
<div className="modal-overlay" onClick={() => setShowForm(false)}>
|
||||
<div className="modal" onClick={e => e.stopPropagation()}>
|
||||
<h2>{editId !== null ? 'Edit plant' : 'Add plant'}</h2>
|
||||
<form onSubmit={handleSubmit} className="plant-form">
|
||||
<label>
|
||||
Emoji
|
||||
<input
|
||||
type="text"
|
||||
value={form.emoji}
|
||||
onChange={e => setForm(f => ({ ...f, emoji: e.target.value }))}
|
||||
maxLength={2}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Name *
|
||||
<input
|
||||
type="text"
|
||||
value={form.name}
|
||||
onChange={e => setForm(f => ({ ...f, name: e.target.value }))}
|
||||
placeholder="e.g. My Monstera"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Species
|
||||
<input
|
||||
type="text"
|
||||
value={form.species}
|
||||
onChange={e => setForm(f => ({ ...f, species: e.target.value }))}
|
||||
placeholder="e.g. Monstera deliciosa"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Location
|
||||
<select value={form.location} onChange={e => setForm(f => ({ ...f, location: e.target.value }))}>
|
||||
{locationOptions.map(l => <option key={l}>{l}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Health
|
||||
<select value={form.health} onChange={e => setForm(f => ({ ...f, health: e.target.value }))}>
|
||||
{healthOptions.map(h => <option key={h}>{h}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Last watered
|
||||
<input
|
||||
type="date"
|
||||
value={form.lastWatered}
|
||||
onChange={e => setForm(f => ({ ...f, lastWatered: e.target.value }))}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Notes
|
||||
<textarea
|
||||
value={form.notes}
|
||||
onChange={e => setForm(f => ({ ...f, notes: e.target.value }))}
|
||||
placeholder="Observations, reminders…"
|
||||
rows={3}
|
||||
/>
|
||||
</label>
|
||||
<div className="form-actions">
|
||||
<button type="button" className="action-btn" onClick={() => setShowForm(false)}>Cancel</button>
|
||||
<button type="submit" className="action-btn water-btn">{editId !== null ? 'Save' : 'Add'}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
.wiki {
|
||||
padding: 24px 20px 100px;
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.wiki-header {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.wiki-header h1 {
|
||||
margin: 0 0 6px;
|
||||
font-size: 28px;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
|
||||
.wiki-header p {
|
||||
color: var(--text);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.wiki-filters {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wiki-search {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 10px 14px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--bg);
|
||||
color: var(--text-h);
|
||||
font-size: 15px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.wiki-search:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.filter-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.chip {
|
||||
padding: 5px 12px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--border);
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.chip:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.chip.active {
|
||||
background: var(--accent-bg);
|
||||
border-color: var(--accent-border);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.wiki-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.wiki-card {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wiki-card-header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
color: var(--text-h);
|
||||
font-size: 15px;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.wiki-card-header:hover {
|
||||
background: var(--accent-bg);
|
||||
}
|
||||
|
||||
.wiki-emoji {
|
||||
font-size: 22px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wiki-card-title {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.wiki-category {
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.difficulty {
|
||||
font-size: 12px;
|
||||
padding: 3px 8px;
|
||||
border-radius: 999px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.diff-very-easy { background: #d1fae5; color: #065f46; }
|
||||
.diff-easy { background: #dcfce7; color: #166534; }
|
||||
.diff-moderate { background: #fef9c3; color: #854d0e; }
|
||||
.diff-hard { background: #fee2e2; color: #991b1b; }
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.diff-very-easy { background: rgba(6,95,70,0.3); color: #6ee7b7; }
|
||||
.diff-easy { background: rgba(22,101,52,0.3); color: #86efac; }
|
||||
.diff-moderate { background: rgba(133,77,14,0.3); color: #fde68a; }
|
||||
.diff-hard { background: rgba(153,27,27,0.3); color: #fca5a5; }
|
||||
}
|
||||
|
||||
.wiki-chevron {
|
||||
font-size: 11px;
|
||||
color: var(--text);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.wiki-card-body {
|
||||
padding: 0 16px 16px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.wiki-description {
|
||||
margin: 12px 0;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.wiki-stats {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.stat {
|
||||
flex: 1;
|
||||
background: var(--code-bg);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 14px;
|
||||
color: var(--text-h);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.wiki-empty {
|
||||
text-align: center;
|
||||
color: var(--text);
|
||||
margin-top: 48px;
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
const plants = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Monstera Deliciosa',
|
||||
category: 'Tropical',
|
||||
light: 'Bright indirect',
|
||||
water: 'Every 1–2 weeks',
|
||||
difficulty: 'Easy',
|
||||
description:
|
||||
'Known for its iconic split leaves, Monstera is a fast-growing tropical plant that thrives in warm, humid conditions. Perfect for adding a jungle vibe to any room.',
|
||||
emoji: '🌿',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Echeveria',
|
||||
category: 'Succulent',
|
||||
light: 'Full sun',
|
||||
water: 'Every 2–3 weeks',
|
||||
difficulty: 'Easy',
|
||||
description:
|
||||
'A rosette-forming succulent with thick, fleshy leaves. Extremely drought-tolerant and thrives on neglect. Ideal for beginners and sunny windowsills.',
|
||||
emoji: '🪴',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Peace Lily',
|
||||
category: 'Tropical',
|
||||
light: 'Low to medium',
|
||||
water: 'Weekly',
|
||||
difficulty: 'Easy',
|
||||
description:
|
||||
'One of the few flowering plants that tolerates low light. Peace Lily also acts as an air purifier, removing toxins from indoor air.',
|
||||
emoji: '🌸',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'Basil',
|
||||
category: 'Herb',
|
||||
light: 'Full sun',
|
||||
water: 'Every 2–3 days',
|
||||
difficulty: 'Moderate',
|
||||
description:
|
||||
'A culinary staple with fragrant leaves. Basil loves warmth and direct sunlight. Pinch flowers to keep leaves coming. Best grown on a kitchen windowsill.',
|
||||
emoji: '🌱',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'Snake Plant',
|
||||
category: 'Succulent',
|
||||
light: 'Low to bright indirect',
|
||||
water: 'Every 2–6 weeks',
|
||||
difficulty: 'Very easy',
|
||||
description:
|
||||
'Nearly indestructible, the Snake Plant tolerates neglect, low light, and irregular watering. Its upright leaves add architectural interest to any space.',
|
||||
emoji: '🐍',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'Fiddle Leaf Fig',
|
||||
category: 'Tropical',
|
||||
light: 'Bright indirect',
|
||||
water: 'Weekly',
|
||||
difficulty: 'Hard',
|
||||
description:
|
||||
'A dramatic statement plant with large, violin-shaped leaves. Fiddle Leaf Figs are sensitive to drafts and overwatering, but reward patience with stunning growth.',
|
||||
emoji: '🎻',
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'Lavender',
|
||||
category: 'Herb',
|
||||
light: 'Full sun',
|
||||
water: 'Every 1–2 weeks',
|
||||
difficulty: 'Moderate',
|
||||
description:
|
||||
'Fragrant and calming, lavender thrives in sunny spots with well-drained soil. Great for borders, pots, and drying for sachets.',
|
||||
emoji: '💜',
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: 'Pothos',
|
||||
category: 'Tropical',
|
||||
light: 'Low to bright indirect',
|
||||
water: 'Every 1–2 weeks',
|
||||
difficulty: 'Very easy',
|
||||
description:
|
||||
'A trailing vine that can grow in almost any condition. Pothos is perfect for shelves and hanging baskets, and propagates effortlessly in water.',
|
||||
emoji: '🍃',
|
||||
},
|
||||
]
|
||||
|
||||
const categories = ['All', 'Tropical', 'Succulent', 'Herb']
|
||||
const difficulties = ['All', 'Very easy', 'Easy', 'Moderate', 'Hard']
|
||||
|
||||
import { useState } from 'react'
|
||||
import './Wiki.css'
|
||||
|
||||
export default function Wiki() {
|
||||
const [search, setSearch] = useState('')
|
||||
const [category, setCategory] = useState('All')
|
||||
const [difficulty, setDifficulty] = useState('All')
|
||||
const [expanded, setExpanded] = useState(null)
|
||||
|
||||
const filtered = plants.filter((p) => {
|
||||
const matchesSearch = p.name.toLowerCase().includes(search.toLowerCase())
|
||||
const matchesCategory = category === 'All' || p.category === category
|
||||
const matchesDifficulty = difficulty === 'All' || p.difficulty === difficulty
|
||||
return matchesSearch && matchesCategory && matchesDifficulty
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="wiki">
|
||||
<div className="wiki-header">
|
||||
<h1>Plant Wiki</h1>
|
||||
<p>Care guides for popular houseplants and herbs</p>
|
||||
</div>
|
||||
|
||||
<div className="wiki-filters">
|
||||
<input
|
||||
className="wiki-search"
|
||||
type="search"
|
||||
placeholder="Search plants…"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
<div className="filter-chips">
|
||||
{categories.map((c) => (
|
||||
<button
|
||||
key={c}
|
||||
className={`chip ${category === c ? 'active' : ''}`}
|
||||
onClick={() => setCategory(c)}
|
||||
>
|
||||
{c}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="filter-chips">
|
||||
{difficulties.map((d) => (
|
||||
<button
|
||||
key={d}
|
||||
className={`chip ${difficulty === d ? 'active' : ''}`}
|
||||
onClick={() => setDifficulty(d)}
|
||||
>
|
||||
{d}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{filtered.length === 0 ? (
|
||||
<p className="wiki-empty">No plants match your filters.</p>
|
||||
) : (
|
||||
<ul className="wiki-list">
|
||||
{filtered.map((plant) => (
|
||||
<li key={plant.id} className="wiki-card">
|
||||
<button
|
||||
className="wiki-card-header"
|
||||
onClick={() => setExpanded(expanded === plant.id ? null : plant.id)}
|
||||
aria-expanded={expanded === plant.id}
|
||||
>
|
||||
<span className="wiki-emoji">{plant.emoji}</span>
|
||||
<div className="wiki-card-title">
|
||||
<strong>{plant.name}</strong>
|
||||
<span className="wiki-category">{plant.category}</span>
|
||||
</div>
|
||||
<span className={`difficulty diff-${plant.difficulty.replace(' ', '-').toLowerCase()}`}>
|
||||
{plant.difficulty}
|
||||
</span>
|
||||
<span className="wiki-chevron">{expanded === plant.id ? '▲' : '▼'}</span>
|
||||
</button>
|
||||
|
||||
{expanded === plant.id && (
|
||||
<div className="wiki-card-body">
|
||||
<p className="wiki-description">{plant.description}</p>
|
||||
<div className="wiki-stats">
|
||||
<div className="stat">
|
||||
<span className="stat-label">Light</span>
|
||||
<span className="stat-value">{plant.light}</span>
|
||||
</div>
|
||||
<div className="stat">
|
||||
<span className="stat-label">Watering</span>
|
||||
<span className="stat-value">{plant.water}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user