[🎨] Moved interfaces to types.ts
This commit is contained in:
parent
640e3bdc8d
commit
4bb2ffa187
3 changed files with 28 additions and 27 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
18
src/types.ts
18
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
|
||||
}
|
||||
|
|
|
|||
28
src/wm.ts
28
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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue