From d545a8d394206b717fb5458068ff7b129f942212 Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 6 Jan 2021 22:11:12 -0600 Subject: [PATCH] chore: lint --- app/package.json | 1 + app/src/react/components/renderer.jsx | 8 +++----- app/src/react/components/stage.jsx | 21 +++++++++++++++++---- app/src/react/components/ui.jsx | 22 +++++++++++++++++----- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/app/package.json b/app/package.json index bfffb92..73c87c7 100644 --- a/app/package.json +++ b/app/package.json @@ -39,6 +39,7 @@ "@latus/user": "2.0.0", "dotenv": "8.2.0", "pixi.js": "^5.3.7", + "prop-types": "^15.7.2", "react": "^17.0.1", "react-hot-loader": "4.13.0" }, diff --git a/app/src/react/components/renderer.jsx b/app/src/react/components/renderer.jsx index 2ca439e..2934d43 100644 --- a/app/src/react/components/renderer.jsx +++ b/app/src/react/components/renderer.jsx @@ -1,5 +1,5 @@ -import {Color, Renderer, Primitives} from '@avocado/graphics'; -import {PixiComponent} from '@inlet/react-pixi' +import {Color, Primitives} from '@avocado/graphics'; +import {PixiComponent} from '@inlet/react-pixi'; const primitives = new Primitives(); primitives.drawCircle( @@ -12,7 +12,5 @@ primitives.drawCircle( ); export default PixiComponent('Humus', { - create: props => { - return primitives.internal - }, + create: () => primitives.internal, }); diff --git a/app/src/react/components/stage.jsx b/app/src/react/components/stage.jsx index f35d37d..ca1095c 100644 --- a/app/src/react/components/stage.jsx +++ b/app/src/react/components/stage.jsx @@ -1,17 +1,30 @@ import './stage.scss'; -import {Stage} from '@inlet/react-pixi' +import {Stage as PStage} from '@inlet/react-pixi'; +import PropTypes from 'prop-types'; import React from 'react'; import Renderer from './renderer'; -export default ({width = 800, height = 450}) => ( +const Stage = ({width, height}) => (
- - +
); + +Stage.defaultProps = { + height: 450, + width: 800, +}; + +Stage.propTypes = { + height: PropTypes.number, + width: PropTypes.number, +}; + +export default Stage; diff --git a/app/src/react/components/ui.jsx b/app/src/react/components/ui.jsx index b8dd30d..f4f5cb6 100644 --- a/app/src/react/components/ui.jsx +++ b/app/src/react/components/ui.jsx @@ -1,16 +1,16 @@ import './ui.scss'; +import PropTypes from 'prop-types'; import React, {useEffect, useRef} from 'react'; -export default ({width = 800, height = 450}) => { - const RATIO = width / height; +const Ui = ({width, height}) => { const $ui = useRef(); useEffect(() => { if (!$ui.current) { return undefined; } const onResize = () => { - const {overflow} = window.document.documentElement.style; + const RATIO = width / height; const {innerWidth, innerHeight} = window; const ratio = innerWidth / innerHeight; let scale; @@ -28,7 +28,7 @@ export default ({width = 800, height = 450}) => { window.addEventListener('resize', onResize); onResize(); return () => window.removeEventListener('resize', onResize); - }, $ui); + }, [$ui, height, width]); return (
{ width: `${width}px`, }} > - +
); }; + +Ui.defaultProps = { + height: 450, + width: 800, +}; + +Ui.propTypes = { + height: PropTypes.number, + width: PropTypes.number, +}; + +export default Ui;