Added active app indicator in taskbar
This commit is contained in:
parent
30046b6f77
commit
6f1b9fe148
5 changed files with 66 additions and 16 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
import { TaskBar } from "./components/TaskBar.js";
|
import { Taskbar } from "./components/Taskbar.js";
|
||||||
import { WindowsManagerProvider } from "./hooks/WindowsManagerContext.js";
|
import { WindowsManagerProvider } from "./hooks/WindowsManagerContext.js";
|
||||||
import { WindowsView } from "./components/WindowsView.js";
|
import { WindowsView } from "./components/WindowsView.js";
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@ function App() {
|
||||||
return (
|
return (
|
||||||
<WindowsManagerProvider>
|
<WindowsManagerProvider>
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<TaskBar/>
|
<Taskbar/>
|
||||||
<WindowsView/>
|
<WindowsView/>
|
||||||
</div>
|
</div>
|
||||||
</WindowsManagerProvider>
|
</WindowsManagerProvider>
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,31 @@
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.App-icon {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.App-icon::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
bottom: 0;
|
||||||
|
width: 90%;
|
||||||
|
height: 0.15rem;
|
||||||
|
background-color: var(--grey-a);
|
||||||
|
transition: height 200ms ease-in-out, width 200ms ease-in-out;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
-webkit-transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.App-icon:hover::after {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.App-icon:not(.Active)::after {
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.Util-icons {
|
.Util-icons {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import "./TaskBar.css";
|
import "./Taskbar.css";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faBatteryFull, faSearch, faVolumeHigh, faWifi } from "@fortawesome/free-solid-svg-icons";
|
import { faBatteryFull, faSearch, faVolumeHigh, faWifi } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { ReactSVG } from "react-svg";
|
|
||||||
import ApplicationsManager from "../modules/applications/applications.js";
|
import ApplicationsManager from "../modules/applications/applications.js";
|
||||||
import { useWindowsManager } from "../hooks/WindowsManagerContext.js";
|
import { AppButton } from "./task-bar/AppButton.js";
|
||||||
|
|
||||||
export function TaskBar() {
|
export function Taskbar() {
|
||||||
const [date, setDate] = useState(new Date());
|
const [date, setDate] = useState(new Date());
|
||||||
const windowsManager = useWindowsManager();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
|
@ -22,11 +20,9 @@ export function TaskBar() {
|
||||||
<button>
|
<button>
|
||||||
<FontAwesomeIcon icon={faSearch}/>
|
<FontAwesomeIcon icon={faSearch}/>
|
||||||
</button>
|
</button>
|
||||||
{ApplicationsManager.APPLICATIONS.map((app) => {
|
{ApplicationsManager.APPLICATIONS.map((app) =>
|
||||||
return (<button key={app.id} onClick={() => { windowsManager.open(app.id); }}>
|
<AppButton app={app} key={app.id}/>
|
||||||
<ReactSVG src={process.env.PUBLIC_URL + `/media/applications/icons/${app.id}.svg`}/>
|
)}
|
||||||
</button>);
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="Util-icons">
|
<div className="Util-icons">
|
||||||
<button>
|
<button>
|
||||||
|
|
|
||||||
19
src/components/task-bar/AppButton.js
Normal file
19
src/components/task-bar/AppButton.js
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { useWindows } from "../../hooks/WindowsContext.js";
|
||||||
|
import { useWindowsManager } from "../../hooks/WindowsManagerContext.js";
|
||||||
|
import { ReactSVG } from "react-svg";
|
||||||
|
|
||||||
|
export function AppButton({ app }) {
|
||||||
|
const [active, setActive] = useState(false);
|
||||||
|
const windows = useWindows();
|
||||||
|
const windowsManager = useWindowsManager();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setActive(windowsManager.isAppActive(app.id));
|
||||||
|
}, [windows]);
|
||||||
|
|
||||||
|
return (<button className={active ? "App-icon Active" : "App-icon"} key={app.id} onClick={() => { windowsManager.open(app.id); }}>
|
||||||
|
<ReactSVG src={process.env.PUBLIC_URL + `/media/applications/icons/${app.id}.svg`}/>
|
||||||
|
</button>);
|
||||||
|
}
|
||||||
|
|
@ -47,6 +47,20 @@ export default class WindowsManager {
|
||||||
// console.log(this);
|
// console.log(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isAppActive(appId) {
|
||||||
|
let active = false;
|
||||||
|
|
||||||
|
Object.values(this.windows).forEach((window) => {
|
||||||
|
console.log(window.app.id, appId);
|
||||||
|
if (window.app.id === appId) {
|
||||||
|
active = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
setUpdateWindows(updateWindows) {
|
setUpdateWindows(updateWindows) {
|
||||||
this.updateWindows = updateWindows;
|
this.updateWindows = updateWindows;
|
||||||
}
|
}
|
||||||
|
|
@ -54,8 +68,4 @@ export default class WindowsManager {
|
||||||
get windowIds() {
|
get windowIds() {
|
||||||
return Object.keys(this.windows);
|
return Object.keys(this.windows);
|
||||||
}
|
}
|
||||||
|
|
||||||
get windowsData() {
|
|
||||||
return Object.values(this.windows);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue