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

added cmd+shift+x / ctrl+shift+x as a deletion key combination #866

Merged
merged 4 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions client/src/components/StyledDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Dialog, DialogTitle, DialogContent, DialogActions, Button, IconButton } from '@mui/material';
import { Close as CloseIcon } from '@mui/icons-material';
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, IconButton } from '@mui/material';
import { styled } from '@mui/system';
import React from 'react';

const ContentContainer = styled('div')`
display: flex;
Expand Down Expand Up @@ -40,8 +40,8 @@ export const StyledDialogTitle = styled(DialogTitle)`
`;

const CustomCloseIconButton = styled(IconButton)`
width: 40px;
height: 40px;
width: 40px;
height: 40px;
border-radius: 8px;
`;

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/controls/CourseSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ const CourseSelect: React.FC<CourseSelectProps> = ({ assignedColors, handleSelec

// create a new fuse instance with the searchOptionsList after filtering by faculty
// so that it allows for searching within the faculty's options
let fuzzy = new Fuse<CourseOverview>(searchOptionsList, searchOptions);
const fuzzy = new Fuse<CourseOverview>(searchOptionsList, searchOptions);

const fuzzyResults = fuzzy.search(query).map((result) => result.item);

Expand Down
12 changes: 2 additions & 10 deletions client/src/components/controls/History.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { Close, Delete, Redo, Undo } from '@mui/icons-material';
import { Button, Dialog, IconButton, Tooltip } from '@mui/material';
import { Delete, Redo, Undo } from '@mui/icons-material';
import { IconButton, Tooltip } from '@mui/material';
import React, { useContext, useEffect, useRef, useState } from 'react';

import { AppContext } from '../../context/AppContext';
import { CourseContext } from '../../context/CourseContext';
import { CourseData, CreatedEvents, DisplayTimetablesMap, SelectedClasses } from '../../interfaces/Periods';
import {
StyledCloseIcon,
StyledDialogButtons,
StyledDialogContent,
StyledDialogTitle,
StyledDialogTitleFont,
StyledTitleContainer,
} from '../../styles/ControlStyles';
import {
ActionsPointer,
areIdenticalTimetables,
Expand Down
22 changes: 7 additions & 15 deletions client/src/components/sidebar/DarkModeButton.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {
NightsStay as DarkModeIcon,
LightMode as LightModeIcon,
} from '@mui/icons-material';
import { LightMode as LightModeIcon, NightsStay as DarkModeIcon } 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';
import { DarkModeButtonProps } from '../../interfaces/PropTypes';

const ToggleDarkModeButton = styled(IconButton)`
display: flex;
Expand All @@ -21,25 +18,20 @@ const IndividualComponentTypography = styled(Typography)<{ collapsed: boolean }>
font-size: 16px;
`;

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

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

return (
<>
<Tooltip title={collapsed ? (isDarkMode ? "Light Mode" : "Dark Mode") : ''} placement="right">
<Tooltip title={collapsed ? (isDarkMode ? 'Light Mode' : 'Dark Mode') : ''} placement="right">
<ToggleDarkModeButton color="inherit" onClick={toggleDarkMode}>
{isDarkMode ? (<LightModeIcon />) : (<DarkModeIcon />)}
{isDarkMode ? <LightModeIcon /> : <DarkModeIcon />}
<IndividualComponentTypography collapsed={collapsed}>
{collapsed ? '' : (isDarkMode ? "Change to Light Mode" : "Change to Dark Mode")}
{collapsed ? '' : isDarkMode ? 'Change to Light Mode' : 'Change to Dark Mode'}
</IndividualComponentTypography>
</ToggleDarkModeButton>
</Tooltip>
Expand Down
5 changes: 1 addition & 4 deletions client/src/components/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CalendarMonth, Description, Group, Info, Security, Settings as SettingsIcon } from '@mui/icons-material';
import { AppBar, AppBarProps, Divider, Typography } from '@mui/material';

import { styled } from '@mui/system';
import React, { useEffect, useRef, useState } from 'react';

Expand All @@ -10,14 +9,12 @@ import About from './About';
import Changelog from './Changelog';
import CollapseButton from './CollapseButton';
import CustomModal from './CustomModal';
import DarkModeButton from './DarkModeButton';
import Privacy from './Privacy';
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;
margin-right: 12.5px;
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/sidebar/UserAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { useEffect, useState } from 'react';
import { AccountCircle, LoginRounded, LogoutRounded } from '@mui/icons-material';
import { Button, Dialog, IconButton, Tooltip } from '@mui/material';
import { Button, IconButton, Tooltip } from '@mui/material';
import { styled } from '@mui/system';
import React, { useEffect, useState } from 'react';

import { API_URL } from '../../api/config';
import StyledDialog from '../StyledDialog';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const TimetableTabContextMenu: React.FC<TimetableTabContextMenuProps> = ({ ancho

const isMacOS = navigator.userAgent.indexOf('Mac') != -1;

const deleteTimetabletip = isMacOS ? 'Delete Tab (Cmd+Delete)' : 'Delete Tab (Ctrl+Backspace)';
const deleteTimetabletip = isMacOS ? 'Delete Tab (Cmd+Shift+x)' : 'Delete Tab (Ctrl+Shift+x)';

const [renameOpen, setRenameOpen] = useState<boolean>(false);
const [renamedString, setRenamedString] = useState<string>('');
Expand Down Expand Up @@ -244,11 +244,11 @@ const TimetableTabContextMenu: React.FC<TimetableTabContextMenuProps> = ({ ancho
// Hotkey for deleting timetables
useEffect(() => {
const handleDeletePopupShortcut = (event: KeyboardEvent) => {
// Ctrl+Backspace on Windows or Cmd+Delete on Mac deletes the selected timetable
if ((!isMacOS && event.ctrlKey) || (isMacOS && event.metaKey)) {
if (event.key === 'Backspace' && !renameOpen) {
setDeleteOpen(true);
}
// Ctrl+Shift+x on Windows or Cmd+Shift+x on Mac deletes the selected timetable
const isDeleteShortcut =
((isMacOS && event.metaKey) || (!isMacOS && event.ctrlKey)) && event.shiftKey && event.key === 'x';
if (isDeleteShortcut && !renameOpen) {
setDeleteOpen(true);
}
};

Expand Down Expand Up @@ -413,6 +413,7 @@ const TimetableTabContextMenu: React.FC<TimetableTabContextMenuProps> = ({ ancho
title="Confirm Deletion"
content="Are you sure you want to delete this current timetable?"
confirmButtonText="Delete"
confirmButtonId="confirm-delete-button"
/>
{/* Restore deleted timetable Alert */}
<StyledSnackbar
Expand Down
2 changes: 1 addition & 1 deletion client/src/styles/ControlStyles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, DialogContent, DialogTitle, ListItem, Typography } from '@mui/material';
import { Close } from '@mui/icons-material';
import { Box, DialogContent, DialogTitle, ListItem, Typography } from '@mui/material';
import { styled } from '@mui/system';

export const StyledButtonText = styled(Box)`
Expand Down
Loading