From d20c1f6b800ffa737e87b932f268a71f6c3ab1f7 Mon Sep 17 00:00:00 2001 From: Prozilla Date: Mon, 18 Dec 2023 11:03:51 +0100 Subject: [PATCH] Added browser app --- public/config/applications.xml | 3 + public/config/taskbar.xml | 2 +- .../applications/.templates/WebView.jsx | 15 ++- .../.templates/WebView.module.css | 1 + .../applications/browser/Browser.jsx | 113 ++++++++++++++++++ .../applications/browser/Browser.module.css | 92 ++++++++++++++ .../file-explorer/FileExplorer.jsx | 12 +- src/components/desktop/Desktop.module.css | 1 + src/components/windows/WindowView.jsx | 13 +- src/components/windows/WindowsView.jsx | 13 ++ src/constants/applications/browser.js | 2 + src/features/applications/applications.js | 4 + src/features/math/vector2.js | 9 ++ src/features/settings/settingsManager.js | 3 +- src/features/utils/browser.js | 13 ++ src/features/virtual-drive/defaultData.js | 2 + src/features/windows/windows.js | 12 ++ src/hooks/utils/history.js | 2 - src/styles/global.css | 3 +- 19 files changed, 295 insertions(+), 20 deletions(-) create mode 100644 public/config/applications.xml create mode 100644 src/components/applications/browser/Browser.jsx create mode 100644 src/components/applications/browser/Browser.module.css create mode 100644 src/constants/applications/browser.js diff --git a/public/config/applications.xml b/public/config/applications.xml new file mode 100644 index 0000000..b4d4b3b --- /dev/null +++ b/public/config/applications.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/public/config/taskbar.xml b/public/config/taskbar.xml index 808f8a0..cc9e8b1 100644 --- a/public/config/taskbar.xml +++ b/public/config/taskbar.xml @@ -1,3 +1,3 @@ - file-explorer,terminal,settings,media-viewer,text-editor,wordle,balls,minesweeper + file-explorer,terminal,settings,media-viewer,browser,text-editor,wordle,balls,minesweeper \ No newline at end of file diff --git a/src/components/applications/.templates/WebView.jsx b/src/components/applications/.templates/WebView.jsx index f39faf9..b722cb0 100644 --- a/src/components/applications/.templates/WebView.jsx +++ b/src/components/applications/.templates/WebView.jsx @@ -1,21 +1,19 @@ -import { useCallback, useEffect, useState } from "react"; +import { forwardRef, useEffect, useState } from "react"; import styles from "./WebView.module.css"; /** * @param {Object} props * @param {String} props.source */ -export function WebView(props) { +export const WebView = forwardRef(({ source, focus, ...props }, ref) => { const [hovered, setHovered] = useState(false); - const { source, focus } = props; - useEffect(() => { window.focus(); const onBlur = (event) => { if (hovered) { - focus(event); + focus?.(event); } }; @@ -38,10 +36,15 @@ export function WebView(props) { return (