Added ability for app to close its window
This commit is contained in:
parent
cc113f15c8
commit
e580ea6214
2 changed files with 8 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ import { HeaderMenu } from "../.common/HeaderMenu.jsx";
|
|||
* @param {Object} props
|
||||
* @param {VirtualFile} props.file
|
||||
*/
|
||||
export function TextEditor({ file, setTitle }) {
|
||||
export function TextEditor({ file, setTitle, close }) {
|
||||
const [currentFile, setCurrentFile] = useState(file);
|
||||
const [content, setContent] = useState(file?.content);
|
||||
const [unsavedChanges, setUnsavedChanges] = useState(false);
|
||||
|
|
@ -62,6 +62,7 @@ export function TextEditor({ file, setTitle }) {
|
|||
onNew={newText}
|
||||
onSave={saveText}
|
||||
onSaveAs={saveTextAs}
|
||||
onExit={() => { close(); }}
|
||||
/>
|
||||
<textarea
|
||||
className={styles.View}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ export function Window({ id, app, size, position, focused = false, onInteract, o
|
|||
resizeObserver.observe(document.getElementById("root"));
|
||||
});
|
||||
|
||||
const close = () => {
|
||||
windowsManager.close(id);
|
||||
};
|
||||
|
||||
const classNames = [styles["Window-container"]];
|
||||
if (maximized)
|
||||
classNames.push(styles.Maximized);
|
||||
|
|
@ -83,12 +87,12 @@ export function Window({ id, app, size, position, focused = false, onInteract, o
|
|||
<button onClick={() => setMaximized(!maximized)}>
|
||||
<FontAwesomeIcon icon={faSquare}/>
|
||||
</button>
|
||||
<button onClick={() => { windowsManager.close(id); }}>
|
||||
<button onClick={close}>
|
||||
<FontAwesomeIcon icon={faXmark}/>
|
||||
</button>
|
||||
</div>
|
||||
<div className={styles["Window-content"]}>
|
||||
<app.WindowContent {...options} setTitle={setTitle}/>
|
||||
<app.WindowContent {...options} setTitle={setTitle} close={close}/>
|
||||
</div>
|
||||
</div>
|
||||
</Draggable>
|
||||
|
|
|
|||
Loading…
Reference in a new issue