[🎨] Moved interfaces to types.ts

This commit is contained in:
ThinLiquid 2023-10-16 20:18:39 +01:00
parent 640e3bdc8d
commit 4bb2ffa187
3 changed files with 28 additions and 27 deletions

View file

@ -1,17 +1,10 @@
import { App } from './types.ts' import { Flow } from './types.ts'
import SettingsApp from './apps/settings.ts' import SettingsApp from './apps/settings.ts'
import FilesApp from './apps/files.ts' import FilesApp from './apps/files.ts'
import MusicApp from './apps/music.ts' import MusicApp from './apps/music.ts'
import EditorApp from './apps/editor.ts' import EditorApp from './apps/editor.ts'
interface Flow {
apps: {
[key: string]: App
}
openApp: Function
}
const flow: Flow = { const flow: Flow = {
apps: { apps: {
'flow.settings': new SettingsApp(), 'flow.settings': new SettingsApp(),

View file

@ -32,3 +32,21 @@ export interface AppClosedEvent extends CustomEvent {
win: FlowWindow 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
}

View file

@ -1,16 +1,6 @@
import flow from './flow.ts' import flow from './flow.ts'
import { v4 as uuid } from 'uuid' import { v4 as uuid } from 'uuid'
import { FlowWindowConfig } from './types.ts'
interface FlowWindowConfig {
title: string
icon: string
width?: number
height?: number
minWidth?: number
minHeight?: number
}
function dragElement (element: HTMLElement, container: HTMLElement): void { function dragElement (element: HTMLElement, container: HTMLElement): void {
let posX = 0; let posY = 0 let posX = 0; let posY = 0
@ -176,13 +166,13 @@ export class FlowWindow {
} }
class WM { class WM {
launcherOpen = false private isLauncherOpen = false
area: HTMLElement windowArea: HTMLElement
launcher: HTMLElement launcher: HTMLElement
windows: FlowWindow[] = [] windows: FlowWindow[] = []
constructor () { constructor () {
this.area = document.createElement('window-area') this.windowArea = document.createElement('window-area')
this.launcher = document.createElement('launcher') this.launcher = document.createElement('launcher')
this.init() this.init()
@ -205,12 +195,12 @@ class WM {
createWindow (config: FlowWindowConfig): FlowWindow { createWindow (config: FlowWindowConfig): FlowWindow {
const win = new FlowWindow(this, config) const win = new FlowWindow(this, config)
this.windows.push(win) this.windows.push(win)
this.area.appendChild(win.element) this.windowArea.appendChild(win.element)
return win return win
} }
toggleLauncher (): boolean { toggleLauncher (): boolean {
if (this.launcherOpen) { if (this.isLauncherOpen) {
this.launcher.style.opacity = '0' this.launcher.style.opacity = '0'
this.launcher.style.backdropFilter = 'blur(0px)' this.launcher.style.backdropFilter = 'blur(0px)'
this.launcher.style.pointerEvents = 'none' this.launcher.style.pointerEvents = 'none'
@ -220,8 +210,8 @@ class WM {
this.launcher.style.pointerEvents = 'all' this.launcher.style.pointerEvents = 'all'
} }
this.launcherOpen = !this.launcherOpen this.isLauncherOpen = !this.isLauncherOpen
return this.launcherOpen return this.isLauncherOpen
} }
private init (): void { private init (): void {
@ -254,7 +244,7 @@ class WM {
this.launcher.querySelector('apps')?.appendChild(app) this.launcher.querySelector('apps')?.appendChild(app)
} }
document.body.appendChild(this.area) document.body.appendChild(this.windowArea)
document.body.appendChild(this.launcher) document.body.appendChild(this.launcher)
} }
} }