Skip to content

Commit

Permalink
feat: Update MealEntryComponent to use form element for better access…
Browse files Browse the repository at this point in the history
…ibility and maintainability
  • Loading branch information
timia2109 committed Aug 2, 2024
1 parent 01c2a2e commit d549de3
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/components/mealPlan/MealEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export const MealEntryComponent: React.FC<MealEntryProps> = ({
};

return (
<div
<form
action={updateMealEntry}
ref={formRef}
onClick={onClick}
className={classNames({
"box-border h-[30vh] w-full cursor-text border bg-base-100 p-1 transition md:h-32":
Expand All @@ -63,33 +65,31 @@ export const MealEntryComponent: React.FC<MealEntryProps> = ({
"text-neutral-400": !isCurrentMonth,
})}
>
<form action={updateMealEntry} ref={formRef} className="h-100">
<input type="hidden" name="date" value={dateTime.toSQLDate()!} />
<input type="hidden" name="mealPlanId" value={mealPlanId} />
<input type="hidden" name="date" value={dateTime.toSQLDate()!} />
<input type="hidden" name="mealPlanId" value={mealPlanId} />

<div className="flex justify-between">
<div className="overflow-hidden text-xs font-extrabold lg:text-lg">
{dateTime.weekdayShort} {dateTime.day}
</div>
<div className="h-full w-5">
{isToday && <FontAwesomeIcon icon={faCalendar} />}
</div>
<div className="flex justify-between">
<div className="overflow-hidden text-xs font-extrabold lg:text-lg">
{dateTime.weekdayShort} {dateTime.day}
</div>
<div className="h-full w-5">
{isToday && <FontAwesomeIcon icon={faCalendar} />}
</div>
</div>

<textarea
defaultValue={entry?.meal}
ref={textFieldRef}
onFocus={() => setHasFocus(true)}
name="meal"
onBlur={onBlur}
className={classNames({
"h-100 w-full flex-grow resize-none overflow-hidden break-words bg-transparent text-start text-xs focus:border-none focus:outline-none lg:text-base":
true,
"text-base-content": isCurrentMonth,
"text-neutral-400": !isCurrentMonth,
})}
/>
</form>
</div>
<textarea
defaultValue={entry?.meal}
ref={textFieldRef}
onFocus={() => setHasFocus(true)}
name="meal"
onBlur={onBlur}
className={classNames({
"h-100 w-full flex-grow resize-none overflow-hidden break-words bg-transparent text-start text-xs focus:border-none focus:outline-none lg:text-base":
true,
"text-base-content": isCurrentMonth,
"text-neutral-400": !isCurrentMonth,
})}
/>
</form>
);
};

0 comments on commit d549de3

Please sign in to comment.