From 4bb2ffa187c624b39972191d044adf7ff98d2bbf Mon Sep 17 00:00:00 2001 From: ThinLiquid Date: Mon, 16 Oct 2023 20:18:39 +0100 Subject: [PATCH] =?UTF-8?q?[=F0=9F=8E=A8]=20Moved=20interfaces=20to=20type?= =?UTF-8?q?s.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/flow.ts | 9 +-------- src/types.ts | 18 ++++++++++++++++++ src/wm.ts | 28 +++++++++------------------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/flow.ts b/src/flow.ts index 520def3..5be8f64 100644 --- a/src/flow.ts +++ b/src/flow.ts @@ -1,17 +1,10 @@ -import { App } from './types.ts' +import { Flow } from './types.ts' import SettingsApp from './apps/settings.ts' import FilesApp from './apps/files.ts' import MusicApp from './apps/music.ts' import EditorApp from './apps/editor.ts' -interface Flow { - apps: { - [key: string]: App - } - openApp: Function -} - const flow: Flow = { apps: { 'flow.settings': new SettingsApp(), diff --git a/src/types.ts b/src/types.ts index 81ef828..d6748be 100644 --- a/src/types.ts +++ b/src/types.ts @@ -32,3 +32,21 @@ export interface AppClosedEvent extends CustomEvent { win: FlowWindow } } + +export interface FlowWindowConfig { + title: string + icon: string + + width?: number + height?: number + + minWidth?: number + minHeight?: number +} + +export interface Flow { + apps: { + [key: string]: App + } + openApp: Function +} diff --git a/src/wm.ts b/src/wm.ts index d852999..4e97706 100644 --- a/src/wm.ts +++ b/src/wm.ts @@ -1,16 +1,6 @@ import flow from './flow.ts' import { v4 as uuid } from 'uuid' - -interface FlowWindowConfig { - title: string - icon: string - - width?: number - height?: number - - minWidth?: number - minHeight?: number -} +import { FlowWindowConfig } from './types.ts' function dragElement (element: HTMLElement, container: HTMLElement): void { let posX = 0; let posY = 0 @@ -176,13 +166,13 @@ export class FlowWindow { } class WM { - launcherOpen = false - area: HTMLElement + private isLauncherOpen = false + windowArea: HTMLElement launcher: HTMLElement windows: FlowWindow[] = [] constructor () { - this.area = document.createElement('window-area') + this.windowArea = document.createElement('window-area') this.launcher = document.createElement('launcher') this.init() @@ -205,12 +195,12 @@ class WM { createWindow (config: FlowWindowConfig): FlowWindow { const win = new FlowWindow(this, config) this.windows.push(win) - this.area.appendChild(win.element) + this.windowArea.appendChild(win.element) return win } toggleLauncher (): boolean { - if (this.launcherOpen) { + if (this.isLauncherOpen) { this.launcher.style.opacity = '0' this.launcher.style.backdropFilter = 'blur(0px)' this.launcher.style.pointerEvents = 'none' @@ -220,8 +210,8 @@ class WM { this.launcher.style.pointerEvents = 'all' } - this.launcherOpen = !this.launcherOpen - return this.launcherOpen + this.isLauncherOpen = !this.isLauncherOpen + return this.isLauncherOpen } private init (): void { @@ -254,7 +244,7 @@ class WM { this.launcher.querySelector('apps')?.appendChild(app) } - document.body.appendChild(this.area) + document.body.appendChild(this.windowArea) document.body.appendChild(this.launcher) } }