Files
mue/src/features/modals/main/Main.jsx
David Ralph 10f12b20c5 7.x Structural Changes (#637)
* refactor(files): Initial commit on experimental file structure

* refactor(structure): New components system

* refactor(structure): Tidy settings' components

* Refactor(structure): Component exports and imports

* refactor(settings): Use new component imports

* feat: unified background.js script

* fix(build): Partially, distributions still not ready

* feat: critical error on noscript, light theme support for it

* fix(background): Critical issue of code making every background #000

* refactor(welcome): Partition into different files + shared components
- This took too long and destroyed my sanity

---------

Co-authored-by: alexsparkes <turbomarshmello@gmail.com>
Co-authored-by: alexsparkes <alexsparkes@gmail.com>
2024-02-18 23:05:15 +00:00

64 lines
1.8 KiB
JavaScript

import variables from 'config/variables';
import { Suspense, lazy, useState, memo } from 'react';
import { MdClose } from 'react-icons/md';
import './scss/index.scss';
import { Tooltip } from 'components/Elements';
const Settings = lazy(() => import('./tabs/Settings'));
const Addons = lazy(() => import('./tabs/Addons'));
const Marketplace = lazy(() => import('./tabs/Marketplace'));
const renderLoader = () => (
<div style={{ display: 'flex', width: '100%', minHeight: '100%' }}>
<ul className="sidebar">
<span className="mainTitle">Mue</span>
</ul>
<div className="tab-content">
<div className="emptyItems">
<div className="emptyMessage">
<div className="loaderHolder">
<div id="loader"></div>
<span className="subtitle">{variables.getMessage('modals.main.loading')}</span>
</div>
</div>
</div>
</div>
</div>
);
function MainModal({ modalClose }) {
const [currentTab, setCurrentTab] = useState('settings');
const changeTab = (type) => {
setCurrentTab(type);
};
const renderTab = () => {
switch (currentTab) {
case 'addons':
return <Addons changeTab={changeTab} />;
case 'marketplace':
return <Marketplace changeTab={changeTab} />;
default:
return <Settings changeTab={changeTab} />;
}
};
return (
<div className="frame">
<Tooltip
style={{ position: 'absolute', top: '1rem', right: '1rem' }}
title={variables.getMessage('modals.welcome.buttons.close')}
key="closeTooltip"
>
<span className="closeModal" onClick={modalClose}>
<MdClose />
</span>
</Tooltip>
<Suspense fallback={renderLoader()}>{renderTab()}</Suspense>
</div>
);
}
export default memo(MainModal);