Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

give close button more powers #221

Merged
merged 2 commits into from
Dec 16, 2022
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
33 changes: 28 additions & 5 deletions frontend/src/components/Close.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import { Link } from "react-router-dom";
import { useNavigate } from "react-router-dom";
import { ReactComponent as CloseIcon } from "../images/icons/close.svg"

export default function Close() {
return (<Link to="/" className="h-10 w-10 min-w-10 text-white active:text-half-faint" >
<CloseIcon />
</Link>)
type Props = {
onClose?: () => void,
to?: string
}

export default function Close({ onClose, to }: Props) {

let navigate = useNavigate();

function handleClose() {
if (onClose) {
onClose();
}

// onClose could be a cleanup function
// So we still might want to navigate after
if (to) {
navigate(to);
} else {
navigate("/");
}
}
return (
<div className="h-10 w-10 min-w-10 text-white active:text-half-faint" onClick={handleClose}>
<CloseIcon />
</div>
)
}
2 changes: 1 addition & 1 deletion frontend/src/routes/ConnectPeer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function ConnectPeer() {
<>
<header className='p-8 flex justify-between items-center'>
<PageTitle title="Connect to peer" theme="red"></PageTitle>
<Close />
<Close to="/manager/peers" />
</header>

<ScreenMain>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routes/OpenChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function OpenChannel() {
<>
<header className='p-8 flex justify-between items-center'>
<PageTitle title="Open Channel" theme="blue"></PageTitle>
<Close />
<Close to="/manager/channels" />
</header>

<ScreenMain>
Expand Down