Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changelog Modal #440

Merged
merged 14 commits into from
Mar 7, 2024
2 changes: 2 additions & 0 deletions site/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import './style/theme.scss';
import './App.scss';

import AppHeader from './component/AppHeader/AppHeader';
import ChangelogModal from './component/ChangelogModal/ChangelogModal';
import Footer from './component/Footer/Footer';
import SearchPage from './pages/SearchPage';
import CoursePage from './pages/CoursePage';
Expand Down Expand Up @@ -108,6 +109,7 @@ export default function App() {
</Routes>
<Footer />
</div>
<div className="changelog-modal">{<ChangelogModal />}</div>
</div>
</ThemeContext.Provider>
</Router>
Expand Down
37 changes: 37 additions & 0 deletions site/src/component/ChangelogModal/ChangelogModal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.changelog-modal {
.modal-content {
background-color: var(--overlay2);
border-radius: var(--border-radius);
padding: 1rem;
}

.modal-header {
align-items: center;
border-bottom: none;
}

h2 {
margin-bottom: 0;
font-size: 1.8rem;
font-weight: 600;
}

.modal-body {
font-size: 1.2rem;
margin: 0;
}

.modal-img {
margin: 1rem 0;
max-width: 70vw;
max-height: 50vh;
object-fit: contain;
}

@media only screen and (max-width: 800px) {
.modal-img {
max-width: 90vw;
max-height: 50vh;
}
}
}
49 changes: 49 additions & 0 deletions site/src/component/ChangelogModal/ChangelogModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { useEffect, useState } from 'react';
import './ChangelogModal.scss';
import Modal from 'react-bootstrap/Modal';

const DESCRIPTION = 'You can now view recently added features to the PeterPortal website, listed in this modal.';
const IMAGE_URL =
'https://media.tenor.com/ufm_0t3ACEAAAAAM/ginger-cat-ginger-cat-eating-then-staring-at-the-camera.gif';
const LAST_UPDATED = '02/27/2024';

const ChangelogModal = () => {
const [showModal, setShowModal] = useState(false);

useEffect(() => {
// display the changelog modal if it is the user's first time seeing it (tracked in local storage)
const lastSeen = localStorage.getItem('changelogSeen');

if (lastSeen !== LAST_UPDATED) {
setShowModal(true);

// mark as seen so it is not displayed after seeing it once
localStorage.setItem('changelogSeen', LAST_UPDATED);
}
}, []);

const closeModal = () => {
setShowModal(false);
};

return (
<div onClick={closeModal}>
<Modal
className="changelog-modal"
show={showModal}
centered
animation={false}
onClick={(e: MouseEvent) => e.stopPropagation()}
>
<Modal.Header closeButton>
<h2>What's New - {new Date().toLocaleString('default', { month: 'long', year: 'numeric' })}</h2>
</Modal.Header>

<p className="modal-body">{DESCRIPTION}</p>
<img className="modal-img" src={IMAGE_URL} />
</Modal>
</div>
);
};

export default ChangelogModal;
2 changes: 1 addition & 1 deletion site/src/pages/RoadmapPage/AddCoursePopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const AddCoursePopup: FC<AddCoursePopupProps> = () => {
);
})}
</Form.Control>
<Form.Control.Feedback type="invalid">Missing qurter</Form.Control.Feedback>
<Form.Control.Feedback type="invalid">Missing quarter</Form.Control.Feedback>
</Form.Group>
)}
<div className="d-flex justify-content-end">
Expand Down
Loading