Skip to content

Commit

Permalink
add modal close
Browse files Browse the repository at this point in the history
  • Loading branch information
JensRavens committed Jan 14, 2025
1 parent 0e865b7 commit 6c82d03
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/frontend/components/modal/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions app/frontend/components/modal/modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ $animation_time: 0.35s;
justify-content: flex-end;
overflow: scroll;

&__close {
position: absolute;
z-index: 999;
top: 10px;
right: 10px;
background-image: url(./close.svg);
background-size: contain;
background-repeat: no-repeat;
display: block;
width: 12px;
height: 12px;
cursor: pointer;
}

&__background {
position: absolute;
top: 0;
Expand Down
7 changes: 5 additions & 2 deletions app/frontend/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface ModalProps {
}

function Modal(props: ModalProps): JSX.Element {
const { children } = props;
const { children, onClose } = props;

const [open, setOpen] = useState(false);

Expand All @@ -43,7 +43,10 @@ function Modal(props: ModalProps): JSX.Element {
'modal__background--fade-out': !props.open,
})}
/>
<div className="modal__content">{children}</div>
<div className="modal__content">
<div className="modal__close" onClick={onClose} />
{children}
</div>
</div>
);
}
Expand Down

0 comments on commit 6c82d03

Please sign in to comment.