mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-02 05:47:14 +02:00
prettify, sorry for the big ass commit
This commit is contained in:
+18
-18
@@ -6,27 +6,27 @@
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
interface IProps<T> {
|
||||
content: (props: T) => React.ReactElement;
|
||||
id: string;
|
||||
props: T;
|
||||
removePopup: (id: string) => void;
|
||||
content: (props: T) => React.ReactElement;
|
||||
id: string;
|
||||
props: T;
|
||||
removePopup: (id: string) => void;
|
||||
}
|
||||
|
||||
export function Popup<T>(props: IProps<T>): React.ReactElement {
|
||||
function keyDown(event: KeyboardEvent): void {
|
||||
if(event.key === 'Escape') props.removePopup(props.id);
|
||||
}
|
||||
function keyDown(event: KeyboardEvent): void {
|
||||
if (event.key === "Escape") props.removePopup(props.id);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
document.addEventListener('keydown', keyDown);
|
||||
return () => {
|
||||
document.removeEventListener('keydown', keyDown);
|
||||
}
|
||||
});
|
||||
useEffect(() => {
|
||||
document.addEventListener("keydown", keyDown);
|
||||
return () => {
|
||||
document.removeEventListener("keydown", keyDown);
|
||||
};
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={"popup-box-content"} id={`${props.id}-content`}>
|
||||
{React.createElement(props.content, props.props)}
|
||||
</div>
|
||||
)
|
||||
return (
|
||||
<div className={"popup-box-content"} id={`${props.id}-content`}>
|
||||
{React.createElement(props.content, props.props)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user