From 569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a Mon Sep 17 00:00:00 2001 From: piotrruss Date: Mon, 6 Sep 2021 23:13:22 +0200 Subject: added stadard linter --- components/App.js | 40 ++++++++++++++-------------- components/Form.js | 74 ++++++++++++++++++++++++++-------------------------- components/Header.js | 73 ++++++++++++++++++++++++++------------------------- components/Layout.js | 20 +++++--------- components/Popup.js | 9 +++---- components/Splash.js | 8 +++--- components/index.js | 12 ++++----- 7 files changed, 115 insertions(+), 121 deletions(-) (limited to 'components') diff --git a/components/App.js b/components/App.js index c539e72..84268cb 100644 --- a/components/App.js +++ b/components/App.js @@ -1,53 +1,53 @@ -import React, {useEffect, useRef} from 'react' +import { useEffect, useRef } from 'react' import useSettings from 'hooks/useSettings' import useMediaQuery from 'hooks/useMediaQuery' -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' +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' -const App = ({children, app, setApps}) => { - const {t} = useSettings() - const winRef = useRef(null); - const forceMax = useMediaQuery(`(max-width: ${app.width}), (max-height: ${app.height})`); +const App = ({ children, app, setApps }) => { + const { t } = useSettings() + const winRef = useRef(null) + const forceMax = useMediaQuery(`(max-width: ${app.width}), (max-height: ${app.height})`) useEffect(() => { move(app, winRef, setApps) - }, []) + }, [app, setApps]) return (
{focus(app.name, setApps)}} + onClick={() => { focus(app.name, setApps) }} className={ - 'window' - + (app.min ? ' hidden' : '') - + (app.max || forceMax ? ' maximized' : '') + '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: app.pos[1], left: app.pos[0] } : { top: `calc((( 100vh - ${app.height} ) / 2) + 2em)`, - left: `calc(( 100vw - ${app.width} ) / 2)`, - } + left: `calc(( 100vw - ${app.width} ) / 2)` + } }} >

{t(app.name)}

{children}
- { app.buttons.includes('min') && ( + {app.buttons.includes('min') && ( toggleMin(app.name, setApps)}> )} - { app.buttons.includes('max') && !forceMax && ( + {app.buttons.includes('max') && !forceMax && ( toggleMax(app.name, setApps)}> )} - { app.buttons.includes('close') && ( + {app.buttons.includes('close') && ( close(app.name, setApps)}> @@ -57,4 +57,4 @@ const App = ({children, app, setApps}) => { ) } -export default App; +export default App diff --git a/components/Form.js b/components/Form.js index 9a17660..681f13a 100644 --- a/components/Form.js +++ b/components/Form.js @@ -3,65 +3,65 @@ import React from 'react' import PropTypes from 'prop-types' import useSettings from 'hooks/useSettings' -const Form = ({errorMessage, onSubmit, isLogin}) => { - const {settings, setSettings, t} = useSettings() +const Form = ({ errorMessage, onSubmit, isLogin }) => { + const { settings, setSettings, t } = useSettings() const themeChange = c => { - setSettings(prev => ({...prev, theme: c})) + setSettings(prev => ({ ...prev, theme: c })) } const languageChange = l => { - setSettings(prev => ({...prev, language: l})) + setSettings(prev => ({ ...prev, language: l })) } return (
-
+
{isLogin ? t('log_in') : t('register_user')}
- - + + {!isLogin && ( <> - + {t('language')}
- {['en', 'pl', 'es', 'de'].map(l => ( -
- languageChange(l)} - /> - -
- ))} + {['en', 'pl', 'es', 'de'].map(l => ( +
+ languageChange(l)} + /> + +
+ ))}
{t('color_theme')}
- {['green', 'blue', 'black'].map(c => ( -
- themeChange(c)} - /> -
- ))} + {['green', 'blue', 'black'].map(c => ( +
+ themeChange(c)} + /> +
+ ))}
)} - + - {errorMessage &&

{t(errorMessage)}

} + {errorMessage &&

{t(errorMessage)}

} ) } @@ -70,5 +70,5 @@ export default Form Form.propTypes = { errorMessage: PropTypes.string, - onSubmit: PropTypes.func, + onSubmit: PropTypes.func } diff --git a/components/Header.js b/components/Header.js index 83f0ff9..32ec977 100644 --- a/components/Header.js +++ b/components/Header.js @@ -1,27 +1,26 @@ import styles from 'styles/Main.module.scss' -import React, {useState} from 'react' -import {useRouter} from 'next/router' +import React, { useState } from 'react' +import { useRouter } from 'next/router' import Link from 'next/link' import useUser from 'hooks/useUser' import fetchJson from 'helpers/fetchJson' -import {focus, toggleMin} from 'helpers/windowActions' -import {open, close} from 'helpers/windowActions' +import { focus, toggleMin, open, close } from 'helpers/windowActions' import appList from 'configs/appList' import useSettings from 'hooks/useSettings' -import {faTimes} from '@fortawesome/free-solid-svg-icons' -import {FontAwesomeIcon} from '@fortawesome/react-fontawesome' +import { faTimes } from '@fortawesome/free-solid-svg-icons' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -const Header = ({apps, setApps}) => { +const Header = ({ apps, setApps }) => { const [userMenu, setUserMenu] = useState(false) const [showApps, setShowApps] = useState(false) - const {user, mutateUser} = useUser() - const {t} = useSettings() + const { user, mutateUser } = useUser() + const { t } = useSettings() const router = useRouter() const handleLogout = async (e) => { e.preventDefault() mutateUser( - await fetchJson('/api/logout', {method: 'POST'}), + await fetchJson('/api/logout', { method: 'POST' }), false ) router.push('/login') @@ -39,13 +38,13 @@ const Header = ({apps, setApps}) => {