refactor: highlight today in calendar + monday is 1st day of week

This commit is contained in:
Nicola Zambello 2023-02-20 15:13:21 +01:00
parent a6a9ce4c0d
commit ac7f544512
Signed by: nzambello
GPG key ID: 56E4A92C2C1E50BA
2 changed files with 72 additions and 0 deletions

View file

@ -326,6 +326,24 @@ export default function TimeEntryDetailsPage() {
newDate.setDate(date.getDate());
setStart(newDate);
}}
firstDayOfWeek="monday"
renderDay={(date) => {
const day = date.getDate();
const today = new Date();
const isToday =
date.getDate() === today.getDate() &&
date.getMonth() === today.getMonth() &&
date.getFullYear() === today.getFullYear();
return isToday ? (
<Text component="div" weight="bold" underline>
{day}
</Text>
) : (
<Text component="div">{day}</Text>
);
}}
/>
<TimeInput
id="new-startTime-time"
@ -390,6 +408,24 @@ export default function TimeEntryDetailsPage() {
newDate.setDate(date.getDate());
setEnd(newDate);
}}
firstDayOfWeek="monday"
renderDay={(date) => {
const day = date.getDate();
const today = new Date();
const isToday =
date.getDate() === today.getDate() &&
date.getMonth() === today.getMonth() &&
date.getFullYear() === today.getFullYear();
return isToday ? (
<Text component="div" weight="bold" underline>
{day}
</Text>
) : (
<Text component="div">{day}</Text>
);
}}
/>
<TimeInput
id="new-endTime-time"

View file

@ -312,6 +312,7 @@ export default function NewTimeEntryPage() {
locale="it"
placeholder="Start date"
label="Start date"
firstDayOfWeek="monday"
aria-invalid={actionData?.errors?.startTime ? true : undefined}
error={actionData?.errors?.startTime}
errorProps={{ children: actionData?.errors?.startTime }}
@ -324,6 +325,23 @@ export default function NewTimeEntryPage() {
newDate.setDate(date.getDate());
setStart(newDate);
}}
renderDay={(date) => {
const day = date.getDate();
const today = new Date();
const isToday =
date.getDate() === today.getDate() &&
date.getMonth() === today.getMonth() &&
date.getFullYear() === today.getFullYear();
return isToday ? (
<Text component="div" weight="bold" underline>
{day}
</Text>
) : (
<Text component="div">{day}</Text>
);
}}
/>
<TimeInput
id="new-startTime-time"
@ -371,6 +389,7 @@ export default function NewTimeEntryPage() {
locale="it"
placeholder="End date"
label="End date"
firstDayOfWeek="monday"
aria-invalid={actionData?.errors?.endTime ? true : undefined}
error={actionData?.errors?.endTime}
errorProps={{ children: actionData?.errors?.endTime }}
@ -383,6 +402,23 @@ export default function NewTimeEntryPage() {
newDate.setDate(date.getDate());
setEnd(newDate);
}}
renderDay={(date) => {
const day = date.getDate();
const today = new Date();
const isToday =
date.getDate() === today.getDate() &&
date.getMonth() === today.getMonth() &&
date.getFullYear() === today.getFullYear();
return isToday ? (
<Text component="div" weight="bold" underline>
{day}
</Text>
) : (
<Text component="div">{day}</Text>
);
}}
/>
<TimeInput
id="new-endTime-time"