@prozilla-os/core 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +1 -0
- package/package.json +43 -0
- package/src/components/_utils/button/Button.module.css +25 -0
- package/src/components/_utils/button/Button.tsx +48 -0
- package/src/components/_utils/directory-list/DirectoryList.module.css +70 -0
- package/src/components/_utils/directory-list/DirectoryList.tsx +203 -0
- package/src/components/_utils/directory-list/ImagePreview.module.css +19 -0
- package/src/components/_utils/directory-list/ImagePreview.tsx +33 -0
- package/src/components/_utils/dropdown-button/DropdownButton.module.css +60 -0
- package/src/components/_utils/dropdown-button/DropdownButton.tsx +40 -0
- package/src/components/_utils/header-menu/HeaderMenu.module.css +8 -0
- package/src/components/_utils/header-menu/HeaderMenu.tsx +15 -0
- package/src/components/_utils/index.ts +10 -0
- package/src/components/_utils/interactable/Interactable.tsx +42 -0
- package/src/components/_utils/progress-bar/ProgressBar.module.css +20 -0
- package/src/components/_utils/progress-bar/ProgressBar.tsx +22 -0
- package/src/components/_utils/web-view/WebView.module.css +15 -0
- package/src/components/_utils/web-view/WebView.tsx +47 -0
- package/src/components/actions/Actions.module.css +281 -0
- package/src/components/actions/Actions.tsx +108 -0
- package/src/components/actions/actions/ClickAction.tsx +30 -0
- package/src/components/actions/actions/Divider.tsx +5 -0
- package/src/components/actions/actions/DropdownAction.tsx +50 -0
- package/src/components/actions/actions/RadioAction.tsx +50 -0
- package/src/components/actions/actions/TextDisplay.tsx +12 -0
- package/src/components/actions/actions/ToggleAction.tsx +31 -0
- package/src/components/actions/index.ts +7 -0
- package/src/components/desktop/Desktop.module.css +49 -0
- package/src/components/desktop/Desktop.tsx +199 -0
- package/src/components/index.ts +10 -0
- package/src/components/modals/ModalView.module.css +14 -0
- package/src/components/modals/ModalView.tsx +54 -0
- package/src/components/modals/ModalsView.module.css +4 -0
- package/src/components/modals/ModalsView.tsx +32 -0
- package/src/components/modals/_utils/WindowedModal.module.css +92 -0
- package/src/components/modals/_utils/WindowedModal.tsx +71 -0
- package/src/components/modals/dialog-box/DialogBox.module.css +27 -0
- package/src/components/modals/dialog-box/DialogBox.tsx +26 -0
- package/src/components/modals/file-selector/FileSelector.module.css +25 -0
- package/src/components/modals/file-selector/FileSelector.tsx +77 -0
- package/src/components/modals/index.ts +7 -0
- package/src/components/modals/share/Option.tsx +23 -0
- package/src/components/modals/share/Share.module.css +153 -0
- package/src/components/modals/share/Share.tsx +197 -0
- package/src/components/prozilla-os/ProzillaOS.module.css +14 -0
- package/src/components/prozilla-os/ProzillaOS.tsx +76 -0
- package/src/components/taskbar/Taskbar.module.css +218 -0
- package/src/components/taskbar/Taskbar.tsx +193 -0
- package/src/components/taskbar/app-icon/AppIcon.module.css +62 -0
- package/src/components/taskbar/app-icon/AppIcon.tsx +76 -0
- package/src/components/taskbar/indicators/Battery.module.css +32 -0
- package/src/components/taskbar/indicators/Battery.tsx +114 -0
- package/src/components/taskbar/indicators/Calendar.module.css +24 -0
- package/src/components/taskbar/indicators/Calendar.tsx +67 -0
- package/src/components/taskbar/indicators/Network.module.css +17 -0
- package/src/components/taskbar/indicators/Network.tsx +38 -0
- package/src/components/taskbar/indicators/Volume.module.css +17 -0
- package/src/components/taskbar/indicators/Volume.tsx +38 -0
- package/src/components/taskbar/indicators/index.ts +4 -0
- package/src/components/taskbar/menus/AppList.module.css +33 -0
- package/src/components/taskbar/menus/HomeMenu.module.css +47 -0
- package/src/components/taskbar/menus/HomeMenu.tsx +118 -0
- package/src/components/taskbar/menus/SearchMenu.module.css +68 -0
- package/src/components/taskbar/menus/SearchMenu.tsx +100 -0
- package/src/components/taskbar/menus/UtilMenu.module.css +41 -0
- package/src/components/taskbar/menus/UtilMenu.tsx +23 -0
- package/src/components/windows/WindowFallbackView.tsx +38 -0
- package/src/components/windows/WindowView.module.css +152 -0
- package/src/components/windows/WindowView.tsx +233 -0
- package/src/components/windows/WindowsView.tsx +89 -0
- package/src/constants/index.ts +3 -0
- package/src/constants/modals.const.ts +3 -0
- package/src/constants/themes.const.ts +8 -0
- package/src/constants/utils.const.ts +19 -0
- package/src/constants/virtualDrive.const.ts +20 -0
- package/src/features/_utils/array.utils.ts +14 -0
- package/src/features/_utils/browser.utils.ts +111 -0
- package/src/features/_utils/date.utils.ts +90 -0
- package/src/features/_utils/event.utils.ts +39 -0
- package/src/features/_utils/index.ts +8 -0
- package/src/features/_utils/math.utils.ts +18 -0
- package/src/features/_utils/number.utils.ts +3 -0
- package/src/features/_utils/string.utils.ts +31 -0
- package/src/features/_utils/time.utils.ts +13 -0
- package/src/features/actions/actionsManager.ts +7 -0
- package/src/features/index.ts +12 -0
- package/src/features/math/vector2.ts +75 -0
- package/src/features/modals/modal.ts +74 -0
- package/src/features/modals/modalsManager.ts +72 -0
- package/src/features/settings/settings.ts +109 -0
- package/src/features/settings/settingsManager.ts +31 -0
- package/src/features/storage/storageManager.ts +35 -0
- package/src/features/system/configs/app.tsx +60 -0
- package/src/features/system/configs/appsConfig.ts +60 -0
- package/src/features/system/configs/desktopConfig.ts +46 -0
- package/src/features/system/configs/index.ts +9 -0
- package/src/features/system/configs/miscConfig.ts +19 -0
- package/src/features/system/configs/modalsConfig.ts +28 -0
- package/src/features/system/configs/taskbarConfig.ts +19 -0
- package/src/features/system/configs/trackingConfig.ts +24 -0
- package/src/features/system/configs/virtualDriveConfig.ts +39 -0
- package/src/features/system/configs/windowsConfig.ts +34 -0
- package/src/features/system/systemManager.ts +68 -0
- package/src/features/tracking/trackingManager.ts +40 -0
- package/src/features/virtual-drive/file/index.ts +2 -0
- package/src/features/virtual-drive/file/virtualFile.ts +197 -0
- package/src/features/virtual-drive/file/virtualFileLink.ts +111 -0
- package/src/features/virtual-drive/folder/index.ts +2 -0
- package/src/features/virtual-drive/folder/virtualFolder.ts +388 -0
- package/src/features/virtual-drive/folder/virtualFolderLink.ts +148 -0
- package/src/features/virtual-drive/index.ts +3 -0
- package/src/features/virtual-drive/root/defaultData.ts +140 -0
- package/src/features/virtual-drive/root/virtualRoot.ts +244 -0
- package/src/features/virtual-drive/virtualBase.ts +191 -0
- package/src/features/windows/windowsManager.ts +244 -0
- package/src/features/z-index/zIndexGroup.ts +40 -0
- package/src/features/z-index/zIndexManager.ts +46 -0
- package/src/hooks/_utils/history.ts +50 -0
- package/src/hooks/_utils/index.ts +6 -0
- package/src/hooks/_utils/keyboard.ts +111 -0
- package/src/hooks/_utils/mouse.ts +32 -0
- package/src/hooks/_utils/outsideClick.tsx +33 -0
- package/src/hooks/_utils/screen.ts +61 -0
- package/src/hooks/_utils/scrollWithShadows.ts +138 -0
- package/src/hooks/apps/appFolder.ts +30 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/modals/alert.tsx +34 -0
- package/src/hooks/modals/contextMenu.tsx +47 -0
- package/src/hooks/modals/index.ts +4 -0
- package/src/hooks/modals/modalsContext.ts +10 -0
- package/src/hooks/modals/modalsManagerContext.ts +10 -0
- package/src/hooks/modals/modalsManagerProvider.tsx +16 -0
- package/src/hooks/modals/modalsProvider.tsx +20 -0
- package/src/hooks/modals/windowedModal.ts +47 -0
- package/src/hooks/settings/settingsManagerContext.ts +10 -0
- package/src/hooks/settings/settingsManagerProvider.tsx +16 -0
- package/src/hooks/system/systemManagerContext.ts +8 -0
- package/src/hooks/system/systemManagerProvider.tsx +26 -0
- package/src/hooks/themes/themes.tsx +22 -0
- package/src/hooks/tracking/trackingManagerContext.ts +10 -0
- package/src/hooks/tracking/trackingManagerProvider.tsx +13 -0
- package/src/hooks/virtual-drive/virtualRootContext.ts +10 -0
- package/src/hooks/virtual-drive/virtualRootProvider.tsx +13 -0
- package/src/hooks/windows/windowsContext.ts +10 -0
- package/src/hooks/windows/windowsManagerContext.ts +10 -0
- package/src/hooks/windows/windowsManagerProvider.tsx +24 -0
- package/src/hooks/windows/windowsProvider.tsx +20 -0
- package/src/hooks/z-index/zIndex.ts +32 -0
- package/src/hooks/z-index/zIndexManagerContext.ts +10 -0
- package/src/hooks/z-index/zIndexManagerProvider.tsx +11 -0
- package/src/index.ts +5 -0
- package/src/styles/global/fonts.css +18 -0
- package/src/styles/global/scrollbar.css +29 -0
- package/src/styles/global/themes.css +67 -0
- package/src/styles/global/variables.css +92 -0
- package/src/styles/global.css +65 -0
- package/src/styles/index.ts +3 -0
- package/src/styles/utils.module.css +22 -0
- package/src/types/util.d.ts +3 -0
- package/src/types/vite-env.d.ts +1 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.AppList {
|
|
2
|
+
--scrollbar-color: rgba(0, 0, 0, 25%);
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
overflow-y: auto;
|
|
6
|
+
max-height: 100%;
|
|
7
|
+
padding-bottom: 0.5rem;
|
|
8
|
+
z-index: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.AppButton {
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: 1rem;
|
|
14
|
+
width: 100%;
|
|
15
|
+
padding: 0.25rem 0.5rem;
|
|
16
|
+
border-radius: var(--border-radius-1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.AppButton > div,
|
|
20
|
+
.AppButton > div > div,
|
|
21
|
+
.AppButton > div > div > svg {
|
|
22
|
+
width: 2rem;
|
|
23
|
+
height: 2rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.AppButton svg {
|
|
27
|
+
filter: var(--svg-drop-shadow-0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.AppButton > p, .AppButton > h2 {
|
|
31
|
+
margin: 0;
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.HomeMenuContainer {
|
|
2
|
+
right: unset;
|
|
3
|
+
left: 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.HomeMenu {
|
|
7
|
+
min-width: 16rem;
|
|
8
|
+
max-width: 32rem;
|
|
9
|
+
border-bottom-left-radius: 0;
|
|
10
|
+
border-bottom-right-radius: var(--border-radius-1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.Buttons {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column-reverse;
|
|
16
|
+
align-items: center;
|
|
17
|
+
padding: 0.25rem;
|
|
18
|
+
margin-top: auto;
|
|
19
|
+
z-index: 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.Buttons > button {
|
|
23
|
+
padding: 0.5rem;
|
|
24
|
+
border-radius: var(--border-radius-1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.Buttons > button > svg {
|
|
28
|
+
height: 1.5rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.Apps {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
width: 100% !important;
|
|
35
|
+
max-height: 20rem;
|
|
36
|
+
padding: 1rem;
|
|
37
|
+
padding-right: 0.25rem;
|
|
38
|
+
padding-bottom: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.Apps > h1 {
|
|
42
|
+
width: 100%;
|
|
43
|
+
text-align: left;
|
|
44
|
+
font-size: 1rem;
|
|
45
|
+
margin: 0;
|
|
46
|
+
margin-bottom: 0.5rem;
|
|
47
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
2
|
+
import styles from "./HomeMenu.module.css";
|
|
3
|
+
import appStyles from "./AppList.module.css";
|
|
4
|
+
import taskbarStyles from "../Taskbar.module.css";
|
|
5
|
+
import { faCircleInfo, faFileLines, faGear, faImage, faPowerOff } from "@fortawesome/free-solid-svg-icons";
|
|
6
|
+
import { ReactSVG } from "react-svg";
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
import { utilStyles } from "../../..";
|
|
9
|
+
import { closeViewport, Vector2 } from "../../../features";
|
|
10
|
+
import { useWindowsManager, useVirtualRoot, useKeyboardListener, useSystemManager } from "../../../hooks";
|
|
11
|
+
import { fileExplorer } from "@prozilla-os/file-explorer";
|
|
12
|
+
|
|
13
|
+
interface HomeMenuProps {
|
|
14
|
+
active: boolean;
|
|
15
|
+
setActive: Function;
|
|
16
|
+
search: Function;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function HomeMenu({ active, setActive, search }: HomeMenuProps) {
|
|
20
|
+
const { systemName, appsConfig } = useSystemManager();
|
|
21
|
+
const windowsManager = useWindowsManager();
|
|
22
|
+
const virtualRoot = useVirtualRoot();
|
|
23
|
+
const [tabIndex, setTabIndex] = useState(active ? 0 : -1);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setTabIndex(active ? 0 : -1);
|
|
27
|
+
}, [active]);
|
|
28
|
+
|
|
29
|
+
const classNames = [styles.HomeMenuContainer, taskbarStyles.MenuContainer];
|
|
30
|
+
if (active)
|
|
31
|
+
classNames.push(taskbarStyles.Active);
|
|
32
|
+
|
|
33
|
+
let onlyAltKey = false;
|
|
34
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
35
|
+
if (event.key === "Alt") {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
onlyAltKey = true;
|
|
38
|
+
} else {
|
|
39
|
+
onlyAltKey = false;
|
|
40
|
+
|
|
41
|
+
if (active && event.key.length === 1) {
|
|
42
|
+
search(event.key);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const onKeyUp = (event: KeyboardEvent) => {
|
|
48
|
+
if (event.key === "Alt" && onlyAltKey) {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
setActive(!active);
|
|
51
|
+
onlyAltKey = false;
|
|
52
|
+
} else {
|
|
53
|
+
onlyAltKey = false;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
useKeyboardListener({ onKeyDown, onKeyUp });
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className={classNames.join(" ")}>
|
|
61
|
+
<div className={`${styles.HomeMenu} ${taskbarStyles.Menu}`}>
|
|
62
|
+
<div className={styles.Buttons}>
|
|
63
|
+
<button title="Shut Down" tabIndex={tabIndex} onClick={() => { closeViewport(true, systemName); }}>
|
|
64
|
+
<FontAwesomeIcon icon={faPowerOff}/>
|
|
65
|
+
</button>
|
|
66
|
+
<button title="Settings" tabIndex={tabIndex} onClick={() => {
|
|
67
|
+
setActive(false);
|
|
68
|
+
windowsManager?.open("settings");
|
|
69
|
+
}}>
|
|
70
|
+
<FontAwesomeIcon icon={faGear}/>
|
|
71
|
+
</button>
|
|
72
|
+
<button title="Info" tabIndex={tabIndex} onClick={() => {
|
|
73
|
+
setActive(false);
|
|
74
|
+
windowsManager?.open("text-editor", {
|
|
75
|
+
mode: "view",
|
|
76
|
+
file: virtualRoot?.navigate("~/Documents/Info.md"),
|
|
77
|
+
size: new Vector2(575, 675),
|
|
78
|
+
});
|
|
79
|
+
}}>
|
|
80
|
+
<FontAwesomeIcon icon={faCircleInfo}/>
|
|
81
|
+
</button>
|
|
82
|
+
<button title="Images" tabIndex={tabIndex} onClick={() => {
|
|
83
|
+
setActive(false);
|
|
84
|
+
windowsManager?.open(fileExplorer.id, { path: "~/Pictures" });
|
|
85
|
+
}}>
|
|
86
|
+
<FontAwesomeIcon icon={faImage}/>
|
|
87
|
+
</button>
|
|
88
|
+
<button title="Documents" tabIndex={tabIndex} onClick={() => {
|
|
89
|
+
setActive(false);
|
|
90
|
+
windowsManager?.open(fileExplorer.id, { path: "~/Documents" }); }
|
|
91
|
+
}>
|
|
92
|
+
<FontAwesomeIcon icon={faFileLines}/>
|
|
93
|
+
</button>
|
|
94
|
+
</div>
|
|
95
|
+
<div className={styles.Apps}>
|
|
96
|
+
<h1 className={utilStyles.TextBold}>{systemName}</h1>
|
|
97
|
+
<div className={appStyles.AppList}>
|
|
98
|
+
{appsConfig.apps.sort((a, b) => a.name.localeCompare(b.name)).map(({ name, id, iconUrl }) =>
|
|
99
|
+
<button
|
|
100
|
+
key={id}
|
|
101
|
+
className={appStyles.AppButton}
|
|
102
|
+
tabIndex={tabIndex}
|
|
103
|
+
onClick={() => {
|
|
104
|
+
setActive(false);
|
|
105
|
+
windowsManager?.open(id);
|
|
106
|
+
}}
|
|
107
|
+
title={name}
|
|
108
|
+
>
|
|
109
|
+
<ReactSVG src={iconUrl ?? ""}/>
|
|
110
|
+
<h2 className={utilStyles.TextRegular}>{name}</h2>
|
|
111
|
+
</button>
|
|
112
|
+
)}
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
.SearchMenuContainer {
|
|
2
|
+
position: absolute;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
left: 0;
|
|
6
|
+
bottom: 100%;
|
|
7
|
+
max-height: 20rem;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.SearchMenu {
|
|
12
|
+
opacity: 0;
|
|
13
|
+
display: flex;
|
|
14
|
+
gap: 0.5rem;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
min-width: 13rem;
|
|
17
|
+
max-width: 19rem;
|
|
18
|
+
padding: 0.5rem;
|
|
19
|
+
margin-top: 100px;
|
|
20
|
+
border-top-left-radius: var(--border-radius-1);
|
|
21
|
+
border-top-right-radius: var(--border-radius-1);
|
|
22
|
+
border-bottom-right-radius: var(--border-radius-1);
|
|
23
|
+
backdrop-filter: var(--taskbar-filter);
|
|
24
|
+
transition: opacity 200ms ease-in-out, margin-top 200ms ease-in-out;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
resize: horizontal;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.SearchMenu::after {
|
|
30
|
+
opacity: var(--taskbar-menu-opacity);
|
|
31
|
+
content: "";
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 0;
|
|
34
|
+
bottom: 0;
|
|
35
|
+
left: 0;
|
|
36
|
+
right: 0;
|
|
37
|
+
background-color: var(--taskbar-menu-color);
|
|
38
|
+
z-index: -2;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.SearchMenuContainer.Active .SearchMenu {
|
|
42
|
+
opacity: 1;
|
|
43
|
+
margin-top: 0px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.SearchMenuContainer:not(.Active) {
|
|
47
|
+
pointer-events: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.SearchMenu > div {
|
|
51
|
+
margin-top: auto;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.Input {
|
|
55
|
+
width: 100%;
|
|
56
|
+
padding: 0.25rem 0.5rem;
|
|
57
|
+
color: var(--foreground-color-0);
|
|
58
|
+
background-color: rgba(0, 0, 0, 25%);
|
|
59
|
+
border: none;
|
|
60
|
+
border-radius: var(--border-radius-1);
|
|
61
|
+
outline: none;
|
|
62
|
+
font-family: inherit;
|
|
63
|
+
font-size: inherit;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.SearchMenu > div > button:first-child {
|
|
67
|
+
background-color: var(--taskbar-button-hover-color);
|
|
68
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import styles from "./SearchMenu.module.css";
|
|
2
|
+
import appStyles from "./AppList.module.css";
|
|
3
|
+
import { useWindowsManager } from "../../../hooks/windows/windowsManagerContext";
|
|
4
|
+
import { ChangeEventHandler, MutableRefObject, useEffect, useState } from "react";
|
|
5
|
+
import { useKeyboardListener } from "../../../hooks/_utils/keyboard";
|
|
6
|
+
import { App } from "../../../features/system/configs/app";
|
|
7
|
+
import { ReactSVG } from "react-svg";
|
|
8
|
+
import { useSystemManager } from "../../../hooks";
|
|
9
|
+
|
|
10
|
+
interface SearchMenuProps {
|
|
11
|
+
active: boolean;
|
|
12
|
+
setActive: Function;
|
|
13
|
+
searchQuery: string;
|
|
14
|
+
setSearchQuery: Function;
|
|
15
|
+
inputRef: MutableRefObject<HTMLInputElement>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function SearchMenu({ active, setActive, searchQuery, setSearchQuery, inputRef }: SearchMenuProps) {
|
|
19
|
+
const { appsConfig } = useSystemManager();
|
|
20
|
+
const windowsManager = useWindowsManager();
|
|
21
|
+
const [apps, setApps] = useState<App[] | null>(null);
|
|
22
|
+
const [tabIndex, setTabIndex] = useState(active ? 0 : -1);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setTabIndex(active ? 0 : -1);
|
|
26
|
+
}, [active]);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (inputRef.current != null) {
|
|
30
|
+
inputRef.current.focus();
|
|
31
|
+
window.scrollTo(0, document.body.scrollHeight);
|
|
32
|
+
}
|
|
33
|
+
}, [inputRef]);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setApps(appsConfig.apps.filter(({ name, id }) =>
|
|
37
|
+
name.toLowerCase().includes(searchQuery.toLowerCase().trim())
|
|
38
|
+
|| id.toLowerCase().includes(searchQuery.toLowerCase().trim())
|
|
39
|
+
).sort((a, b) =>
|
|
40
|
+
a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
|
41
|
+
));
|
|
42
|
+
}, [searchQuery]);
|
|
43
|
+
|
|
44
|
+
const onChange = (event: Event) => {
|
|
45
|
+
const value = (event.target as HTMLInputElement).value;
|
|
46
|
+
setSearchQuery(value);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const classNames = [styles.SearchMenuContainer];
|
|
50
|
+
if (active && apps != null)
|
|
51
|
+
classNames.push(styles.Active);
|
|
52
|
+
|
|
53
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
54
|
+
if ((event.key === "f" || event.key === "g") && event.ctrlKey && !active) {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
setActive(true);
|
|
57
|
+
} else if (event.key === "Escape" && active) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
setActive(false);
|
|
60
|
+
} else if (event.key === "Enter" && active) {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
if (apps == null) return;
|
|
63
|
+
windowsManager?.open(apps[0].id);
|
|
64
|
+
setActive(false);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
useKeyboardListener({ onKeyDown });
|
|
69
|
+
|
|
70
|
+
return <div className={classNames.join(" ")}>
|
|
71
|
+
<div className={styles.SearchMenu}>
|
|
72
|
+
<div className={appStyles.AppList}>
|
|
73
|
+
{apps?.map(({ name, id }) =>
|
|
74
|
+
<button
|
|
75
|
+
key={id}
|
|
76
|
+
className={appStyles.AppButton}
|
|
77
|
+
tabIndex={tabIndex}
|
|
78
|
+
onClick={() => {
|
|
79
|
+
setActive(false);
|
|
80
|
+
windowsManager?.open(id);
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
<ReactSVG src={appsConfig.getAppById(id)?.iconUrl ?? ""}/>
|
|
84
|
+
<p>{name}</p>
|
|
85
|
+
</button>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
<input
|
|
89
|
+
ref={inputRef}
|
|
90
|
+
className={styles.Input}
|
|
91
|
+
aria-label="Search query"
|
|
92
|
+
tabIndex={tabIndex}
|
|
93
|
+
value={searchQuery}
|
|
94
|
+
onChange={onChange as unknown as ChangeEventHandler}
|
|
95
|
+
spellCheck={false}
|
|
96
|
+
placeholder="Search..."
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
</div>;
|
|
100
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.UtilMenuContainer {
|
|
2
|
+
position: absolute;
|
|
3
|
+
right: 0;
|
|
4
|
+
bottom: 100%;
|
|
5
|
+
height: auto !important;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.UtilMenu {
|
|
10
|
+
opacity: 1;
|
|
11
|
+
display: flex;
|
|
12
|
+
border-top-left-radius: var(--border-radius-1);
|
|
13
|
+
border-top-right-radius: var(--border-radius-1);
|
|
14
|
+
border-bottom-left-radius: var(--border-radius-1);
|
|
15
|
+
backdrop-filter: var(--taskbar-filter);
|
|
16
|
+
transform: none;
|
|
17
|
+
transition: opacity 200ms ease-in-out, transform 200ms ease-in-out;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
resize: horizontal;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.UtilMenu::after {
|
|
23
|
+
opacity: var(--taskbar-menu-opacity);
|
|
24
|
+
content: "";
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: 0;
|
|
27
|
+
bottom: 0;
|
|
28
|
+
left: 0;
|
|
29
|
+
right: 0;
|
|
30
|
+
background-color: var(--taskbar-menu-color);
|
|
31
|
+
z-index: -2;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.UtilMenuContainer:not(.Active) {
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.UtilMenuContainer:not(.Active) .UtilMenu {
|
|
39
|
+
opacity: 0;
|
|
40
|
+
transform: translateY(100px);
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import styles from "./UtilMenu.module.css";
|
|
3
|
+
|
|
4
|
+
interface UtilMenuProps {
|
|
5
|
+
active: boolean;
|
|
6
|
+
setActive: Function;
|
|
7
|
+
className: string;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function UtilMenu({ active, setActive: _setActive, className, children }: UtilMenuProps) {
|
|
12
|
+
const classNames = [styles.UtilMenuContainer];
|
|
13
|
+
if (active)
|
|
14
|
+
classNames.push(styles.Active);
|
|
15
|
+
if (className != null)
|
|
16
|
+
classNames.push(className);
|
|
17
|
+
|
|
18
|
+
return (<div className={classNames.join(" ")}>
|
|
19
|
+
<div className={styles.UtilMenu}>
|
|
20
|
+
{children}
|
|
21
|
+
</div>
|
|
22
|
+
</div>);
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useAlert } from "../../hooks/modals/alert";
|
|
3
|
+
import { Vector2 } from "../../features/math/vector2";
|
|
4
|
+
import { App } from "../../features/system/configs/app";
|
|
5
|
+
import { useSystemManager } from "../../hooks";
|
|
6
|
+
|
|
7
|
+
export interface WindowFallbackViewProps {
|
|
8
|
+
error?: Error;
|
|
9
|
+
resetErrorBoundary?: unknown;
|
|
10
|
+
app?: App;
|
|
11
|
+
closeWindow?: Function
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// I don't know why this component's type needs to be ReactNode instead of FC, it has something to do with the way it's implemented
|
|
15
|
+
export function WindowFallbackView({ error, resetErrorBoundary: _resetErrorBoundary, app, closeWindow }: WindowFallbackViewProps): undefined {
|
|
16
|
+
const { appsConfig } = useSystemManager();
|
|
17
|
+
const { alert } = useAlert();
|
|
18
|
+
const [alerted, setAlerted] = useState(false);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (alerted)
|
|
22
|
+
return;
|
|
23
|
+
|
|
24
|
+
setAlerted(true);
|
|
25
|
+
closeWindow?.();
|
|
26
|
+
|
|
27
|
+
if (app != null && error != null)
|
|
28
|
+
alert({
|
|
29
|
+
title: `${app.name} has stopped working`,
|
|
30
|
+
text: `${error.name}: ${error.message}`,
|
|
31
|
+
iconUrl: appsConfig.getAppById(app.id)?.iconUrl as string | undefined,
|
|
32
|
+
size: new Vector2(350, 150),
|
|
33
|
+
single: true
|
|
34
|
+
});
|
|
35
|
+
}, [alerted, alert, app?.id, app?.name, error?.message, closeWindow, error?.name]);
|
|
36
|
+
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
.Window-container {
|
|
2
|
+
--header-height: 2.5rem;
|
|
3
|
+
--header-button-hover-color: rgba(255, 255, 255, 5%);
|
|
4
|
+
|
|
5
|
+
position: absolute;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.Window-container.Minimized {
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@keyframes pop-in {
|
|
13
|
+
0% {
|
|
14
|
+
scale: 0;
|
|
15
|
+
}
|
|
16
|
+
100% {
|
|
17
|
+
scale: 100%;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.Window-container.Maximized {
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
transform: none !important;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.Window-container.Maximized .Window-inner {
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: calc(100% - var(--taskbar-height));
|
|
30
|
+
border-radius: 0;
|
|
31
|
+
resize: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.Window-inner {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
min-width: 300px;
|
|
38
|
+
min-height: 150px;
|
|
39
|
+
background-color: var(--background-color-2);
|
|
40
|
+
border-radius: var(--border-radius-1);
|
|
41
|
+
box-shadow: var(--window-box-shadow);
|
|
42
|
+
resize: both;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
transform-origin: center center;
|
|
45
|
+
animation: appear 250ms ease-in-out forwards;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.Window-container.Minimized .Window-inner {
|
|
49
|
+
animation: disappear 250ms ease-in-out forwards;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@keyframes appear {
|
|
53
|
+
0% {
|
|
54
|
+
opacity: 0;
|
|
55
|
+
transform: translateY(25vh) scale(0);
|
|
56
|
+
}
|
|
57
|
+
25% {
|
|
58
|
+
opacity: 0;
|
|
59
|
+
}
|
|
60
|
+
100% {
|
|
61
|
+
opacity: 1;
|
|
62
|
+
transform: none;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@keyframes disappear {
|
|
67
|
+
0% {
|
|
68
|
+
opacity: 1;
|
|
69
|
+
transform: none;
|
|
70
|
+
}
|
|
71
|
+
75% {
|
|
72
|
+
opacity: 0;
|
|
73
|
+
}
|
|
74
|
+
100% {
|
|
75
|
+
opacity: 0;
|
|
76
|
+
transform: translateY(25vh) scale(0);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.Header {
|
|
81
|
+
--window-icon-size: 1.5rem;
|
|
82
|
+
--window-icon-margin: 0.75rem;
|
|
83
|
+
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
height: var(--header-height);
|
|
87
|
+
padding: 0.25rem;
|
|
88
|
+
padding-left: var(--window-icon-margin);
|
|
89
|
+
padding-right: 0;
|
|
90
|
+
background-color: var(--background-color-1);
|
|
91
|
+
cursor: grab;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.Window-icon,
|
|
95
|
+
.Window-icon > div,
|
|
96
|
+
.Window-icon > div > svg {
|
|
97
|
+
height: 100%;
|
|
98
|
+
width: auto;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.Window-icon {
|
|
102
|
+
height: var(--window-icon-size);
|
|
103
|
+
margin-right: calc(var(--window-icon-margin) - 0.1rem);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.Window-icon > div {
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.Header > p {
|
|
112
|
+
user-select: none;
|
|
113
|
+
width: auto;
|
|
114
|
+
margin: 0;
|
|
115
|
+
margin-right: auto;
|
|
116
|
+
white-space: nowrap;
|
|
117
|
+
text-overflow: ellipsis;
|
|
118
|
+
overflow: hidden;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.Header-button {
|
|
122
|
+
display: flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
justify-content: center;
|
|
125
|
+
height: var(--header-height);
|
|
126
|
+
margin: 0;
|
|
127
|
+
padding: 0.75rem;
|
|
128
|
+
color: var(--foreground-color-0);
|
|
129
|
+
background: none;
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
border: none;
|
|
132
|
+
outline: none;
|
|
133
|
+
aspect-ratio: 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.Header-button > svg {
|
|
137
|
+
height: 100%;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.Exit-button {
|
|
141
|
+
--header-button-hover-color: var(--red-0);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.Header-button:hover, .Header-button:focus-visible {
|
|
145
|
+
background-color: var(--header-button-hover-color);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.Window-content {
|
|
149
|
+
position: relative;
|
|
150
|
+
overflow: hidden;
|
|
151
|
+
height: 100%;
|
|
152
|
+
}
|