Skip to content

Commit

Permalink
Merge branch 'master' into fix-navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
js0mmer authored Mar 7, 2024
2 parents 152f1b4 + a979ffb commit 1c400a1
Show file tree
Hide file tree
Showing 14 changed files with 249 additions and 391 deletions.
1 change: 1 addition & 0 deletions site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"react-redux": "^9.0.4",
"react-responsive": "^9.0.2",
"react-router-dom": "^6.18.0",
"react-transition-group": "^4.4.5",
"react-twemoji": "^0.5.0",
"semantic-ui-css": "^2.5.0",
"semantic-ui-react": "^2.1.4",
Expand Down
6 changes: 5 additions & 1 deletion site/src/App.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
button {
color: inherit;
}

.app-body {
display: flex;
height: 92vh;
height: calc(100% - 72px);
overflow: hidden;
}

Expand Down
2 changes: 0 additions & 2 deletions site/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import './style/theme.scss';
import './App.scss';

import AppHeader from './component/AppHeader/AppHeader';
import Footer from './component/Footer/Footer';
import SearchPage from './pages/SearchPage';
import CoursePage from './pages/CoursePage';
import ProfessorPage from './pages/ProfessorPage';
Expand Down Expand Up @@ -106,7 +105,6 @@ export default function App() {
<Route path="/reviews" element={<ReviewsPage />} />
<Route path="*" element={<ErrorPage />} />
</Routes>
<Footer />
</div>
</div>
</ThemeContext.Provider>
Expand Down
98 changes: 9 additions & 89 deletions site/src/component/AppHeader/AppHeader.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#peterportal-logo {
width: 100%;
height: 100%;
width: auto;
height: 32px;
@media (min-width: 800px) {
height: 36px;
}
}

[data-theme='dark'] {
Expand All @@ -27,10 +30,10 @@
position: sticky;
z-index: 300;
width: 100%;
height: 8vh;
height: 72px;
background-color: var(--overlay1);
padding-right: 3vw;
padding-left: 2vw;
padding-left: 16px;
display: flex;
top: 0;

Expand Down Expand Up @@ -58,47 +61,7 @@
align-items: center;
border: none;
background: none;
}

.desktop-toggle {
display: contents;
}

.mobile-toggle {
display: none;
}

.navbar-toggle {
background-color: var(--overlay2);
margin-left: 5vw;
display: flex;
flex-direction: row;
align-items: center;
height: 60%;
border-radius: 1rem;
width: 12vw;

.navbar-toggle-item {
width: 50%;
height: 100%;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
border-radius: 1rem;

a {
color: var(--text);
}
}

.active {
background-color: var(--peterportal-secondary-orange);

a {
color: white;
}
}
padding: 4px;
}

.navbar-logo {
Expand All @@ -110,46 +73,14 @@
right: 0;
margin-left: auto;
margin-right: auto;
width: 7vw;
width: fit-content;
}

@media only screen and (max-width: 800px) {
.beta {
display: none;
}

.desktop-toggle {
display: none;
}

.mobile-toggle {
display: contents;
}

.navbar-toggle {
margin-left: 5vw;
display: flex;
flex-direction: row;
align-items: center;
height: 60%;
border-radius: 1rem;
width: 17vw;

.navbar-toggle-item {
width: 100%;
height: 100%;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
border-radius: 1rem;

a {
font-size: 10px;
}
}
}

.navbar-logo {
display: flex;
flex-direction: row;
Expand All @@ -159,7 +90,6 @@
right: 0;
margin-left: auto;
margin-right: auto;
width: 18vw;
}

.school-term {
Expand All @@ -175,13 +105,3 @@
flex-direction: row;
justify-content: space-between;
}

@media only screen and (max-width: 1300px) {
.navbar {
.navbar-nav {
.navbar-toggle {
width: 20vw;
}
}
}
}
55 changes: 7 additions & 48 deletions site/src/component/AppHeader/AppHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect, FC } from 'react';
import { Icon, Popup, Grid, Label } from 'semantic-ui-react';
import { useLocation, Link } from 'react-router-dom';
import { Link } from 'react-router-dom';
import axios from 'axios';

import { List } from 'react-bootstrap-icons';
Expand All @@ -12,73 +12,32 @@ import './AppHeader.scss';
import { useAppDispatch, useAppSelector } from '../../store/hooks';
import { setSidebarStatus } from '../../store/slices/uiSlice';
import Profile from './Profile';
import { useIsDesktop, useIsMobile } from '../../helpers/util';

const AppHeader: FC = () => {
const dispatch = useAppDispatch();
const sidebarOpen = useAppSelector((state) => state.ui.sidebarOpen);
const location = useLocation();
const [week, setWeek] = useState('');

const splitLocation = location.pathname.split('/');
const coursesActive =
splitLocation[1] === '' ||
(splitLocation.length > 0 && splitLocation[splitLocation.length - 1] == 'courses') ||
(splitLocation.length > 1 && splitLocation[1] == 'course');
const professorsActive =
(splitLocation.length > 0 && splitLocation[splitLocation.length - 1] == 'professors') ||
(splitLocation.length > 1 && splitLocation[1] == 'professor');

useEffect(() => {
// Get the current week data
axios.get<WeekData>('/api/schedule/api/currentWeek').then((res) => {
setWeek(res.data.display);
/** @todo make this less code-smelly */
setWeek(res.data.display.split(' • ')[0]);
});
}, []);

const toggleMenu = () => {
dispatch(setSidebarStatus(!sidebarOpen));
};

const isDesktop = useIsDesktop();
const isMobile = useIsMobile();

return (
<header className="navbar">
<div className="navbar-nav">
<div className="navbar-left">
{/* Hamburger Menu */}
{isMobile && (
<button className="navbar-menu" onClick={toggleMenu}>
<List className="navbar-menu-icon" size={'3vh'} />
</button>
)}

{/* Toggle Course and Professor */}
{(coursesActive || professorsActive) && (
<div className="navbar-toggle">
<div className="desktop-toggle">
<div className={`navbar-toggle-item ${coursesActive ? 'active' : ''}`}>
<Link to={'/search/courses'}>Courses</Link>
</div>
<div className={`navbar-toggle-item ${professorsActive ? 'active' : ''}`}>
<Link to={'/search/professors'}>Professors</Link>
</div>
</div>
<div className="mobile-toggle">
{coursesActive === true && (
<div className={`navbar-toggle-item active`}>
<Link to={'/search/professors'}>Professors</Link>
</div>
)}
{professorsActive === true && (
<div className={`navbar-toggle-item active`}>
<Link to={'/search/courses'}>Courses</Link>
</div>
)}
</div>
</div>
)}
<button className="navbar-menu" onClick={toggleMenu}>
<List className="navbar-menu-icon" size="32px" />
</button>
</div>

{/* Logo */}
Expand Down Expand Up @@ -142,7 +101,7 @@ const AppHeader: FC = () => {
<p className="school-term" style={{ height: '1rem', lineHeight: '1rem' }}>
{week}
</p>
{isDesktop && <Profile />}
<Profile />
</div>
</div>
</header>
Expand Down
42 changes: 25 additions & 17 deletions site/src/component/AppHeader/Profile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,50 +23,66 @@
background-color: var(--overlay1);
border-radius: var(--border-radius);
border: 1px solid var(--background);
width: 350px;
width: 310px;
max-width: 100vw;
box-shadow: 0 0 12px rgba(196, 198, 209, 0.24);

.arrow::before {
border-bottom-color: var(--background);
}

h1 {
font-size: 1.5em;
font-size: 18px;
overflow: hidden;
text-overflow: ellipsis;
font-weight: bold;
}

h2 {
font-size: 1em;
font-size: 14px;
color: var(--text-light);
overflow: hidden;
text-overflow: ellipsis;
}
}
[data-theme='dark'] {
#profile-popover {
box-shadow: 2px 4px 24px rgba(0, 0, 0, 0.24);
}
}

.profile-popover__header {
display: flex;
min-height: 6vh;
height: 50px;
margin-bottom: 0.75em;

span {
div {
display: flex;
flex-direction: column;
justify-content: center;
white-space: nowrap;
overflow: hidden;
}

img {
margin-right: 0.75em;
height: 6vh;
margin-right: 12px;
height: 50px;
border-radius: 100%;
}

button {
border: none;
background: none;
font-size: 1.5em;
font-size: 20px;
line-height: 1em;
padding: 0 0.5em;
border-radius: var(--border-radius);
display: flex;
align-items: center;
gap: 8px;
span {
font-size: 18px;
}
}

button:hover {
Expand All @@ -79,6 +95,7 @@
list-style: none;
padding: 0;
margin: 0;
font-size: 16px;
}

li div {
Expand All @@ -94,15 +111,6 @@
background: none;
width: 100%;
}

.divider-before::before {
display: block;
content: '';
width: 100%;
height: 1px;
background-color: var(--overlay2);
margin: 0.25em 0;
}
}

.profile-popover__link,
Expand Down
Loading

0 comments on commit 1c400a1

Please sign in to comment.