Skip to content

Commit e5a5821

Browse files
committed
Styling Announcement Page and Making Popup
1 parent 1a48933 commit e5a5821

File tree

8 files changed

+198
-49
lines changed

8 files changed

+198
-49
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React, {useState, useEffect} from 'react';
2+
import { useNavigate } from 'react-router-dom';
3+
import '../../styles/AnnouncementPopup.css';
4+
import { TfiAnnouncement } from 'react-icons/tfi';
5+
6+
7+
8+
const AnnouncementPopup = () => {
9+
const [show, setShow] = useState(true);
10+
const [latestAnnouncement, setLatestAnnouncement] = useState(null);
11+
const navigate = useNavigate();
12+
13+
const formatDate = (timestamp) => {
14+
const date = new Date(timestamp);
15+
return date.toLocaleDateString('en-US', {
16+
weekday: 'long',
17+
year: 'numeric',
18+
month: 'long',
19+
day: 'numeric',
20+
});
21+
};
22+
23+
useEffect(() => {
24+
fetch('src/data/announcements.json')
25+
.then((response) => response.json())
26+
.then((data) => {
27+
if (data.length > 0) {
28+
setLatestAnnouncement(data[0]);
29+
}
30+
})
31+
.catch((error) => console.error('Error fetching announcements', error));
32+
}, []);
33+
34+
const handleDelete = () => {
35+
setShow(false);
36+
};
37+
38+
if (!show || !latestAnnouncement) return null;
39+
40+
return (
41+
<div className='popup'>
42+
<button className = 'speaker-icon' onClick={() => navigate('./announcements')}>
43+
<TfiAnnouncement/>
44+
</button>
45+
<div className='popup-content'>
46+
<button className='close' onClick={handleDelete}>
47+
&times;
48+
</button>
49+
<h1 className='popup-label'> {latestAnnouncement.subject} </h1>
50+
<p className = 'popup-date'> {formatDate(latestAnnouncement.timestamp)} </p>
51+
<p className='popup-body'> {latestAnnouncement.body} </p>
52+
</div>
53+
</div>
54+
55+
);
56+
57+
};
58+
59+
export default AnnouncementPopup

src/data/announcements.json

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,32 @@
11
[
2-
{
3-
"id": 7,
4-
"subject": "hello",
5-
"body": "bye",
6-
"timestamp": "2025-02-04T04:01:50Z"
7-
},
8-
{
9-
"id": 6,
10-
"subject": "Hello",
11-
"body": "",
12-
"timestamp": "2025-02-02T06:04:56Z"
13-
},
14-
{
15-
"id": 5,
16-
"subject": "hello",
17-
"body": "bye",
18-
"timestamp": "2025-02-02T01:13:55Z"
19-
},
202
{
213
"id": 4,
22-
"subject": "hello",
23-
"body": "bye",
24-
"timestamp": "2025-02-02T01:06:22Z"
4+
"subject": "Congratulations!",
5+
"body": "This workshop covers the basics of Web Development - HTML, CSS, and JavaScript! Together, they make up the structure (HTML), the style (CSS), and the functionality (JS) of a web application.",
6+
"timestamp": "2025-02-04T01:06:22Z"
257
},
268
{
279
"id": 3,
28-
"subject": "hello",
29-
"body": "bye",
10+
"subject": "Yay!",
11+
"body": "Hello! Welcome to HOTH XI's Intro to Web APIs workshop. This is a guide to introduce you to the foundations of Web APIs that will allow you to integrate them into any fullstack project. We will be covering the client-server model, HTTP requests & responses, and how we can leverage external servers to retrieve data and services for an app. Keep reading to learn more!",
3012
"timestamp": "2025-02-02T01:05:09Z"
3113
},
3214
{
3315
"id": 2,
34-
"subject": "Your announcement text here",
35-
"body": "The subject/title of your announcement",
16+
"subject": "Intro to Servers!",
17+
"body": "In this workshop, you will learn server-side programming in the context of full stack applications! Topics covered include HTTP, CRUD, and REST APIs. The second half of the workshop will include a hands-on demo building your own REST API using Flask and connecting it with a React frontend. By the end of the workshop you will become a server savant savvy with tools such as Postman. Viewers are recommended to have a strong foundation in JavaScript and Python.",
3618
"timestamp": "2025-02-02T01:01:26Z"
3719
},
3820
{
3921
"id": 1,
40-
"subject": "Hello1",
41-
"body": "",
22+
"subject": "Intro to React.js",
23+
"body": "Hello! Welcome to the Intro to React JS workshop for HOTH XI! Here we will be introducing frontend web development using React. In this workshop we will utilize HTML, CSS, and JavaScript, so I would recommend watching the workshop on those if you are not already familiar with them!",
4224
"timestamp": "2025-02-02T00:58:11Z"
4325
},
4426
{
4527
"id": 0,
46-
"subject": "Hello",
47-
"body": "",
28+
"subject": "Intro to React Native",
29+
"body": "Hello and welcome to our Intro to React Native workshop! We'll be covering the basics of React Native in a way that I hope is simple to understand and impactful enough to teach some key features of app development. Happy hacking!",
4830
"timestamp": "2025-02-02T00:57:26Z"
4931
}
5032
]

src/pages/Announcements.jsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,24 @@ export default function Announcements() {
99
const formatDate = (timestamp) => {
1010
const date = new Date(timestamp);
1111
return date.toLocaleDateString('en-US', {
12+
weekday: 'long',
1213
year: 'numeric',
13-
month: 'long',
14-
day: 'numeric',
15-
hour: '2-digit',
16-
minute: '2-digit'
14+
month: 'long',
15+
day: 'numeric',
1716
});
1817
};
1918

2019
return (
2120
<div id='announcements'>
22-
<h1>Announcements</h1>
23-
<div>
21+
<h1 className = 'announcements-title'>Announcements</h1>
22+
<div className = 'announcements-container'>
2423
{announcements.map((announcement) => (
25-
<div key={announcement.id}>
26-
<h2>{announcement.subject}</h2>
27-
<p >{announcement.body}</p>
28-
<p>
29-
Posted on {formatDate(announcement.timestamp)}
24+
<div key={announcement.id} className='announcements-label'>
25+
<h2 className = 'announcements-subject'>{announcement.subject}</h2>
26+
<p className = 'announcements-date'>
27+
{formatDate(announcement.timestamp)}
3028
</p>
29+
<p className = 'announcements-body'>{announcement.body}</p>
3130
</div>
3231
))}
3332
</div>

src/pages/Home.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Banner from '../components/Home/Banner';
55
import HothDescription from '../components/Home/HothDescription';
66
import PhotoCarousel from '../components/Home/PhotoCarousel';
77
import FAQSection from '../components/Home/FAQSection';
8+
import AnnouncementPopup from '../components/General/AnnouncementPopup';
89

910
export default function Home() {
1011
useTitle('');
@@ -35,6 +36,8 @@ export default function Home() {
3536
<Container2>
3637
<FAQSection />
3738
</Container2>
39+
40+
<AnnouncementPopup />
3841
</div>
3942
);
4043
}

src/pages/Schedule.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import useTitle from '../components/General/useTitle';
33
import eventSchedule from '../data/eventSchedule';
44
import '../styles/Schedule.css';
55
import { FaRegClock } from 'react-icons/fa';
6-
import '../styles/Announcements.css';
76

87
const formatTime = date => {
98
const options = {
@@ -44,9 +43,9 @@ export default function Schedule() {
4443
))}
4544
</div>
4645
) : (
47-
<div id='announcements'>
48-
<h1 className='announcements-title'>Schedule</h1>
49-
<div className='announcements-container'>
46+
<div id='schedule'>
47+
<h1 className='schedule-title'>Schedule</h1>
48+
<div className='events-container'>
5049
<p>
5150
HOTH XII will take place later this quarter, and our team is working
5251
hard to organize a fantastic hackathon for you all!{' '}

src/styles/AnnouncementPopup.css

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
.popup {
2+
position: fixed;
3+
right: 1rem;
4+
bottom: 1rem;
5+
justify-content: flex-end;
6+
align-items: center;
7+
z-index: 100;
8+
9+
}
10+
11+
.popup-content {
12+
background: #f7f7f7;
13+
padding: 1.5rem;
14+
border: 1px solid lightgray;
15+
border-radius: 1rem;
16+
margin-left: 2rem;
17+
max-width: 16rem;
18+
}
19+
20+
.dark .popup-content {
21+
background: #362d40;
22+
border: 1px solid #362d40;
23+
}
24+
25+
.speaker-icon {
26+
position: absolute;
27+
background-color: yellow;
28+
top: -3.4rem;
29+
right: 0rem;
30+
width: 50px;
31+
height: 50px;
32+
border-radius: 50%;
33+
display: flex;
34+
align-items: center;
35+
justify-content: center;
36+
box-shadow: 0 0px 10px rgba(0, 0, 0, 0.5);
37+
font-size: 1.5rem;
38+
transition: all 0.3s ease-in-out;
39+
cursor: pointer;
40+
border: none;
41+
}
42+
43+
.speaker-icon:hover {
44+
background-color: #FFFFC5;
45+
}
46+
47+
.popup-label {
48+
font-size: 1.5rem;
49+
}
50+
51+
.popup-date {
52+
font-size: 0.9rem;
53+
}
54+
55+
.popup-body {
56+
font-size: 0.95rem;
57+
}
58+
59+
.close {
60+
position: absolute;
61+
top: 0.5rem;
62+
left: 2.5rem;
63+
border: none;
64+
font-size: 1.2rem;
65+
font-weight: bold;
66+
background: transparent;
67+
cursor: pointer;
68+
}
69+
70+
.dark .close {
71+
color: white;
72+
}

src/styles/Announcements.css

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
#announcements {
22
width: 100%;
3-
max-width: 60rem;
4-
padding: 2rem 3rem;
3+
max-width: 80rem;
4+
padding: 2rem 10rem;
55
}
66

77
.announcements-title {
8-
font-size: 3rem;
8+
padding-bottom: 1.5rem;
9+
font-size: 2.5rem;
10+
text-align: center;
911
}
1012

1113
.announcements-container {
12-
display: flex;
13-
flex-direction: column;
14+
display: grid;
15+
gap: 1rem;
16+
width: 100%;
17+
margin: 0 auto;
18+
}
19+
20+
.announcements-label {
21+
background: var(--bgWhite);
22+
padding: 1.5rem 2rem;
23+
border: 1px solid lightgray;
24+
box-shadow: 0 2px 6px var(--lightGray);
25+
border-radius: 0.75rem;
26+
transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
27+
}
28+
29+
.announcements-label:hover {
30+
transform: translateY(-3px);
31+
box-shadow: 0 0px 6px var(--hackPrimary);
32+
}
33+
34+
.announcements-subject {
35+
margin-top: 1.1%;
36+
padding-top: 0.1rem;
37+
}
38+
39+
.announcements-date {
40+
margin-top: 0.7rem;
41+
text-align: left;
42+
font-size: 0.9rem;
43+
margin-bottom: 1rem;
44+
}
45+
46+
.announcements-body {
47+
margin-top: 1.5rem;
1448
}
1549

1650
@media (max-width: 550px) {

0 commit comments

Comments
 (0)