Improve calendar styles and improve chore display logic in CalendarView

This commit is contained in:
Mo Tarbin
2025-05-28 00:11:46 -04:00
parent 709a91b1db
commit 581931b679
2 changed files with 60 additions and 11 deletions

View File

@@ -6,11 +6,25 @@
border: none; border: none;
} }
/* Add styles for weekday names */
.react-calendar__month-view__weekdays__weekday {
text-decoration: none;
font-weight: 500;
padding: 0.5em;
}
.react-calendar__month-view__weekdays__weekday abbr {
text-decoration: none;
border-bottom: none;
cursor: default;
}
.react-calendar__tile { .react-calendar__tile {
padding: 10px; padding: 10px;
min-height: 45px; max-height: 40px;
min-width: 40px;
text-align: center; text-align: center;
border-radius: 8px; border-radius: 50px;
transition: background-color 0.3s ease; transition: background-color 0.3s ease;
} }
@@ -19,13 +33,13 @@
} }
.react-calendar__tile--active { .react-calendar__tile--active {
background-color: #007bff !important; border: 1px dotted #4ec1a2e3 !important;
/* background-color: inherit; */
} }
.react-calendar__tile--now { .react-calendar__tile--now {
border: 1px dotted #4ec1a2e3 !important; background-color: #007bff !important;
border-radius: 8px; border-radius: 50px;
background-color: inherit;
} }
.react-calendar__tile--now:enabled:hover { .react-calendar__tile--now:enabled:hover {
@@ -39,6 +53,8 @@
height: 16px; height: 16px;
flex-wrap: wrap; flex-wrap: wrap;
position: relative; position: relative;
min-height: 16px;
margin-top: -5px;
} }
.dot { .dot {
@@ -48,6 +64,16 @@
margin: 0 1px; margin: 0 1px;
} }
.dot-with-line {
width: 1.2em;
height: 0.3em;
border-radius: 0.15em;
margin: 0 1px;
}
.dot-empty {
background-color: transparent;
}
.chore-tooltip { .chore-tooltip {
position: absolute; position: absolute;
top: 100%; top: 100%;

View File

@@ -26,14 +26,32 @@ const CalendarView = ({ chores }) => {
const tileDate = date.toLocaleDateString() const tileDate = date.toLocaleDateString()
return choreDate === tileDate return choreDate === tileDate
}) })
if (dayChores.length === 0) {
return (
<div className='dot-container'>
<span className='dot-empty'></span>
</div>
)
}
if (dayChores.length > 3) {
return (
<div className='dot-container'>
<span
className='dot-with-line'
style={{
backgroundColor: getAssigneeColor(
dayChores[0].assignedTo,
userProfile,
),
}}
></span>
</div>
)
}
return ( return (
<div className='dot-container'> <div className='dot-container'>
{dayChores.map((chore, index) => { {dayChores.map((chore, index) => {
if (index > 6) {
return null
}
return ( return (
<span <span
key={index} key={index}
@@ -68,9 +86,13 @@ const CalendarView = ({ chores }) => {
onChange={d => { onChange={d => {
setSeletedDate(new Date(d)) setSeletedDate(new Date(d))
}} }}
// format the days from MON, TUE, WED, THU, FRI, SAT, SUN to first three letters:
// formatShortWeekday={(locale, date) =>
// ['S', 'M', 'T', 'W', 'T', 'F', 'S'][date.getDay()]
// }
/> />
{!selectedDate && ( {!selectedDate && (
<Grid container ml={-3}> <Grid container ml={-3} mt={1}>
{[ {[
{ name: 'Assigned to me', color: TASK_COLOR.ASSIGNED_TO_ME }, { name: 'Assigned to me', color: TASK_COLOR.ASSIGNED_TO_ME },
{ name: 'Assigned to other', color: TASK_COLOR.ASSIGNED_TO_OTHER }, { name: 'Assigned to other', color: TASK_COLOR.ASSIGNED_TO_OTHER },
@@ -108,6 +130,7 @@ const CalendarView = ({ chores }) => {
// p: 2, // p: 2,
// borderRadius: 20, // borderRadius: 20,
// if exceed the height, scroll: // if exceed the height, scroll:
mt: 1,
maxHeight: '160px', maxHeight: '160px',
overflowY: 'auto', overflowY: 'auto',
// minimum height to fit the content: // minimum height to fit the content: