@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,49 @@
|
|
|
1
|
+
.Desktop {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: env(safe-area-inset-top, 0);
|
|
4
|
+
left: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
z-index: -1;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.Wallpaper {
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
object-fit: cover;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.Content {
|
|
21
|
+
--direction: column;
|
|
22
|
+
|
|
23
|
+
position: absolute;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: var(--direction);
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
align-content: flex-start;
|
|
28
|
+
justify-content: flex-start;
|
|
29
|
+
top: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
padding: 0.5rem;
|
|
34
|
+
padding-bottom: calc(var(--taskbar-height) + 0.5rem);
|
|
35
|
+
z-index: 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.Item {
|
|
39
|
+
padding: 0.25rem;
|
|
40
|
+
text-shadow: 0.1rem 0.1rem 0.2rem color-mix(in srgb, var(--black-0) 75%, transparent);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.Item p {
|
|
44
|
+
color: var(--white-0);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.Item svg {
|
|
48
|
+
filter: var(--svg-drop-shadow-0);
|
|
49
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { memo, MouseEventHandler, useState } from "react";
|
|
2
|
+
import styles from "./Desktop.module.css";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { Actions } from "../actions/Actions";
|
|
5
|
+
import { ClickAction } from "../actions/actions/ClickAction";
|
|
6
|
+
import { faArrowsRotate, faCompress, faExpand, faEye, faFolder, faPaintBrush, faTerminal, faTrash } from "@fortawesome/free-solid-svg-icons";
|
|
7
|
+
import { ToggleAction } from "../actions/actions/ToggleAction";
|
|
8
|
+
import { DropdownAction } from "../actions/actions/DropdownAction";
|
|
9
|
+
import { RadioAction } from "../actions/actions/RadioAction";
|
|
10
|
+
import { Divider } from "../actions/actions/Divider";
|
|
11
|
+
import { Share } from "../modals/share/Share";
|
|
12
|
+
import { ModalProps } from "../modals/ModalView";
|
|
13
|
+
import { SettingsManager, reloadViewport, ModalsManager, Vector2, isValidInteger } from "../../features";
|
|
14
|
+
import { VirtualFile } from "../../features/virtual-drive/file";
|
|
15
|
+
import { VirtualFolder, VirtualFolderLink } from "../../features/virtual-drive/folder";
|
|
16
|
+
import { useSettingsManager, useWindowsManager, useVirtualRoot, useWindowedModal, useContextMenu, useSystemManager } from "../../hooks";
|
|
17
|
+
import { DirectoryList } from "../_utils";
|
|
18
|
+
import { FileEventHandler, FolderEventHandler } from "../_utils/directory-list/DirectoryList";
|
|
19
|
+
import { fileExplorer } from "@prozilla-os/file-explorer";
|
|
20
|
+
|
|
21
|
+
export const Desktop = memo(() => {
|
|
22
|
+
const { desktopConfig } = useSystemManager();
|
|
23
|
+
const settingsManager = useSettingsManager();
|
|
24
|
+
const windowsManager = useWindowsManager();
|
|
25
|
+
const virtualRoot = useVirtualRoot();
|
|
26
|
+
|
|
27
|
+
const [wallpaper, setWallpaper] = useState<string | null>(null);
|
|
28
|
+
const [showIcons, setShowIcons] = useState(false);
|
|
29
|
+
const [iconSize, setIconSize] = useState<number>(desktopConfig.defaultIconSize);
|
|
30
|
+
const [iconDirection, setIconDirection] = useState<number>(desktopConfig.defaultIconDirection);
|
|
31
|
+
const { openWindowedModal } = useWindowedModal();
|
|
32
|
+
|
|
33
|
+
const directory = virtualRoot?.navigate("~/Desktop");
|
|
34
|
+
|
|
35
|
+
const { onContextMenu, ShortcutsListener } = useContextMenu({ Actions: (props) =>
|
|
36
|
+
<Actions {...props}>
|
|
37
|
+
<DropdownAction label="View" icon={faEye}>
|
|
38
|
+
<RadioAction initialIndex={iconSize} onTrigger={(event, params, value) => {
|
|
39
|
+
const settings = settingsManager?.getSettings(SettingsManager.VIRTUAL_PATHS.desktop);
|
|
40
|
+
void settings?.set("icon-size", value as string);
|
|
41
|
+
}} options={[
|
|
42
|
+
{ label: "Small icons" },
|
|
43
|
+
{ label: "Medium icons" },
|
|
44
|
+
{ label: "Large icons" },
|
|
45
|
+
]}/>
|
|
46
|
+
<Divider/>
|
|
47
|
+
<RadioAction initialIndex={iconDirection} onTrigger={(event, params, value) => {
|
|
48
|
+
const settings = settingsManager?.getSettings(SettingsManager.VIRTUAL_PATHS.desktop);
|
|
49
|
+
void settings?.set("icon-direction", value as string);
|
|
50
|
+
}} options={[
|
|
51
|
+
{ label: "Align vertically" },
|
|
52
|
+
{ label: "Align horizontally" },
|
|
53
|
+
]}/>
|
|
54
|
+
<Divider/>
|
|
55
|
+
<ToggleAction label="Show dekstop icons" initialValue={showIcons} onTrigger={() => {
|
|
56
|
+
const settings = settingsManager?.getSettings(SettingsManager.VIRTUAL_PATHS.desktop);
|
|
57
|
+
void settings?.set("show-icons", (!showIcons).toString());
|
|
58
|
+
}}/>
|
|
59
|
+
</DropdownAction>
|
|
60
|
+
<ClickAction label="Reload" shortcut={["Control", "r"]} icon={faArrowsRotate} onTrigger={() => {
|
|
61
|
+
reloadViewport();
|
|
62
|
+
}}/>
|
|
63
|
+
<ClickAction
|
|
64
|
+
label={!document.fullscreenElement ? "Enter fullscreen" : "Exit fullscreen"}
|
|
65
|
+
shortcut={["F11"]}
|
|
66
|
+
icon={!document.fullscreenElement ? faExpand : faCompress}
|
|
67
|
+
onTrigger={() => {
|
|
68
|
+
if (windowsManager?.isAnyFocused())
|
|
69
|
+
return;
|
|
70
|
+
|
|
71
|
+
if (!document.fullscreenElement) {
|
|
72
|
+
void document.body.requestFullscreen().catch((error) => {
|
|
73
|
+
console.error(error);
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
void document.exitFullscreen().catch((error) => {
|
|
77
|
+
console.error(error);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
<ClickAction label="Change appearance" icon={faPaintBrush} onTrigger={() => {
|
|
83
|
+
windowsManager?.open("settings", { tab: 2 });
|
|
84
|
+
}}/>
|
|
85
|
+
<Divider/>
|
|
86
|
+
<ClickAction label={`Open in ${fileExplorer.name}`} icon={fileExplorer.iconUrl as string | undefined} onTrigger={() => {
|
|
87
|
+
windowsManager?.open(fileExplorer.id, { path: directory?.path });
|
|
88
|
+
}}/>
|
|
89
|
+
{/* <ClickAction label={`Open in ${"APP_NAMES.TERMINAL"}`} icon={APP_ICONS.TERMINAL} onTrigger={() => {
|
|
90
|
+
windowsManager?.open(APPS.TERMINAL, { path: directory?.path });
|
|
91
|
+
}}/> */}
|
|
92
|
+
<Divider/>
|
|
93
|
+
<ClickAction label={"Share"} icon={ModalsManager.getModalIconUrl("share")} onTrigger={() => {
|
|
94
|
+
openWindowedModal({
|
|
95
|
+
size: new Vector2(350, 350),
|
|
96
|
+
Modal: (props: ModalProps) => <Share {...props}/>
|
|
97
|
+
});
|
|
98
|
+
}}/>
|
|
99
|
+
</Actions>
|
|
100
|
+
});
|
|
101
|
+
const { onContextMenu: onContextMenuFile } = useContextMenu({ Actions: (props) =>
|
|
102
|
+
<Actions {...props}>
|
|
103
|
+
<ClickAction label="Open" onTrigger={(event, file) => {
|
|
104
|
+
if (windowsManager != null) (file as VirtualFile).open(windowsManager);
|
|
105
|
+
}}/>
|
|
106
|
+
<ClickAction label={`Reveal in ${fileExplorer.name}`} icon={faFolder} onTrigger={(event, file) => {
|
|
107
|
+
if (windowsManager != null) (file as VirtualFile).parent?.open(windowsManager);
|
|
108
|
+
}}/>
|
|
109
|
+
<ClickAction label="Delete" icon={faTrash} onTrigger={(event, file) => {
|
|
110
|
+
(file as VirtualFile).delete();
|
|
111
|
+
}}/>
|
|
112
|
+
</Actions>
|
|
113
|
+
});
|
|
114
|
+
const { onContextMenu: onContextMenuFolder } = useContextMenu({ Actions: (props) =>
|
|
115
|
+
<Actions {...props}>
|
|
116
|
+
<ClickAction label="Open" onTrigger={(event, folder) => {
|
|
117
|
+
if (windowsManager != null) (folder as VirtualFolder).open(windowsManager);
|
|
118
|
+
}}/>
|
|
119
|
+
{/* <ClickAction label={`Open in ${APP_NAMES.TERMINAL}`} icon={faTerminal} onTrigger={(event, folder) => {
|
|
120
|
+
windowsManager?.open(APPS.TERMINAL, { path: (folder as VirtualFolder).path });
|
|
121
|
+
}}/> */}
|
|
122
|
+
<ClickAction label={`Reveal in ${fileExplorer.name}`} icon={faFolder} onTrigger={(event, folder) => {
|
|
123
|
+
if (windowsManager != null) (folder as VirtualFolder).parent?.open(windowsManager);
|
|
124
|
+
}}/>
|
|
125
|
+
<Divider/>
|
|
126
|
+
<ClickAction label="Delete" icon={faTrash} onTrigger={(event, folder) => {
|
|
127
|
+
(folder as VirtualFolder).delete();
|
|
128
|
+
}}/>
|
|
129
|
+
</Actions>
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
const settings = settingsManager?.getSettings(SettingsManager.VIRTUAL_PATHS.desktop);
|
|
134
|
+
void settings?.get("wallpaper", setWallpaper);
|
|
135
|
+
void settings?.get("show-icons", (value) => {
|
|
136
|
+
if (value != null) {
|
|
137
|
+
setShowIcons(value === "true");
|
|
138
|
+
} else {
|
|
139
|
+
setShowIcons(true);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
void settings?.get("icon-size", (value) => {
|
|
143
|
+
if (isValidInteger(value))
|
|
144
|
+
setIconSize(parseInt(value));
|
|
145
|
+
});
|
|
146
|
+
void settings?.get("icon-direction", (value) => {
|
|
147
|
+
if (isValidInteger(value))
|
|
148
|
+
setIconDirection(parseInt(value));
|
|
149
|
+
});
|
|
150
|
+
}, [settingsManager]);
|
|
151
|
+
|
|
152
|
+
const onError = () => {
|
|
153
|
+
const settings = settingsManager?.getSettings(SettingsManager.VIRTUAL_PATHS.desktop);
|
|
154
|
+
void settings?.set("wallpaper", desktopConfig.defaultWallpaper);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const iconScale = 1 + ((isValidInteger(iconSize) ? iconSize : desktopConfig.defaultIconSize) - 1) / 5;
|
|
158
|
+
|
|
159
|
+
return <>
|
|
160
|
+
<ShortcutsListener/>
|
|
161
|
+
<div
|
|
162
|
+
className={styles.Desktop}
|
|
163
|
+
onContextMenu={onContextMenu as unknown as MouseEventHandler}
|
|
164
|
+
>
|
|
165
|
+
{showIcons && <DirectoryList
|
|
166
|
+
directory={directory as VirtualFolder}
|
|
167
|
+
className={styles.Content}
|
|
168
|
+
style={{
|
|
169
|
+
"--scale": `${iconScale}rem`,
|
|
170
|
+
"--direction": iconDirection == 1 ? "row" : "column"
|
|
171
|
+
}}
|
|
172
|
+
fileClassName={styles["Item"]}
|
|
173
|
+
folderClassName={styles["Item"]}
|
|
174
|
+
onOpenFile={(event, file) => {
|
|
175
|
+
(event).preventDefault();
|
|
176
|
+
|
|
177
|
+
const options: Record<string, unknown> = {};
|
|
178
|
+
if (file.name === "Info.md")
|
|
179
|
+
options.size = new Vector2(575, 675);
|
|
180
|
+
if (file.extension === "md")
|
|
181
|
+
options.mode = "view";
|
|
182
|
+
|
|
183
|
+
windowsManager?.openFile(file, options);
|
|
184
|
+
}}
|
|
185
|
+
onOpenFolder={(event, folder) => {
|
|
186
|
+
windowsManager?.open(fileExplorer.id, {
|
|
187
|
+
path: (folder as VirtualFolderLink).linkedPath ?? folder.path
|
|
188
|
+
});
|
|
189
|
+
}}
|
|
190
|
+
onContextMenuFile={onContextMenuFile as unknown as FileEventHandler}
|
|
191
|
+
onContextMenuFolder={onContextMenuFolder as unknown as FolderEventHandler}
|
|
192
|
+
/>}
|
|
193
|
+
{wallpaper
|
|
194
|
+
? <img src={wallpaper} className={styles.Wallpaper} alt="Desktop wallpaper" onError={onError}/>
|
|
195
|
+
: null
|
|
196
|
+
}
|
|
197
|
+
</div>
|
|
198
|
+
</>;
|
|
199
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ProzillaOS } from "./prozilla-os/ProzillaOS";
|
|
2
|
+
export { Taskbar } from "./taskbar/Taskbar";
|
|
3
|
+
export { WindowsView } from "./windows/WindowsView";
|
|
4
|
+
export { Desktop } from "./desktop/Desktop";
|
|
5
|
+
|
|
6
|
+
export * from "./_utils";
|
|
7
|
+
export * from "./actions";
|
|
8
|
+
export * from "./modals";
|
|
9
|
+
|
|
10
|
+
export type { WindowProps } from "./windows/WindowView";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.ModalView {
|
|
2
|
+
--position-x: 0;
|
|
3
|
+
--position-y: 0;
|
|
4
|
+
|
|
5
|
+
position: fixed;
|
|
6
|
+
top: calc(var(--position-y) * 1px);
|
|
7
|
+
left: calc(var(--position-x) * 1px);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ModalView > * {
|
|
11
|
+
background: var(--background-color-0);
|
|
12
|
+
border-radius: var(--border-radius-1);
|
|
13
|
+
box-shadow: var(--window-box-shadow);
|
|
14
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CSSProperties, FC, KeyboardEvent, memo, ReactNode } from "react";
|
|
2
|
+
import { Modal } from "../../features/modals/modal";
|
|
3
|
+
import { OutsideClickListener } from "../../hooks/_utils/outsideClick";
|
|
4
|
+
import styles from "./ModalView.module.css";
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
|
|
7
|
+
export interface ModalProps {
|
|
8
|
+
modal?: Modal;
|
|
9
|
+
params?: {
|
|
10
|
+
appId?: string;
|
|
11
|
+
fullscreen?: boolean;
|
|
12
|
+
iconUrl?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
standalone?: boolean;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
onFinish?: Function;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const ModalView: FC<ModalProps> = memo(({ modal }) => {
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const onDismiss = (event: Event) => {
|
|
25
|
+
if ((event as unknown as KeyboardEvent).key === "Escape")
|
|
26
|
+
modal?.close();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
document.addEventListener("keydown", onDismiss);
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
document.removeEventListener("keydown", onDismiss);
|
|
33
|
+
};
|
|
34
|
+
}, [modal]);
|
|
35
|
+
|
|
36
|
+
if (modal?.element == null) return;
|
|
37
|
+
|
|
38
|
+
const Modal = modal.element;
|
|
39
|
+
|
|
40
|
+
const Container = () => (<div
|
|
41
|
+
className={styles.ModalView}
|
|
42
|
+
style={{ "--position-x": modal?.position.x, "--position-y": modal?.position.y } as CSSProperties}
|
|
43
|
+
>
|
|
44
|
+
<Modal modal={modal} {...modal?.props}/>
|
|
45
|
+
</div>);
|
|
46
|
+
|
|
47
|
+
if (modal.dismissible) {
|
|
48
|
+
return (<OutsideClickListener onOutsideClick={() => { modal?.close(); }}>
|
|
49
|
+
<Container/>
|
|
50
|
+
</OutsideClickListener>);
|
|
51
|
+
} else {
|
|
52
|
+
return <Container/>;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { memo, MutableRefObject, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { ModalView } from "./ModalView";
|
|
3
|
+
import styles from "./ModalsView.module.css";
|
|
4
|
+
import { useModals } from "../../hooks/modals/modalsContext";
|
|
5
|
+
import { useModalsManager } from "../../hooks/modals/modalsManagerContext";
|
|
6
|
+
import { Modal } from "../../features/modals/modal";
|
|
7
|
+
|
|
8
|
+
export const ModalsView = memo(() => {
|
|
9
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
10
|
+
const modals = useModals();
|
|
11
|
+
const modalsManager = useModalsManager();
|
|
12
|
+
const [sortedModals, setSortedModals] = useState<Modal[]>([]);
|
|
13
|
+
|
|
14
|
+
// Sort modals
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (modals != null)
|
|
17
|
+
setSortedModals([...modals].sort((modalA, modalB) =>
|
|
18
|
+
(modalA.lastInteraction ?? 0) - (modalB.lastInteraction ?? 0)
|
|
19
|
+
));
|
|
20
|
+
}, [modals]);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (modalsManager != null)
|
|
24
|
+
modalsManager.containerRef = ref as MutableRefObject<HTMLDivElement>;
|
|
25
|
+
}, [modalsManager, ref]);
|
|
26
|
+
|
|
27
|
+
return <div ref={ref} className={styles.ModalsView}>
|
|
28
|
+
{sortedModals?.map((modal) =>
|
|
29
|
+
<ModalView key={modal.id} modal={modal}/>
|
|
30
|
+
)}
|
|
31
|
+
</div>;
|
|
32
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
.WindowedModal {
|
|
2
|
+
--header-height: 2.5rem;
|
|
3
|
+
--header-button-hover-color: rgba(255, 255, 255, 5%);
|
|
4
|
+
|
|
5
|
+
position: absolute;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
min-width: 300px;
|
|
9
|
+
min-height: 150px;
|
|
10
|
+
background-color: var(--background-color-2) !important;
|
|
11
|
+
resize: both;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.Header {
|
|
16
|
+
--window-icon-size: 1.5rem;
|
|
17
|
+
--window-icon-margin: 0.75rem;
|
|
18
|
+
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
height: var(--header-height);
|
|
22
|
+
padding: 0.25rem;
|
|
23
|
+
padding-left: var(--window-icon-margin);
|
|
24
|
+
padding-right: 0;
|
|
25
|
+
background-color: var(--background-color-1);
|
|
26
|
+
cursor: grab;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.Window-icon,
|
|
30
|
+
.Window-icon > div,
|
|
31
|
+
.Window-icon > div > svg {
|
|
32
|
+
height: 100%;
|
|
33
|
+
width: auto;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.Window-icon {
|
|
37
|
+
height: var(--window-icon-size);
|
|
38
|
+
margin-right: calc(var(--window-icon-margin) - 0.1rem);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.Window-icon > div {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.Header > p {
|
|
47
|
+
user-select: none;
|
|
48
|
+
width: auto;
|
|
49
|
+
margin: 0;
|
|
50
|
+
margin-right: auto;
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
text-overflow: ellipsis;
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.Header-button {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
justify-content: center;
|
|
60
|
+
height: var(--header-height);
|
|
61
|
+
margin: 0;
|
|
62
|
+
padding: 0.75rem;
|
|
63
|
+
color: var(--foreground-color-0);
|
|
64
|
+
background: none;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
border: none;
|
|
67
|
+
outline: none;
|
|
68
|
+
aspect-ratio: 1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.Header-button > svg {
|
|
72
|
+
height: 100%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.Exit-button {
|
|
76
|
+
--header-button-hover-color: var(--red-0);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.Header-button:hover, .Header-button:focus-visible {
|
|
80
|
+
background-color: var(--header-button-hover-color);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.Window-content {
|
|
84
|
+
position: relative;
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
align-items: center;
|
|
89
|
+
width: 100%;
|
|
90
|
+
height: 100%;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { useScreenDimensions } from "../../../hooks/_utils/screen";
|
|
3
|
+
import { Vector2 } from "../../../features/math/vector2";
|
|
4
|
+
import styles from "./WindowedModal.module.css";
|
|
5
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
6
|
+
import { faXmark } from "@fortawesome/free-solid-svg-icons";
|
|
7
|
+
import Draggable from "react-draggable";
|
|
8
|
+
import { ReactSVG } from "react-svg";
|
|
9
|
+
import utilStyles from "../../../styles/utils.module.css";
|
|
10
|
+
import { ModalProps } from "../ModalView";
|
|
11
|
+
|
|
12
|
+
export function WindowedModal({ modal, params, children, ...props }: ModalProps) {
|
|
13
|
+
const nodeRef = useRef(null);
|
|
14
|
+
|
|
15
|
+
const [startPosition, setStartPosition] = useState(modal?.position);
|
|
16
|
+
const [screenWidth, screenHeight] = useScreenDimensions();
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (screenWidth == null || screenHeight == null) return;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if (modal?.position != null) {
|
|
23
|
+
if (modal.position.x > screenWidth) modal.position.x = 0;
|
|
24
|
+
if (modal.position.y > screenHeight) modal.position.y = 0;
|
|
25
|
+
|
|
26
|
+
setStartPosition(modal.position);
|
|
27
|
+
} else {
|
|
28
|
+
setStartPosition(new Vector2(0, 0));
|
|
29
|
+
}
|
|
30
|
+
}, [modal, screenHeight, screenWidth]);
|
|
31
|
+
|
|
32
|
+
return <Draggable
|
|
33
|
+
axis="both"
|
|
34
|
+
handle={".Window-handle"}
|
|
35
|
+
defaultPosition={startPosition}
|
|
36
|
+
position={undefined}
|
|
37
|
+
scale={1}
|
|
38
|
+
bounds={{
|
|
39
|
+
top: -(modal?.position.y ?? 0) - 1,
|
|
40
|
+
bottom: (screenHeight ?? 0) - 55 - (modal?.position.y ?? 0),
|
|
41
|
+
left: -(modal?.size.x ?? 0) + 85 - (modal?.position.x ?? 0),
|
|
42
|
+
right: (screenWidth ?? 0) - 5 - (modal?.position.x ?? 0)
|
|
43
|
+
}}
|
|
44
|
+
cancel="button"
|
|
45
|
+
nodeRef={nodeRef}
|
|
46
|
+
>
|
|
47
|
+
<div
|
|
48
|
+
className={styles.WindowedModal}
|
|
49
|
+
ref={nodeRef}
|
|
50
|
+
style={{
|
|
51
|
+
width: modal?.size.x ?? 0,
|
|
52
|
+
height: modal?.size.y ?? 0,
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
<div className={`${styles.Header} Window-handle`}>
|
|
56
|
+
<ReactSVG
|
|
57
|
+
className={styles["Window-icon"]}
|
|
58
|
+
src={params?.iconUrl as string}
|
|
59
|
+
/>
|
|
60
|
+
<p className={utilStyles.TextSemibold}>{params?.title as string}</p>
|
|
61
|
+
<button aria-label="Close" className={`${styles["Header-button"]} ${styles["Exit-button"]}`} tabIndex={0}
|
|
62
|
+
onClick={() => { modal?.close(); }}>
|
|
63
|
+
<FontAwesomeIcon icon={faXmark}/>
|
|
64
|
+
</button>
|
|
65
|
+
</div>
|
|
66
|
+
<div className={styles["Window-content"]} {...props}>
|
|
67
|
+
{children}
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</Draggable>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.DialogContent {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
align-items: center;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100%;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.DialogContent button {
|
|
13
|
+
margin-bottom: 0.75rem;
|
|
14
|
+
padding: 0.5rem 1rem;
|
|
15
|
+
width: fit-content;
|
|
16
|
+
color: var(--foreground-color-0);
|
|
17
|
+
background-color: var(--background-color-0);
|
|
18
|
+
border: none;
|
|
19
|
+
border-radius: var(--border-radius-1);
|
|
20
|
+
outline: none;
|
|
21
|
+
transition: background-color 100ms ease-in-out;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.DialogContent button:hover, .DialogContent button:focus-visible {
|
|
26
|
+
background-color: var(--background-color-1);
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DIALOG_CONTENT_TYPES } from "../../../constants/modals.const";
|
|
2
|
+
import { WindowedModal } from "../_utils/WindowedModal";
|
|
3
|
+
import { ModalProps } from "../ModalView";
|
|
4
|
+
import styles from "./DialogBox.module.css";
|
|
5
|
+
|
|
6
|
+
export function DialogBox({ modal, params, children, ...props }: ModalProps) {
|
|
7
|
+
const onClick = (event: MouseEvent) => {
|
|
8
|
+
event.preventDefault();
|
|
9
|
+
const attribute = (event.target as HTMLElement).getAttribute("data-type");
|
|
10
|
+
if (attribute == null) return;
|
|
11
|
+
|
|
12
|
+
const type = parseInt(attribute);
|
|
13
|
+
|
|
14
|
+
switch (type) {
|
|
15
|
+
case DIALOG_CONTENT_TYPES.closeButton:
|
|
16
|
+
modal?.close();
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return <WindowedModal modal={modal} params={params} onClick={onClick} {...props}>
|
|
22
|
+
<div className={styles.DialogContent}>
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
25
|
+
</WindowedModal>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.Footer {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: space-between;
|
|
4
|
+
align-items: center;
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.Selection > p {
|
|
9
|
+
font-size: 1rem;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.Buttons {
|
|
13
|
+
display: flex;
|
|
14
|
+
gap: 1rem;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
align-items: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.Button {
|
|
20
|
+
--normal-color: var(--background-color-0);
|
|
21
|
+
--hover-color: var(--background-color-1);
|
|
22
|
+
|
|
23
|
+
padding: 0.35rem 0.7rem;
|
|
24
|
+
border-radius: var(--border-radius-1);
|
|
25
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { Button } from "../../_utils/button/Button";
|
|
3
|
+
import { WindowedModal } from "../_utils/WindowedModal";
|
|
4
|
+
import styles from "./FileSelector.module.css";
|
|
5
|
+
import { ModalProps } from "../ModalView";
|
|
6
|
+
import { VirtualFile } from "../../../features/virtual-drive/file";
|
|
7
|
+
import { VirtualFolder } from "../../../features/virtual-drive/folder";
|
|
8
|
+
import { FileSelectorMode, fileExplorer } from "@prozilla-os/file-explorer";
|
|
9
|
+
|
|
10
|
+
interface FileSelectorProps extends ModalProps {
|
|
11
|
+
type: FileSelectorMode;
|
|
12
|
+
allowedFormats?: string[];
|
|
13
|
+
onFinish: (result: VirtualFile | VirtualFile[]) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function FileSelector({ modal, params, type, allowedFormats, onFinish, ...props }: FileSelectorProps) {
|
|
17
|
+
const multi = (type == FileSelectorMode.Multi);
|
|
18
|
+
|
|
19
|
+
const [selection, setSelection] = useState<string[] | null>(multi ? [] : null);
|
|
20
|
+
const [directory, setDirectory] = useState<VirtualFolder | null>(null);
|
|
21
|
+
|
|
22
|
+
const finish = (event: Event) => {
|
|
23
|
+
event?.preventDefault();
|
|
24
|
+
|
|
25
|
+
if (directory == null || selection == null)
|
|
26
|
+
return;
|
|
27
|
+
|
|
28
|
+
const files = selection.map((id) => {
|
|
29
|
+
const { name, extension } = VirtualFile.splitId(id);
|
|
30
|
+
return directory.findFile(name, extension);
|
|
31
|
+
}).filter((file) => {
|
|
32
|
+
if (file == null)
|
|
33
|
+
return false;
|
|
34
|
+
const validFormat = (allowedFormats == null || (file.extension != null && allowedFormats.includes(file.extension)));
|
|
35
|
+
return validFormat;
|
|
36
|
+
}) as VirtualFile[];
|
|
37
|
+
|
|
38
|
+
if (files.length === 0)
|
|
39
|
+
return;
|
|
40
|
+
|
|
41
|
+
modal?.close();
|
|
42
|
+
onFinish?.(multi ? files : files[0]);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return <WindowedModal modal={modal} params={{
|
|
46
|
+
title: multi ? "Select files" : "Select a file",
|
|
47
|
+
iconUrl: fileExplorer.iconUrl as string | undefined,
|
|
48
|
+
...params,
|
|
49
|
+
}} {...props}>
|
|
50
|
+
<fileExplorer.WindowContent
|
|
51
|
+
selectorMode={type}
|
|
52
|
+
Footer={() =>
|
|
53
|
+
<div className={styles.Footer}>
|
|
54
|
+
<span className={styles.Selection}>
|
|
55
|
+
{multi
|
|
56
|
+
? <p>Selected file(s): {selection != null ? selection.join(", ") : ""}</p>
|
|
57
|
+
: <p>Selected file: {selection ?? ""}</p>
|
|
58
|
+
}
|
|
59
|
+
</span>
|
|
60
|
+
<div className={styles.Buttons}>
|
|
61
|
+
<Button className={styles.Button} onClick={finish}>
|
|
62
|
+
Confirm
|
|
63
|
+
</Button>
|
|
64
|
+
<Button className={styles.Button} onClick={() => { modal?.close(); }}>
|
|
65
|
+
Cancel
|
|
66
|
+
</Button>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
}
|
|
70
|
+
onSelectionChange={({ files, directory }) => {
|
|
71
|
+
setSelection(files as string[] | null);
|
|
72
|
+
setDirectory(directory as VirtualFolder);
|
|
73
|
+
}}
|
|
74
|
+
onSelectionFinish={finish}
|
|
75
|
+
/>
|
|
76
|
+
</WindowedModal>;
|
|
77
|
+
}
|