test window.opwn

This commit is contained in:
HF 2022-08-17 22:52:23 +02:00
parent df223f5932
commit feb5263628
5 changed files with 74 additions and 20 deletions

View File

@ -14,11 +14,18 @@ const UIWin = () => {
const [Content, name] = COMPONENTS[windowType]; const [Content, name] = COMPONENTS[windowType];
return ( return (
<> <div
className="window show"
style={{
width: '100%',
height: '100%',
overflow: 'auto',
}}
>
{(windowType) {(windowType)
? <Content /> ? <Content />
: <h1>Loading</h1>} : <h1>Loading</h1>}
</> </div>
); );
}; };

View File

@ -75,6 +75,32 @@ const Window = ({ id }) => {
dispatch(closeWindow(id)); dispatch(closeWindow(id));
}, [dispatch]); }, [dispatch]);
const {
xPos, yPos,
width, height,
} = position;
const popUp = useCallback((evt) => {
let left;
let top;
try {
left = Math.round(window.top.screenX + xPos);
top = Math.round(window.top.screenY + yPos);
if (Number.isNaN(left) || Number.isNaN(top)) {
throw new Error('NaN');
}
} catch {
left = 0;
top = 0;
}
window.lmao = window.open(
'./win',
'lol',
`popup=yes,width=${width},height=${height},left=${left},top=${top},toolbar=no,status=no,directories=no,menubar=no`,
);
close(evt);
}, [xPos, yPos, width, height]);
useDrag( useDrag(
titleBarRef, titleBarRef,
focus, focus,
@ -117,15 +143,8 @@ const Window = ({ id }) => {
return null; return null;
} }
const { const { title, windowType } = win;
windowType, const { z } = position;
title,
} = win;
const {
xPos, yPos,
width, height,
z,
} = position;
const [Content, name] = COMPONENTS[windowType]; const [Content, name] = COMPONENTS[windowType];
@ -146,17 +165,26 @@ const Window = ({ id }) => {
<h2>{windowTitle}</h2> <h2>{windowTitle}</h2>
<div <div
onClick={close} onClick={close}
className="ModalClose" className="modal-topbtn close"
role="button" role="button"
label="close" label="close"
key="closebtn" key="closebtn"
title={t`Close`} title={t`Close`}
tabIndex={-1} tabIndex={-1}
></div> ></div>
<div
onClick={popUp}
className="modal-topbtn pop"
role="button"
label="close"
key="popbtn"
title={t`PopUp`}
tabIndex={-1}
>G</div>
{(showWindows) && ( {(showWindows) && (
<div <div
onClick={toggleMaximize} onClick={toggleMaximize}
className="ModalRestore" className="modal-topbtn restore"
key="resbtn" key="resbtn"
role="button" role="button"
label="restore" label="restore"
@ -207,6 +235,13 @@ const Window = ({ id }) => {
> >
{windowTitle} {windowTitle}
</span> </span>
<span
className="win-topbtn"
key="pobtn"
onClick={popUp}
>
G
</span>
<span <span
className="win-topbtn" className="win-topbtn"
key="maxbtn" key="maxbtn"

View File

@ -496,5 +496,3 @@ export function parseInterval(interval) {
} }
return (num * factor); return (num * factor);
} }

View File

@ -537,7 +537,13 @@ export default function windows(
showWindows, showWindows,
}; };
} }
return correctPositions(state); const newState = (showWindows === state.showWindows)
? state
: {
...state,
showWindows,
};
return correctPositions(newState);
} }

View File

@ -635,7 +635,7 @@ tr:nth-child(even) {
flex-direction: row; flex-direction: row;
} }
.ModalClose, .ModalRestore { .modal-topbtn {
position: fixed; position: fixed;
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -652,15 +652,19 @@ tr:nth-child(even) {
z-index: 5; z-index: 5;
} }
.ModalClose { .modal-topbtn.close {
right: 14px; right: 14px;
} }
.ModalRestore { .modal-topbtn.restore {
right: 52px; right: 52px;
} }
.ModalClose:hover, .ModalRestore:hover { .modal-topbtn.pop {
right: 90px;
}
.modal-topbtn:hover {
background-color: #e3e3e4; background-color: #e3e3e4;
} }
@ -679,6 +683,10 @@ tr:nth-child(even) {
border-radius: inherit !important; border-radius: inherit !important;
} }
.modal-topbtn.pop {
right: 52px;
}
.modal { .modal {
height: 100%; height: 100%;
width: 100%; width: 100%;