From 569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a Mon Sep 17 00:00:00 2001 From: piotrruss Date: Mon, 6 Sep 2021 23:13:22 +0200 Subject: added stadard linter --- helpers/windowActions.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'helpers/windowActions.js') diff --git a/helpers/windowActions.js b/helpers/windowActions.js index b6d86b6..090e20a 100644 --- a/helpers/windowActions.js +++ b/helpers/windowActions.js @@ -1,9 +1,9 @@ -export const close = (appName, setApps) => {setApps(apps => apps.filter(a => a && a.name !== appName))} +export const close = (appName, setApps) => { setApps(apps => apps.filter(a => a && a.name !== appName)) } -export const open = ({appName, buttons, height, width}, setApps) => { +export const open = ({ appName, buttons, height, width }, setApps) => { setApps(apps => ( !apps.some(a => a.name === appName) - ? [...apps, {name: appName, min: false, max: false, height, width, pos: [], buttons}] + ? [...apps, { name: appName, min: false, max: false, height, width, pos: [], buttons }] : apps )) } @@ -12,7 +12,7 @@ export const focus = (appName, setApps) => { setApps(apps => { const i = apps.findIndex(a => a.name === appName) return i !== apps.length - 1 - ? [...apps.filter((_,n) => n !== i), apps[i]] + ? [...apps.filter((_, n) => n !== i), apps[i]] : apps }) } @@ -21,23 +21,22 @@ export const unfocus = (appName, setApps) => { setApps(apps => { const i = apps.findIndex(a => a.name === appName) return i !== 0 - ? [apps[i], ...apps.filter((_,n) => n !== i)] + ? [apps[i], ...apps.filter((_, n) => n !== i)] : apps }) } export const toggleMin = (appName, setApps) => { setApps(apps => ([ - ...apps.map(a => a.name === appName ? {...a, min: !a.min} : a ) + ...apps.map(a => a.name === appName ? { ...a, min: !a.min } : a) ])) unfocus(appName, setApps) } export const toggleMax = (appName, setApps) => setApps(apps => ([ - ...apps.map(a => a.name === appName ? {...a, max: !a.max} : a ) + ...apps.map(a => a.name === appName ? { ...a, max: !a.max } : a) ])) - export const move = (app, winRef, setApps) => { winRef.current.onmousedown = (event) => { if (!app.max && event.target.classList && event.target.classList.contains('window__title')) { @@ -46,12 +45,12 @@ export const move = (app, winRef, setApps) => { winRef.current.classList.add('moving') focus(app.name, setApps) - function moveAt(pageX, pageY) { + function moveAt (pageX, pageY) { const x = pageX - shiftX const y = pageY - shiftY - 32 setApps(apps => ([...apps.map(a => a.name === app.name - ? {...a, pos: [x + 'px', y < 0 ? 0 : y + 'px']} + ? { ...a, pos: [x + 'px', y < 0 ? 0 : y + 'px'] } : a )])) } @@ -72,4 +71,3 @@ export const move = (app, winRef, setApps) => { winRef.current.ondragstart = () => null } - -- cgit v1.2.3