Skip to content

Commit 0379c1b

Browse files
author
Malin Kussi
committed
Fixed events and nav bar
1 parent 62935a8 commit 0379c1b

File tree

7 files changed

+118
-58
lines changed

7 files changed

+118
-58
lines changed
23.6 KB
Loading

src/data/EventsDatabase.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,49 @@
11
import { EventObject } from '../tools/CustomTypes'
22

3-
const semesterEnd = '5/31/25'
3+
const semesterEnd = '5/08/25'
44
const EVENT_INFO: EventObject[] = [
55
{
66
title: 'Weekly SolidWorks Workshop',
77
description: `The goal of these classes is to equip you with the skills to model and design on a professional
88
level, as well as create a common ground for all engineers to work together more efficiently and effectively`,
9-
date: new Date('2025-02-17T17:30:00'),
9+
date: new Date('2025-02-24T17:30:00'),
1010
location: 'The ideas hub (second floor of the engineering building)',
1111
weekly: true,
12-
endDate: new Date(semesterEnd)
12+
endDate: new Date(semesterEnd),
13+
duration: 90 // 1 hour 30 minutes
1314
},
1415
{
1516
title: 'General Body Meeting',
1617
description: 'Updates on what happened since the last GBM and the plan for the rest of the semester as well as an activity',
1718
date: new Date('2025-02-05T17:00:00'),
18-
// location: 'The Fish Bowl (first floor pf the engineering building)'
1919
location: '201A classroom (The ideas hub second floor of the engineering building)'
2020
},
2121
{
2222
title: 'Weekly Programming Meeting',
2323
description: 'The weekly meeting for the programming sub-team. Take a look at the code for the robot',
24-
date: new Date('2025-02-12T17:00:00'),
24+
date: new Date('2025-02-26T17:00:00'),
2525
location: 'The ideas hub (second floor of the engineering building)',
2626
weekly: true,
27-
endDate: new Date(semesterEnd)
27+
endDate: new Date(semesterEnd),
28+
duration: 60 // 1 hour
2829
},
2930
{
3031
title: 'Weekly Electrical Meeting',
3132
description: 'The weekly meeting for the electrical sub-team. Talk about improved batteries, wiring, and more!',
32-
date: new Date('2025-02-12T18:00:00'),
33+
date: new Date('2025-02-26T18:00:00'),
3334
location: 'The ideas hub (second floor of the engineering building)',
3435
weekly: true,
35-
endDate: new Date(semesterEnd)
36+
endDate: new Date(semesterEnd),
37+
duration: 60 // 1 hour
3638
},
3739
{
3840
title: 'Weekly Mechanical Meeting',
3941
description: 'The weekly meeting for the mechanical sub-team. Learn about the design aspects of robot and 3D model parts.',
40-
date: new Date('2025-02-12T16:00:00'),
42+
date: new Date('2025-02-26T16:00:00'),
4143
location: 'The ideas hub (second floor of the engineering building)',
4244
weekly: true,
43-
endDate: new Date(semesterEnd)
45+
endDate: new Date(semesterEnd),
46+
duration: 60 // 1 hour
4447
}
4548
]
4649

src/pages/events/EventListStyles.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ export default class EventListStyles {
1010
grid-template-rows: repeat(${props => props.rows}, minmax(0, 1fr));
1111
grid-row-gap: 5%;
1212
justify-items: center;
13+
14+
@media (max-width: 718px) {
15+
display: grid;
16+
grid-template-columns: 100%;
17+
grid-template-rows:
18+
calc(var(--vh) * .2) /* Intro heading */
19+
max(calc(var(--vh) * .15), 100px); /* Contact info */
20+
justify-content: center;
21+
align-content: center;
22+
}
1323
`
1424

1525
static readonly EventItemContainer = styled.div`

src/pages/general/navigation/Navigation.tsx

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,51 +19,80 @@ const Navigation = (): React.ReactElement => {
1919
const TEAMS = `https://teams.microsoft.com/l/team/19%3aeaf903fd81cd48eba95d8e769ed78544%40thread.tacv2/conversations?groupId=8f
2020
78ecbb-62f3-4b2c-bda7-7488eca908ee&tenantId=716e81ef-b522-4473-8e31-10bd02ccf6e5`
2121

22-
// State for handling dropdown hover
22+
// State for handling dropdown visibility
2323
const [showDropdown, setShowDropdown] = useState(false)
2424

25+
// Timeout variable to prevent flickering
26+
let hideDropdownTimeout: NodeJS.Timeout
27+
28+
// Open dropdown when hovering over "Projects"
29+
const handleMouseEnter = (): void => {
30+
clearTimeout(hideDropdownTimeout) // Cancel hide if mouse enters again
31+
setShowDropdown(true)
32+
}
33+
34+
// Close dropdown when mouse leaves (with small delay)
35+
const handleMouseLeave = (): void => {
36+
hideDropdownTimeout = setTimeout(() => {
37+
setShowDropdown(false)
38+
}, 400) // Small delay before closing
39+
}
40+
41+
// Close dropdown when clicking a project
42+
const handleItemClick = (): void => {
43+
setShowDropdown(false) // Close dropdown when a project is clicked
44+
scrollToTop()
45+
}
46+
2547
return (
2648
<>
27-
{/* The rest of the navigation bar. The className is dependent on whether the navbar is expanded or not */}
2849
<Styles.NavigationBar id='navbar-transition'
29-
transparency={ scroll <= 10 && width > Constants.MOBILE_SIZE ? 1 : 0 }
30-
toggle={ width < Constants.MOBILE_SIZE ? 1 : 0 }
50+
transparency={scroll <= 10 && width > Constants.MOBILE_SIZE ? 1 : 0}
51+
toggle={width < Constants.MOBILE_SIZE ? 1 : 0}
3152
sticky='top' bg='dark' variant='dark' expand='md' collapseOnSelect>
53+
3254
{/* Top left of the navigation bar */}
3355
<Styles.Logo className='logo-and-title'>
3456
<Link className='logo-container' to='/home'>
35-
<img alt='logo' src={nasaLogo} id='web-logo' onClick={scrollToTop}/>
57+
<img alt='logo' src={nasaLogo} id='web-logo' onClick={scrollToTop} />
3658
<div>
3759
<p>Temple Space</p>
3860
<p>Exploration</p>
3961
</div>
4062
</Link>
4163
</Styles.Logo>
64+
4265
<Navbar.Toggle aria-controls='basic-navbar-nav' />
4366
<Navbar.Collapse className='basic-navbar-links'>
44-
<Styles.NavbarLinks variant='pills' toggle={ width < Constants.MOBILE_SIZE ? 1 : 0 }>
45-
<NavLink eventKey='7' as={Link} to={Constants.PATHS.HOME} onClick={() => location.href = TEAMS}>Teams</NavLink>
67+
<Styles.NavbarLinks variant='pills' toggle={width < Constants.MOBILE_SIZE ? 1 : 0}>
4668
<NavLink eventKey='1' as={Link} to={Constants.PATHS.HOME} onClick={scrollToTop}>Home</NavLink>
4769
<NavLink eventKey='2' as={Link} to={Constants.PATHS.EVENTS} onClick={scrollToTop}>Events</NavLink>
4870
<NavLink eventKey='3' as={Link} to={Constants.PATHS.SPONSORS} onClick={scrollToTop}>Sponsors</NavLink>
49-
{/* Projects Dropdown - Opens on Hover */}
50-
<NavDropdown
51-
title='Projects'
52-
id='projects-dropdown'
53-
show={showDropdown}
54-
onMouseEnter={() => setShowDropdown(true)}
55-
onMouseLeave={() => setShowDropdown(false)}
56-
className='nav-link'>
57-
<NavDropdown.Item as={Link} to={Constants.PATHS.ROBOTICS} onClick={scrollToTop}>
58-
Robotics
59-
</NavDropdown.Item>
60-
<NavDropdown.Item as={Link} to={Constants.PATHS.ROCKSAT} onClick={scrollToTop}>
61-
RockSat
62-
</NavDropdown.Item>
63-
<NavDropdown.Item as={Link} to={Constants.PATHS.BALLOONING} onClick={scrollToTop}>
64-
NASA Ballooning
65-
</NavDropdown.Item>
66-
</NavDropdown>
71+
72+
{/* Projects Dropdown - Opens on Hover, Closes on Click */}
73+
<div className='nav-item'
74+
onMouseEnter={handleMouseEnter}
75+
onMouseLeave={handleMouseLeave}>
76+
<NavDropdown
77+
title='Projects'
78+
id='projects-dropdown'
79+
show={showDropdown}
80+
className='nav-link'>
81+
<div onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
82+
<NavDropdown.Item as={Link} to={Constants.PATHS.ROBOTICS} onClick={handleItemClick}>
83+
Robotics
84+
</NavDropdown.Item>
85+
<NavDropdown.Item as={Link} to={Constants.PATHS.ROCKSAT} onClick={handleItemClick}>
86+
RockSat
87+
</NavDropdown.Item>
88+
<NavDropdown.Item as={Link} to={Constants.PATHS.BALLOONING} onClick={handleItemClick}>
89+
NASA Ballooning
90+
</NavDropdown.Item>
91+
</div>
92+
</NavDropdown>
93+
</div>
94+
95+
<NavLink eventKey='7' as={Link} to={Constants.PATHS.HOME} onClick={() => location.href = TEAMS}>Teams</NavLink>
6796
</Styles.NavbarLinks>
6897
</Navbar.Collapse>
6998
</Styles.NavigationBar>

src/pages/general/navigation/NavigationStyles.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,31 @@ export default class NavigationStyles {
8080
padding: 4px 8px 8px 8px;
8181
}
8282
83+
div.nav-item{
84+
position: relative;
85+
padding: 2px 0px 0px 0px;
86+
}
87+
8388
a.dropdown-toggle {
8489
background-color: ${props => props.toggle ? `${COLORS.SELECTED}` : 'transparent'} !important;
8590
color: ${COLORS.TEXT} !important;
86-
font-size: 16px;
87-
}
88-
89-
/* Show dropdown on hover */
90-
.nav-item:hover .dropdown-menu {
91-
display: block !important;
91+
font-size: 17px;
92+
padding: 6px 8px 8px 8px;
9293
}
9394
9495
.dropdown-menu {
95-
display: none;
9696
position: absolute;
9797
background-color: ${props => props.toggle ? `${COLORS.SELECTED}` : 'transparent'} !important;
98-
padding: 0px 8px 8px 13px;
98+
padding: 0px 8px 8px 16px;
9999
border: none;
100100
}
101101
102102
.dropdown-item {
103103
color: ${COLORS.TEXT} !important;
104+
background-color: ${props => props.toggle ? `${COLORS.SELECTED}` : 'transparent'} !important;
104105
font-size: 15px;
105106
border: none;
107+
padding: 0px
106108
}
107109
108110
.dropdown-item:hover {

src/tools/CustomTypes.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ export type EventObject = {
1111
description: string,
1212
weekly?: boolean,
1313
endDate?: Date,
14-
tbd?: boolean
14+
tbd?: boolean,
15+
duration?: number
1516
}

src/tools/services/getEvents.tsx

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,49 @@ function sortByDate(eventA: EventObject, eventB: EventObject): number {
1616
* @param events The events to be posted
1717
* @returns The events to be posted with the correct weekly dates
1818
*/
19+
1920
function handleWeeklyEvents(events: EventObject[]): EventObject[] {
20-
// Date used to filter out old events
21+
const currentDateTime = new Date().getTime() // Get current time in milliseconds
2122
const dateFilter = new Date()
2223
dateFilter.setDate(dateFilter.getDate() - 1)
2324
dateFilter.setUTCHours(23, 59, 59, 999)
24-
25-
// Remove events that are in the past and no longer occurring.
2625
events = events.filter(event => {
2726
if (event.date < dateFilter && !event.weekly) return 0
2827
if (event.weekly && ((event.endDate ?? new Date()) < dateFilter)) return 0
2928
return 1
3029
})
30+
return events
31+
.map(event => {
32+
const eventDate = new Date(event.date) // Copy event date
33+
const eventEndDate = event.endDate ? new Date(event.endDate) : null
34+
const eventDuration = (event.duration ?? 60) * 60 * 1000 // Convert minutes to milliseconds (default 1hr)
35+
36+
// Compute the actual end time of the event
37+
let eventEndTime = eventDate.getTime() + eventDuration
38+
39+
// If it's a weekly event and has passed, move it forward to the next valid week
40+
if (event.weekly) {
41+
while (eventEndTime < currentDateTime) {
42+
eventDate.setDate(eventDate.getDate() + 7) // Move event forward by one week
43+
eventEndTime = eventDate.getTime() + eventDuration // Update end time
44+
}
3145

32-
// Handle weekly dates. Set them to be the next occurrence if they are in the past.
33-
events.forEach(event => {
34-
if (event.weekly) {
35-
const currentDate = new Date()
36-
const dayOffset = (7 + event.date.getDay() - currentDate.getDay()) % 7
37-
const nextOccurrence = new Date(currentDate.getTime() + dayOffset * 24 * 60 * 60 * 1000)
38-
if (nextOccurrence < currentDate) {
39-
nextOccurrence.setDate(nextOccurrence.getDate() + 7)
46+
// Stop repeating events if the new date exceeds `endDate`
47+
if (eventEndDate && eventDate.getTime() > eventEndDate.getTime()) {
48+
return null // Exclude this event
49+
}
50+
51+
return { ...event, date: eventDate } // Return updated weekly event
4052
}
41-
}
42-
})
4353

44-
return events.sort(sortByDate)
54+
// Non-weekly events should stay as they are
55+
return event
56+
})
57+
.filter((event): event is EventObject => event !== null)
58+
.sort(sortByDate)
4559
}
4660

61+
4762
export function getEvents(): EventObject[] {
4863
const data = EVENT_INFO
4964
return handleWeeklyEvents(data)

0 commit comments

Comments
 (0)