Skip to content

Commit

Permalink
Merge branch 'staging' of github.com:devsoc-unsw/notangles into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasmine Tran committed Jul 8, 2024
2 parents 8d7bb4d + dd38807 commit a9a1c4b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 5 deletions.
50 changes: 50 additions & 0 deletions client/src/components/sidebar/DarkModeButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {
NightsStay as DarkModeIcon,
LightMode as LightModeIcon,
} from '@mui/icons-material';
import { IconButton, Tooltip, Typography } from '@mui/material';
import { styled } from '@mui/system';
import React, { useContext } from 'react';

import { DarkModeButtonProps } from '../../interfaces/PropTypes';
import { AppContext } from '../../context/AppContext';

const ToggleDarkModeButton = styled(IconButton)`
display: flex;
border-radius: 8px;
justify-content: flex-between;
padding: 12px 12px 12px 12px;
`;

const IndividualComponentTypography = styled(Typography)<{ collapsed: boolean }>`
padding-left: ${(props) => (props.collapsed ? '0px' : '12px')};
font-size: 16px;
`;

const DarkModeButton: React.FC<DarkModeButtonProps> = ({
collapsed,
}) => {
const {
isDarkMode,
setIsDarkMode,
} = useContext(AppContext);

const toggleDarkMode = () => {
setIsDarkMode(!isDarkMode);
};

return (
<>
<Tooltip title={collapsed ? (isDarkMode ? "Dark Mode" : "Light Mode") : ''} placement="right">
<ToggleDarkModeButton color="inherit" onClick={toggleDarkMode}>
{isDarkMode ? (<LightModeIcon />) : (<DarkModeIcon />)}
<IndividualComponentTypography collapsed={collapsed}>
{collapsed ? '' : (isDarkMode ? "Change to Light Mode" : "Change to Dark Mode")}
</IndividualComponentTypography>
</ToggleDarkModeButton>
</Tooltip>
</>
);
};

export default DarkModeButton;
3 changes: 0 additions & 3 deletions client/src/components/sidebar/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const SettingText = styled('div')`

const Settings: React.FC = () => {
const {
isDarkMode,
setIsDarkMode,
isSquareEdges,
setIsSquareEdges,
is12HourMode,
Expand All @@ -35,7 +33,6 @@ const Settings: React.FC = () => {
} = useContext(AppContext);

const settingsToggles: { state: boolean; setter: (mode: boolean) => void; desc: string }[] = [
{ state: isDarkMode, setter: setIsDarkMode, desc: 'Dark mode' },
{ state: isSquareEdges, setter: setIsSquareEdges, desc: 'Square corners on classes' },
{ state: is12HourMode, setter: setIs12HourMode, desc: '12-hour time' },
{ state: isShowOnlyOpenClasses, setter: setisShowOnlyOpenClasses, desc: 'Show only open classes' },
Expand Down
7 changes: 6 additions & 1 deletion client/src/components/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Group,
CalendarMonth,
} from '@mui/icons-material';
import { AppBar, Typography, AppBarProps, Divider, Button } from '@mui/material';
import { AppBar, Typography, AppBarProps, Divider } from '@mui/material';
import { styled } from '@mui/system';
import React, { useEffect, useRef, useState } from 'react';

Expand All @@ -21,6 +21,7 @@ import Settings from './Settings';
import TermSelect from './TermSelect';
import UserAccount from './UserAccount';
import { uniqueId } from 'lodash-es';
import DarkModeButton from './DarkModeButton';

const LogoImg = styled('img')`
height: 46px;
Expand Down Expand Up @@ -84,6 +85,7 @@ const SidebarFooter = styled('div')`
display: flex;
flex-direction: column;
padding: 10px 16px 20px 16px;
gap: 8px;
`;
const SidebarFooterText = styled('div')`
display: flex;
Expand Down Expand Up @@ -211,6 +213,9 @@ const Sidebar: React.FC = () => {
</NavComponentsContainer>
</SideBarContainer>
<SidebarFooter>
<DarkModeButton
collapsed={collapsed}
/>
{/* TODO: dummy logic - to be replaced */}
<UserAccount collapsed={collapsed} />
{!collapsed ? (
Expand Down
4 changes: 4 additions & 0 deletions client/src/interfaces/PropTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export interface CourseContextProviderProps {
children: ReactNode;
}

export interface DarkModeButtonProps {
collapsed: boolean;
}

export interface CustomModalProps {
title: string;
toolTipTitle: string;
Expand Down
3 changes: 2 additions & 1 deletion client/team.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"Jordan Benjamin",
"Nikki Qin",
"Lucy Chhuo",
"Sohum Shah"
"Sohum Shah",
"Dylan Zhang"
]
}

0 comments on commit a9a1c4b

Please sign in to comment.