Skip to content

Commit

Permalink
chore: remove unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ZendeAditya committed Jan 12, 2025
1 parent 3f71ebb commit 6cb306c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
22 changes: 21 additions & 1 deletion src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode } from 'react';
import React, { ReactNode, useEffect } from 'react';
import styles from '@/components/Modal/modal.module.scss';

interface ModalType {
Expand All @@ -8,6 +8,20 @@ interface ModalType {
}

export default function Modal(props: ModalType) {
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
props.toggle();
}
};

document.addEventListener('keydown', handleKeyDown);

return () => {
document.removeEventListener('keydown', handleKeyDown);
};
}, [props]);

return (
<>
{props.isOpen && (
Expand All @@ -21,6 +35,12 @@ export default function Modal(props: ModalType) {
className={styles.modalBox}
data-testid="modal-box"
>
<button
className={styles.closeButton}
onClick={props.toggle}
>
close
</button>
{props.children}
</div>
</div>
Expand Down
14 changes: 14 additions & 0 deletions src/components/Modal/modal.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,17 @@
border-radius: 1rem;
animation: fadeIn ease-in-out 250ms;
}

.closeButton {
position: absolute;
top: 2%;
right: 10px;
cursor: pointer;
z-index: 999;
padding: 4px 25px;
border-radius: 3px;
&:hover {
background: #041187;
color: white;
}
}
2 changes: 0 additions & 2 deletions src/components/taskDetails/TaskUpdateModal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React from 'react';
import ProgressContainer from '../tasks/card/progressContainer';
import Modal from '../Modal';
import getCurrentDate from '@/utils/getLatestDate';
import { questions } from '@/constants/ProgressUpdates';
import ProgressForm from '../ProgressForm/ProgressForm';
import task from '@/interfaces/task.type';
import { useRouter } from 'next/router';

type Props = {
isOpen: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/components/taskDetails/task-details.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ $base-unit: 4px;
}

.taskUpdateModal {
position: relative;
min-width: fit-content;
max-width: 796px;
width: 80vw;
Expand Down

0 comments on commit 6cb306c

Please sign in to comment.