The start menu is not working
Browse files- components/taskbar.js +30 -10
- components/window.js +3 -3
- script.js +15 -3
components/taskbar.js
CHANGED
|
@@ -110,33 +110,53 @@ class CustomTaskbar extends HTMLElement {
|
|
| 110 |
setInterval(() => this.updateClock(), 60000);
|
| 111 |
|
| 112 |
this.shadowRoot.getElementById('start-button').addEventListener('click', () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
windowManager.createWindow({
|
| 114 |
id: 'start-menu',
|
| 115 |
title: 'Start Menu',
|
| 116 |
content: `
|
| 117 |
<div class="p-4 grid grid-cols-3 gap-4">
|
| 118 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
<i data-feather="user" class="w-8 h-8 mb-2"></i>
|
| 120 |
<span>About</span>
|
| 121 |
-
</
|
| 122 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
<i data-feather="folder" class="w-8 h-8 mb-2"></i>
|
| 124 |
<span>Projects</span>
|
| 125 |
-
</
|
| 126 |
-
<
|
| 127 |
<i data-feather="mail" class="w-8 h-8 mb-2"></i>
|
| 128 |
<span>Contact</span>
|
| 129 |
-
</
|
| 130 |
-
<
|
| 131 |
<i data-feather="settings" class="w-8 h-8 mb-2"></i>
|
| 132 |
<span>Settings</span>
|
| 133 |
-
</
|
| 134 |
</div>
|
| 135 |
`,
|
| 136 |
icon: 'grid',
|
| 137 |
-
initialPosition: { x: 50, y: window.innerHeight -
|
|
|
|
|
|
|
| 138 |
});
|
| 139 |
-
}
|
|
|
|
| 140 |
|
| 141 |
feather.replace();
|
| 142 |
}
|
|
|
|
| 110 |
setInterval(() => this.updateClock(), 60000);
|
| 111 |
|
| 112 |
this.shadowRoot.getElementById('start-button').addEventListener('click', () => {
|
| 113 |
+
const existingStartMenu = document.querySelector('custom-window[id="start-menu"]');
|
| 114 |
+
|
| 115 |
+
if (existingStartMenu) {
|
| 116 |
+
windowManager.closeWindow('start-menu');
|
| 117 |
+
} else {
|
| 118 |
windowManager.createWindow({
|
| 119 |
id: 'start-menu',
|
| 120 |
title: 'Start Menu',
|
| 121 |
content: `
|
| 122 |
<div class="p-4 grid grid-cols-3 gap-4">
|
| 123 |
+
<a href="#" class="p-4 flex flex-col items-center cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 rounded" onclick="windowManager.createWindow({
|
| 124 |
+
id: 'about',
|
| 125 |
+
title: 'About Me.txt',
|
| 126 |
+
content: document.querySelector('custom-window[id=\\'about\\']').innerHTML,
|
| 127 |
+
icon: 'user',
|
| 128 |
+
initialPosition: { x: 100, y: 100 }
|
| 129 |
+
}); windowManager.closeWindow('start-menu'); return false;">
|
| 130 |
<i data-feather="user" class="w-8 h-8 mb-2"></i>
|
| 131 |
<span>About</span>
|
| 132 |
+
</a>
|
| 133 |
+
<a href="#" class="p-4 flex flex-col items-center cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 rounded" onclick="windowManager.createWindow({
|
| 134 |
+
id: 'projects',
|
| 135 |
+
title: 'Projects Explorer',
|
| 136 |
+
content: document.querySelector('custom-window[id=\\'projects\\']').innerHTML,
|
| 137 |
+
icon: 'folder',
|
| 138 |
+
initialPosition: { x: 300, y: 150 }
|
| 139 |
+
}); windowManager.closeWindow('start-menu'); return false;">
|
| 140 |
<i data-feather="folder" class="w-8 h-8 mb-2"></i>
|
| 141 |
<span>Projects</span>
|
| 142 |
+
</a>
|
| 143 |
+
<a href="#" class="p-4 flex flex-col items-center cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 rounded">
|
| 144 |
<i data-feather="mail" class="w-8 h-8 mb-2"></i>
|
| 145 |
<span>Contact</span>
|
| 146 |
+
</a>
|
| 147 |
+
<a href="#" class="p-4 flex flex-col items-center cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 rounded">
|
| 148 |
<i data-feather="settings" class="w-8 h-8 mb-2"></i>
|
| 149 |
<span>Settings</span>
|
| 150 |
+
</a>
|
| 151 |
</div>
|
| 152 |
`,
|
| 153 |
icon: 'grid',
|
| 154 |
+
initialPosition: { x: 50, y: window.innerHeight - 250 },
|
| 155 |
+
width: 400,
|
| 156 |
+
height: 300
|
| 157 |
});
|
| 158 |
+
}
|
| 159 |
+
});
|
| 160 |
|
| 161 |
feather.replace();
|
| 162 |
}
|
components/window.js
CHANGED
|
@@ -32,10 +32,10 @@ class CustomWindow extends HTMLElement {
|
|
| 32 |
<style>
|
| 33 |
:host {
|
| 34 |
position: absolute;
|
| 35 |
-
width: 500px;
|
| 36 |
max-width: 90vw;
|
| 37 |
-
min-height: 300px;
|
| 38 |
-
|
| 39 |
border-radius: 8px;
|
| 40 |
overflow: hidden;
|
| 41 |
display: flex;
|
|
|
|
| 32 |
<style>
|
| 33 |
:host {
|
| 34 |
position: absolute;
|
| 35 |
+
width: var(--window-width, 500px);
|
| 36 |
max-width: 90vw;
|
| 37 |
+
min-height: var(--window-min-height, 300px);
|
| 38 |
+
background-color: rgba(255, 255, 255, 0.9);
|
| 39 |
border-radius: 8px;
|
| 40 |
overflow: hidden;
|
| 41 |
display: flex;
|
script.js
CHANGED
|
@@ -81,17 +81,29 @@ class WindowManager {
|
|
| 81 |
this.windows = [];
|
| 82 |
this.zIndexCounter = 10;
|
| 83 |
}
|
| 84 |
-
|
| 85 |
createWindow(options) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
const windowElement = document.createElement('custom-window');
|
| 87 |
windowElement.setAttribute('id', options.id);
|
| 88 |
windowElement.setAttribute('title', options.title);
|
| 89 |
windowElement.setAttribute('icon', options.icon);
|
| 90 |
windowElement.setAttribute('initial-x', options.initialPosition.x);
|
| 91 |
windowElement.setAttribute('initial-y', options.initialPosition.y);
|
| 92 |
-
windowElement.innerHTML = options.content;
|
| 93 |
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
this.windows.push({
|
| 96 |
id: options.id,
|
| 97 |
element: windowElement,
|
|
|
|
| 81 |
this.windows = [];
|
| 82 |
this.zIndexCounter = 10;
|
| 83 |
}
|
|
|
|
| 84 |
createWindow(options) {
|
| 85 |
+
const existingWindow = document.querySelector(`custom-window[id="${options.id}"]`);
|
| 86 |
+
if (existingWindow) {
|
| 87 |
+
this.bringToFront(existingWindow);
|
| 88 |
+
return;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
const windowElement = document.createElement('custom-window');
|
| 92 |
windowElement.setAttribute('id', options.id);
|
| 93 |
windowElement.setAttribute('title', options.title);
|
| 94 |
windowElement.setAttribute('icon', options.icon);
|
| 95 |
windowElement.setAttribute('initial-x', options.initialPosition.x);
|
| 96 |
windowElement.setAttribute('initial-y', options.initialPosition.y);
|
|
|
|
| 97 |
|
| 98 |
+
if (options.width) {
|
| 99 |
+
windowElement.style.width = `${options.width}px`;
|
| 100 |
+
}
|
| 101 |
+
if (options.height) {
|
| 102 |
+
windowElement.style.minHeight = `${options.height}px`;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
windowElement.innerHTML = options.content;
|
| 106 |
+
document.querySelector('desktop-shell').appendChild(windowElement);
|
| 107 |
this.windows.push({
|
| 108 |
id: options.id,
|
| 109 |
element: windowElement,
|