From 1e14a1101933dcfec3f357c590a455649db375ff Mon Sep 17 00:00:00 2001 From: piotrruss Date: Sat, 4 Sep 2021 21:55:21 +0200 Subject: add mobile styles --- components/App.js | 81 +++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) (limited to 'components/App.js') diff --git a/components/App.js b/components/App.js index b24aead..c539e72 100644 --- a/components/App.js +++ b/components/App.js @@ -1,7 +1,7 @@ import React, {useEffect, useRef} from 'react' import useSettings from 'hooks/useSettings' import useMediaQuery from 'hooks/useMediaQuery' -import {close, toggleMin, toggleMax, move} from 'helpers/windowActions' +import {close, toggleMin, toggleMax, move, focus} from 'helpers/windowActions' import {faArrowUp, faExpandAlt, faTimes, faCompressAlt} from '@fortawesome/free-solid-svg-icons' import {FontAwesomeIcon} from '@fortawesome/react-fontawesome' @@ -11,50 +11,49 @@ const App = ({children, app, setApps}) => { const forceMax = useMediaQuery(`(max-width: ${app.width}), (max-height: ${app.height})`); useEffect(() => { - move(app.name, winRef, setApps) + move(app, winRef, setApps) }, []) return ( - <> -
-

{t(app.name)}

-
{children}
-
- { app.buttons.includes('min') && ( - toggleMin(app.name, setApps)}> - - - )} - { app.buttons.includes('max') && !forceMax && ( - toggleMax(app.name, setApps)}> - - - )} - { app.buttons.includes('close') && ( - close(app.name, setApps)}> - - - )} -
+
{focus(app.name, setApps)}} + className={ + 'window' + + (app.min ? ' hidden' : '') + + (app.max || forceMax ? ' maximized' : '') + } + style={{ + height: app.height, + width: app.width, + ...app.pos.length + ? {top: app.pos[1], left: app.pos[0]} + : { + top: `calc((( 100vh - ${app.height} ) / 2) + 2em)`, + left: `calc(( 100vw - ${app.width} ) / 2)`, + } + }} + > +

{t(app.name)}

+
{children}
+
+ { app.buttons.includes('min') && ( + toggleMin(app.name, setApps)}> + + + )} + { app.buttons.includes('max') && !forceMax && ( + toggleMax(app.name, setApps)}> + + + )} + { app.buttons.includes('close') && ( + close(app.name, setApps)}> + + + )}
- +
) } -- cgit v1.2.3