aboutsummaryrefslogtreecommitdiffstats
path: root/components/App.js
blob: a68e593ef51fc24061f0a8e3b3df41a95b29061e (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
39
40
41
42
43
import React, {useEffect, useRef} from 'react'
import {close, toggleMin, toggleMax, move} from 'helpers/windowActions'
import {faArrowUp, faExpandAlt, faTimes, faCompressAlt} from '@fortawesome/free-solid-svg-icons'
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'

const App = ({children, app, apps, setApps}) => {
  const winRef = useRef(null);

  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]} : {}}
        tabIndex={0}
      >
        <h2 className='window__title'>Notes</h2>
        <div className='window__title-buttons'>
          <span onClick={() => toggleMin('Notes', apps, setApps)}>
            <FontAwesomeIcon icon={faArrowUp} />
          </span>
          <span onClick={() => toggleMax('Notes', apps, setApps)}>
            <FontAwesomeIcon icon={app.max ? faCompressAlt : faExpandAlt} />
          </span>
          <span onClick={() => close('Notes', apps, setApps)}>
            <FontAwesomeIcon icon={faTimes} />
          </span>
        </div>
        <div className='window__content'>{children}</div>
      </div>
    </>
  )
}

export default App;