From 60a5e5ba30d71cab3495961c4c6bffcc564ff07c Mon Sep 17 00:00:00 2001 From: Prozilla Date: Thu, 10 Aug 2023 13:27:09 +0200 Subject: [PATCH] Updated window rendering --- package-lock.json | 12 ------ package.json | 30 +++++++++----- .../applications/.templates/WebView.jsx | 40 +++++++++++++++++-- .../.templates/WebView.module.css | 8 ++++ src/components/windows/Window.jsx | 30 +++++++++----- src/components/windows/WindowsView.jsx | 12 ++++-- src/features/applications/applications.js | 2 +- 7 files changed, 94 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index 40714b3..11c12ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,6 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-draggable": "^4.4.5", - "react-iframe": "^1.8.5", "react-scripts": "5.0.1", "react-svg": "^16.1.18", "web-vitals": "^2.1.4" @@ -14853,17 +14852,6 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" }, - "node_modules/react-iframe": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/react-iframe/-/react-iframe-1.8.5.tgz", - "integrity": "sha512-F4cQJGs3ydaG6fJWfuz9yLwOU0Trzl6kttXuUG+vYwosH8enOOFxZWEDQCSbNVO8ayjfYZeqLxEvdvcsSy4GvA==", - "dependencies": { - "object-assign": "^4.1.1" - }, - "peerDependencies": { - "react": ">=16.x.x" - } - }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", diff --git a/package.json b/package.json index 974ecfc..c1249a3 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-draggable": "^4.4.5", - "react-iframe": "^1.8.5", "react-scripts": "5.0.1", "react-svg": "^16.1.18", "web-vitals": "^2.1.4" @@ -40,20 +39,31 @@ "jsdoc" ], "rules": { - "indent": ["error", "tab", { "SwitchCase": 1 }], + "indent": [ + "error", + "tab", + { + "SwitchCase": 1 + } + ], "semi": "error", "no-var": "error", "prefer-const": "error", - "quotes": ["error", "double"], - + "quotes": [ + "error", + "double" + ], "jsdoc/no-undefined-types": "warn", "jsdoc/require-param": "warn", "jsdoc/check-tag-names": "warn", - "jsdoc/check-types": ["warn", {}], + "jsdoc/check-types": [ + "warn", + {} + ], "jsdoc/check-values": "warn", "jsdoc/empty-tags": "warn", "jsdoc/check-param-names": "warn", - "jsdoc/check-property-names": "warn", + "jsdoc/check-property-names": "warn", "jsdoc/check-access": "warn", "jsdoc/check-alignment": "warn", "jsdoc/multiline-blocks": "warn", @@ -63,10 +73,10 @@ "settings": { "jsdoc": { "preferredTypes": { - "Object":"object", - "object.<>":"Object<>", - "Object.<>":"Object<>", - "object<>":"Object<>" + "Object": "object", + "object.<>": "Object<>", + "Object.<>": "Object<>", + "object<>": "Object<>" } } } diff --git a/src/components/applications/.templates/WebView.jsx b/src/components/applications/.templates/WebView.jsx index f7c8c6f..f39faf9 100644 --- a/src/components/applications/.templates/WebView.jsx +++ b/src/components/applications/.templates/WebView.jsx @@ -1,13 +1,47 @@ -import Iframe from "react-iframe"; +import { useCallback, useEffect, useState } from "react"; import styles from "./WebView.module.css"; /** * @param {Object} props * @param {String} props.source - * @returns */ export function WebView(props) { + const [hovered, setHovered] = useState(false); + + const { source, focus } = props; + + useEffect(() => { + window.focus(); + + const onBlur = (event) => { + if (hovered) { + focus(event); + } + }; + + window.addEventListener("blur", onBlur); + + return () => { + window.removeEventListener("blur", onBlur); + }; + }, [hovered]); + + const onMouseOver = () => { + setHovered(true); + }; + + const onMouseOut = () => { + window.focus(); + setHovered(false); + }; + return ( -