aboutsummaryrefslogtreecommitdiffstats
path: root/components/App.js
blob: 02443f3e5a51de1b2f5e9f7ff2b5fd73b87c8d87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React, {useState, useEffect, useRef} from 'react'
import useUser from 'lib/useUser'
import fetchJson from 'lib/fetchJson'
import {close, toggleMin, toggleMax, move} from 'helpers/windowActions'
import {Layout} from 'components'

const App = ({children, app, apps, setApps}) => {
  const winRef = useRef(null);
  const [errorMsg, setErrorMsg] = useState('')

  useEffect(() => {
    move(app.name, winRef, apps, setApps)
  }, [])

  return (
    <>
      <div
        ref={winRef}
        className={
          'list window'
          + (app.min ? ' hidden' : '')
          + (app.max ? ' maximized' : '')
        }
      style={app.pos.length ? {top: app.pos[1], left: app.pos[0]} : {}}
      >
        <div className='window__title'>Notes</div>
        <div className='window__title-buttons'>
          <span onClick={() => toggleMin('Notes', apps, setApps)}>_</span>
          <span onClick={() => toggleMax('Notes', apps, setApps)}>+</span>
          <span onClick={() => close('Notes', apps, setApps)}>x</span>
        </div>
        <div className='window__content'>{children}</div>
      </div>
    </>
  )
}

export default App;