chore: tidy
This commit is contained in:
parent
40a02ea088
commit
5af4fcf6a5
|
@ -1,10 +1,11 @@
|
||||||
// 3rd party.
|
// 3rd party.
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import React, {useEffect, useState} from 'react';
|
import React, {useState} from 'react';
|
||||||
// 2nd party.
|
// 2nd party.
|
||||||
import {compose} from '@avocado/core';
|
import {compose} from '@avocado/core';
|
||||||
import contempo from 'contempo';
|
import contempo from 'contempo';
|
||||||
// 1st party.
|
// 1st party.
|
||||||
|
import {useEvent} from '../hooks/use-event';
|
||||||
import QuickStatus from './quick-status';
|
import QuickStatus from './quick-status';
|
||||||
import Hotbar from './hotbar';
|
import Hotbar from './hotbar';
|
||||||
import Inventory from './inventory';
|
import Inventory from './inventory';
|
||||||
|
@ -16,21 +17,14 @@ const decorate = compose(
|
||||||
|
|
||||||
const MenuComponent = ({app}) => {
|
const MenuComponent = ({app}) => {
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
useEffect(() => {
|
useEvent(app, 'isMenuOpenedChanged', (_, isOpened) => {
|
||||||
const onMenuOpenedChanged = () => {
|
setOpened(isOpened);
|
||||||
setOpened(app.isMenuOpened);
|
});
|
||||||
}
|
|
||||||
onMenuOpenedChanged();
|
|
||||||
app.on('isMenuOpenedChanged', onMenuOpenedChanged);
|
|
||||||
return () => {
|
|
||||||
app.off('isMenuOpenedChanged', onMenuOpenedChanged);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
return <div className="menu unselectable">
|
return <div className="menu unselectable">
|
||||||
<div className={classnames(
|
<div className={classnames(
|
||||||
'menu-inner',
|
'menu-inner',
|
||||||
opened ? 'open' : '',
|
opened ? 'open' : '',
|
||||||
)}>
|
)}>
|
||||||
<Inventory app={app} />
|
<Inventory app={app} />
|
||||||
<QuickStatus app={app} />
|
<QuickStatus app={app} />
|
||||||
<WorldTime worldTime={app.worldTime} />
|
<WorldTime worldTime={app.worldTime} />
|
||||||
|
|
Loading…
Reference in New Issue
Block a user