Skip to content

Commit

Permalink
Edited styles & linted
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessh committed Oct 26, 2024
1 parent b4529bb commit af9320d
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 59 deletions.
28 changes: 28 additions & 0 deletions frontend/src/components/pages/schedule/ScheduleCalendar.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
.fc .fc-toolbar-title {
font-size: 2em;
font-weight: 700;
}

.fc-timegrid-slot

.fc-timegrid-slot-lane

.fc-timegrid-slot-minor {
display: none;
color: transparent;
}

.fc-scrollgrid-liquid {
border-left: none!important;
}

.fc-timegrid-slot-label {
border: none!important;
padding-right: 5px!important;
}

col {
width: 100px!important;
}

:root {
--fc-today-bg-color: rgba(87,70,157,0.10);
--fc-button-bg-color: rgb(87, 70, 157);
--fc-button-border-color: rgb(87, 70, 157);
--fc-button-hover-bg-color: rgb(71, 53, 147);
--fc-button-hover-border-color: rgb(71, 53, 147);
--fc-button-active-bg-color: rgb(62, 42, 153);
--fc-button-active-border-color: rgb(62, 42, 153);
}
109 changes: 65 additions & 44 deletions frontend/src/components/pages/schedule/ScheduleCalendar.tsx
Original file line number Diff line number Diff line change
@@ -1,75 +1,96 @@
import FullCalendar from '@fullcalendar/react'
import timeGridPlugin from '@fullcalendar/timegrid';
import { DayHeaderContentArg, EventContentArg } from '@fullcalendar/core';
import FullCalendar from "@fullcalendar/react";
import timeGridPlugin from "@fullcalendar/timegrid";
import { DayHeaderContentArg, EventContentArg } from "@fullcalendar/core";
import React, { useEffect, useRef } from "react";
import ModeCommentOutlinedIcon from "@mui/icons-material/ModeCommentOutlined";
import "./ScheduleCalendar.css";

const events = [
{ title: 'test', start: new Date('2024-09-29T09:00:00'), end: new Date('2024-09-29T10:00:00' ), allDay: true },
]
{
title: "test",
start: new Date("2024-09-29T09:00:00"),
end: new Date("2024-09-29T10:00:00"),
allDay: true,
},
];

function renderEventContent(eventInfo: EventContentArg) {
const isAllDay = eventInfo.event.allDay;
return (
<div style={{
display: 'flex',
flexDirection: isAllDay ? 'row' : 'column',
padding: '5px',
borderRadius: '5px',
border: '0px',
borderLeft: '5px solid #255B9A',
backgroundColor: '#C5DCF8',
color: '#255B9A',
justifyContent: isAllDay ? 'space-between' : 'flex-start',
}}>
<div><b>{eventInfo.event.title}</b></div>
{isAllDay ? '' : `${new Date(eventInfo.event.start!).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} - ${new Date(eventInfo.event.end!).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`}
<ModeCommentOutlinedIcon fontSize="inherit" style={{marginTop: '3px'}} />
<div
style={{
display: "flex",
flexDirection: isAllDay ? "row" : "column",
padding: "5px",
borderRadius: "5px",
border: "0px",
borderLeft: "5px solid #255B9A",
backgroundColor: "#C5DCF8",
color: "#255B9A",
justifyContent: isAllDay ? "space-between" : "flex-start",
}}
>
<div>
<b>{eventInfo.event.title}</b>
</div>
{isAllDay
? ""
: `${new Date(eventInfo.event.start!).toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
})} - ${new Date(eventInfo.event.end!).toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
})}`}
<ModeCommentOutlinedIcon
fontSize="inherit"
style={{ marginTop: "3px" }}
/>
</div>
)
);
}

function renderHeaderContent(date: DayHeaderContentArg) {
const dayOfWeek = date.date.toLocaleString('en-US', { weekday: 'long' });
const dayOfWeek = date.date.toLocaleString("en-US", { weekday: "long" });
const dayOfMonth = date.date.getDate();

return (
<div style={{ textAlign: 'center'}}>
<div style={{ textAlign: "center" }}>
{dayOfWeek.substring(0, 3).toUpperCase()}
<br />
{dayOfMonth}
</div>
)
);
}

export function ScheduleCalendar() {
export function ScheduleCalendar() {
const calendarRef = useRef<any>(null);
const handleAllDayContent = (arg: any) => {
return <span>{arg.text ? '' : ''}</span>;
return <span>{arg.text ? "" : ""}</span>;
};
return (
<div>
<FullCalendar
plugins={[timeGridPlugin]}
initialView='timeGridWeek'
weekends
events={events}
slotMinTime="08:00:00"
slotMaxTime="19:00:00"
slotDuration={{ minute: 20 }}
slotLabelInterval={{ hours: 1 }}
eventContent={renderEventContent}
dayHeaderContent={renderHeaderContent}
eventDisplay="block"
firstDay={1} // Set the first day of the week to Monday
slotLabelFormat={{ hour: 'numeric', minute: '2-digit', hour12: true }} // Format slots as H:MM am/pm
allDayContent={handleAllDayContent}
eventBackgroundColor='transparent'
eventBorderColor='transparent'
slotEventOverlap={false}
plugins={[timeGridPlugin]}
initialView="timeGridWeek"
weekends
events={events}
slotMinTime="08:00:00"
slotMaxTime="19:00:00"
slotDuration={{ minute: 20 }}
slotLabelInterval={{ hours: 1 }}
eventContent={renderEventContent}
dayHeaderContent={renderHeaderContent}
eventDisplay="block"
firstDay={1} // Set the first day of the week to Monday
slotLabelFormat={{ hour: "numeric", minute: "2-digit", hour12: true }} // Format slots as H:MM am/pm
allDayContent={handleAllDayContent}
eventBackgroundColor="transparent"
eventBorderColor="transparent"
slotEventOverlap={false}
/>
</div>
)
);
}

export default ScheduleCalendar;
export default ScheduleCalendar;
20 changes: 5 additions & 15 deletions frontend/src/components/pages/schedule/SchedulePage.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
import React from "react";
import {
Flex,
} from "@chakra-ui/react";
import { Flex } from "@chakra-ui/react";

import RoomCard from "../home/HomeRoomCard"
import RoomCard from "../home/HomeRoomCard";
import { residentsMockData } from "../../../mocks/residents";
import { ScheduleCalendar } from "./ScheduleCalendar";

const renderRoomCards = residentsMockData.map(resident =>
const renderRoomCards = residentsMockData.map((resident) => (
<RoomCard
key={resident.residentId}
room={resident.roomNumber}
residentId={resident.residentId}
/>
)

));

const SchedulePage = (): React.ReactElement => {
return (
<Flex flexDir="column" flexGrow={1} p="20px">
<h1>Schedule Page</h1>
<Flex
flexWrap="wrap"
justifyContent="flex-start"
>
{renderRoomCards}
</Flex>
<ScheduleCalendar/>
<ScheduleCalendar />
</Flex>
);
};
Expand Down
29 changes: 29 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2307,6 +2307,30 @@
resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.2.1.tgz#16308cea045f0fc777b6ff20a9f25474dd8293d2"
integrity sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q==

"@fullcalendar/core@^6.1.15":
version "6.1.15"
resolved "https://registry.yarnpkg.com/@fullcalendar/core/-/core-6.1.15.tgz#6c3f5259fc4589870228853072131219bb533f6e"
integrity sha512-BuX7o6ALpLb84cMw1FCB9/cSgF4JbVO894cjJZ6kP74jzbUZNjtwffwRdA+Id8rrLjT30d/7TrkW90k4zbXB5Q==
dependencies:
preact "~10.12.1"

"@fullcalendar/daygrid@^6.1.15", "@fullcalendar/daygrid@~6.1.15":
version "6.1.15"
resolved "https://registry.yarnpkg.com/@fullcalendar/daygrid/-/daygrid-6.1.15.tgz#91208b0955ba805ddad285a53ee6f53855146963"
integrity sha512-j8tL0HhfiVsdtOCLfzK2J0RtSkiad3BYYemwQKq512cx6btz6ZZ2RNc/hVnIxluuWFyvx5sXZwoeTJsFSFTEFA==

"@fullcalendar/react@^6.1.15":
version "6.1.15"
resolved "https://registry.yarnpkg.com/@fullcalendar/react/-/react-6.1.15.tgz#3198b4a64e256afd37c9760c8741a9af89ade894"
integrity sha512-L0b9hybS2J4e7lq6G2CD4nqriyLEqOH1tE8iI6JQjAMTVh5JicOo5Mqw+fhU5bJ7hLfMw2K3fksxX3Ul1ssw5w==

"@fullcalendar/timegrid@^6.1.15":
version "6.1.15"
resolved "https://registry.yarnpkg.com/@fullcalendar/timegrid/-/timegrid-6.1.15.tgz#c4630b7c03c813065154c6e3981f8d51d9d692e5"
integrity sha512-61ORr3A148RtxQ2FNG7JKvacyA/TEVZ7z6I+3E9Oeu3dqTf6M928bFcpehRTIK6zIA6Yifs7BeWHgOE9dFnpbw==
dependencies:
"@fullcalendar/daygrid" "~6.1.15"

"@graphql-typed-document-node/core@^3.1.1":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861"
Expand Down Expand Up @@ -9371,6 +9395,11 @@ postcss@^8.3.5, postcss@^8.4.23, postcss@^8.4.33, postcss@^8.4.4:
picocolors "^1.0.0"
source-map-js "^1.0.2"

preact@~10.12.1:
version "10.12.1"
resolved "https://registry.yarnpkg.com/preact/-/preact-10.12.1.tgz#8f9cb5442f560e532729b7d23d42fd1161354a21"
integrity sha512-l8386ixSsBdbreOAkqtrwqHwdvR35ID8c3rKPa8lCWuO86dBi32QWHV4vfsZK1utLLFMvw+Z5Ad4XLkZzchscg==

prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
Expand Down

0 comments on commit af9320d

Please sign in to comment.