refactor(modules): experimental changes to module structure

This commit is contained in:
David Ralph 2024-02-18 23:27:38 +00:00
parent 10f12b20c5
commit 618b5fe466
85 changed files with 73 additions and 72 deletions

View File

@ -6,9 +6,9 @@ import Background from 'features/widgets/background/Background';
import Widgets from 'features/widgets/Widgets';
import Modals from 'features/modals/Modals';
import { loadSettings, moveSettings } from 'modules/helpers/settings';
import { loadSettings, moveSettings } from 'utils/helpers/settings';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
export default class App extends PureComponent {
componentDidMount() {

View File

@ -2,7 +2,7 @@ import variables from 'config/variables';
import { PureComponent } from 'react';
import { Checkbox as CheckboxUI, FormControlLabel } from '@mui/material';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
class Checkbox extends PureComponent {
constructor(props) {

View File

@ -2,7 +2,7 @@ import variables from 'config/variables';
import { PureComponent, createRef } from 'react';
import { InputLabel, MenuItem, FormControl, Select } from '@mui/material';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
class Dropdown extends PureComponent {
constructor(props) {

View File

@ -2,7 +2,7 @@ import variables from 'config/variables';
import { PureComponent } from 'react';
import { toast } from 'react-toastify';
import { compressAccurately, filetoDataURL } from 'image-conversion';
import { videoCheck } from 'modules/helpers/background/widget';
import { videoCheck } from 'utils/helpers/background/widget';
class FileUpload extends PureComponent {
componentDidMount() {

View File

@ -8,8 +8,8 @@ import {
FormLabel,
} from '@mui/material';
import EventBus from 'modules/helpers/eventbus';
import { translations } from 'modules/translations';
import EventBus from 'utils/helpers/eventbus';
import { translations } from 'utils/translations';
class Radio extends PureComponent {
constructor(props) {

View File

@ -4,7 +4,7 @@ import { toast } from 'react-toastify';
import { Slider } from '@mui/material';
import { MdRefresh } from 'react-icons/md';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
class SliderComponent extends PureComponent {
constructor(props) {

View File

@ -2,7 +2,7 @@ import variables from 'config/variables';
import { PureComponent } from 'react';
import { Switch as SwitchUI, FormControlLabel } from '@mui/material';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
class Switch extends PureComponent {
constructor(props) {

View File

@ -4,7 +4,7 @@ import { toast } from 'react-toastify';
import { TextField } from '@mui/material';
import { MdRefresh } from 'react-icons/md';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
class Text extends PureComponent {
constructor(props) {

View File

@ -6,7 +6,7 @@ import {
MdOutlineVisibility,
MdOutlineKeyboardArrowRight,
} from 'react-icons/md';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import { Button } from 'components/Elements';
export const CustomActions = ({ children }) => {

View File

@ -3,8 +3,8 @@ import { Row, Content, Action } from '../Item/SettingsItem';
import variables from 'config/variables';
import Slider from '../../../Form/Settings/Slider/Slider';
import { values } from 'modules/helpers/settings/modals';
import EventBus from 'modules/helpers/eventbus';
import { values } from 'utils/helpers/settings/modals';
import EventBus from 'utils/helpers/eventbus';
const PreferencesWrapper = ({ children, ...props }) => {
const [shown, setShown] = useState(localStorage.getItem(props.setting) === 'true');

View File

@ -1,5 +1,5 @@
import * as constants from 'config/constants';
import Stats from 'modules/helpers/stats';
import Stats from 'utils/helpers/stats';
const variables = {
language: {},

View File

@ -1,6 +1,6 @@
import { PureComponent } from 'react';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import './autocomplete.scss';

View File

@ -6,7 +6,7 @@ import Main from './main/Main';
import Navbar from '../widgets/navbar/Navbar';
import Preview from '../helpers/preview/Preview';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import Welcome from './welcome/Welcome';

View File

@ -20,7 +20,7 @@ import Modal from 'react-modal';
import { Header } from 'components/Layout/Settings';
import { Button } from 'components/Elements';
import { install, uninstall } from 'modules/helpers/marketplace';
import { install, uninstall } from 'utils/helpers/marketplace';
import { ShareModal } from 'components/Elements';

View File

@ -12,7 +12,7 @@ import Dropdown from '../../../../../components/Form/Settings/Dropdown/Dropdown'
import { Header, CustomActions } from 'components/Layout/Settings';
import { Button } from 'components/Elements';
import { install, uninstall, urlParser } from 'modules/helpers/marketplace';
import { install, uninstall, urlParser } from 'utils/helpers/marketplace';
export default class Added extends PureComponent {
constructor() {

View File

@ -16,7 +16,7 @@ import Dropdown from '../../../../../components/Form/Settings/Dropdown/Dropdown'
import { Header } from 'components/Layout/Settings';
import { Button } from 'components/Elements';
import { install, urlParser, uninstall } from 'modules/helpers/marketplace';
import { install, urlParser, uninstall } from 'utils/helpers/marketplace';
class Marketplace extends PureComponent {
constructor() {

View File

@ -1,7 +1,7 @@
import { memo } from 'react';
import variables from 'config/variables';
import { MdClose, MdRestartAlt } from 'react-icons/md';
import { setDefaultSettings } from 'modules/helpers/settings';
import { setDefaultSettings } from 'utils/helpers/settings';
import { Tooltip } from 'components/Elements';
function ResetModal({ modalClose }) {
const reset = () => {

View File

@ -6,7 +6,7 @@ import { SiGithubsponsors, SiOpencollective } from 'react-icons/si';
import { BiDonateHeart } from 'react-icons/bi';
import { Tooltip } from 'components/Elements';
import other_contributors from 'modules/other_contributors.json';
import other_contributors from 'utils/data/other_contributors.json';
export default class About extends PureComponent {
constructor() {

View File

@ -8,7 +8,7 @@ import {
MdDataUsage,
} from 'react-icons/md';
import { exportSettings, importSettings } from 'modules/helpers/settings/modals';
import { exportSettings, importSettings } from 'utils/helpers/settings/modals';
import { FileUpload, Text, Switch, Dropdown } from 'components/Form/Settings';
import ResetModal from '../ResetModal';

View File

@ -7,7 +7,7 @@ import { Header, Section, Row, Content, Action } from 'components/Layout/Setting
import { MdAccessibility } from 'react-icons/md';
import { values } from 'modules/helpers/settings/modals';
import { values } from 'utils/helpers/settings/modals';
function AppearanceSettings() {
const [accessibility, setAccessibility] = useState(false);

View File

@ -4,8 +4,8 @@ import Checkbox from '../../../../../components/Form/Settings/Checkbox/Checkbox'
import Slider from '../../../../../components/Form/Settings/Slider/Slider';
import { TextField } from '@mui/material';
import EventBus from 'modules/helpers/eventbus';
import { values } from 'modules/helpers/settings/modals';
import EventBus from 'utils/helpers/eventbus';
import { values } from 'utils/helpers/settings/modals';
import { Row, Content, Action } from '../../../../../components/Layout/Settings/Item/SettingsItem';

View File

@ -5,7 +5,7 @@ import { toast } from 'react-toastify';
import { TextareaAutosize } from '@mui/material';
import { Header, Row, Content, Action, PreferencesWrapper } from 'components/Layout/Settings';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
export default class Message extends PureComponent {
constructor() {

View File

@ -13,7 +13,7 @@ import { Button } from 'components/Elements';
import { Row, Content, Action } from '../../../../../components/Layout/Settings/Item/SettingsItem';
import { Header } from 'components/Layout/Settings';
import { getTitleFromUrl, isValidUrl } from 'modules/helpers/settings/modals';
import { getTitleFromUrl, isValidUrl } from 'utils/helpers/settings/modals';
import QuickLink from './quicklinks/QuickLink';
function Navbar() {

View File

@ -11,7 +11,7 @@ import QuickLinks from './overview_skeletons/QuickLinks';
import Date from './overview_skeletons/Date';
import Message from './overview_skeletons/Message';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
const widget_name = {
greeting: variables.getMessage('modals.main.settings.sections.greeting.title'),

View File

@ -8,9 +8,9 @@ import Modal from 'react-modal';
import AddModal from './quicklinks/AddModal';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import QuickLink from './quicklinks/QuickLink';
import { getTitleFromUrl, isValidUrl } from 'modules/helpers/settings/modals';
import { getTitleFromUrl, isValidUrl } from 'utils/helpers/settings/modals';
export default class QuickLinks extends PureComponent {
constructor() {

View File

@ -14,7 +14,7 @@ import {
import { Checkbox, Dropdown } from 'components/Form/Settings';
import { toast } from 'react-toastify';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
export default class QuoteSettings extends PureComponent {
constructor() {

View File

@ -6,7 +6,7 @@ import { MenuItem, TextField } from '@mui/material';
import { Header, Row, Content, Action, PreferencesWrapper } from 'components/Layout/Settings';
import { Dropdown, Checkbox } from 'components/Form/Settings';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import searchEngines from 'features/widgets/search/search_engines.json';

View File

@ -8,10 +8,10 @@ import { toast } from 'react-toastify';
import { Button } from 'components/Elements';
import { Header, CustomActions } from 'components/Layout/Settings';
import { saveFile } from 'modules/helpers/settings/modals';
import { saveFile } from 'utils/helpers/settings/modals';
import achievementsData from 'modules/helpers/settings/achievements.json';
import translations from 'modules/helpers/settings/achievement_translations/index';
import achievementsData from 'utils/data/achievements.json';
import translations from 'i18n/locales/achievements/index';
const achievementLanguage = {
de_DE: translations.de_DE,

View File

@ -19,7 +19,7 @@ import Text from '../../../../../../components/Form/Settings/Text/Text';
import ColourSettings from './Colour';
import CustomSettings from './Custom';
import { values } from 'modules/helpers/settings/modals';
import { values } from 'utils/helpers/settings/modals';
export default class BackgroundSettings extends PureComponent {
constructor() {

View File

@ -8,8 +8,8 @@ import {
Action,
} from '../../../../../../components/Layout/Settings/Item/SettingsItem';
import hexToRgb from 'modules/helpers/background/hexToRgb';
import rgbToHex from 'modules/helpers/background/rgbToHex';
import hexToRgb from 'utils/helpers/background/hexToRgb';
import rgbToHex from 'utils/helpers/background/rgbToHex';
//import '@muetab/react-color-gradient-picker/dist/index.css';
import '../../../scss/settings/react-color-picker-gradient-picker-custom-styles.scss';

View File

@ -9,9 +9,9 @@ import {
MdOutlineFileUpload,
MdFolder,
} from 'react-icons/md';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import { compressAccurately, filetoDataURL } from 'image-conversion';
import { videoCheck } from 'modules/helpers/background/widget';
import { videoCheck } from 'utils/helpers/background/widget';
import Checkbox from '../../../../../../components/Form/Settings/Checkbox/Checkbox';
import FileUpload from '../../../../../../components/Form/Settings/FileUpload/FileUpload';

View File

@ -2,9 +2,9 @@ import variables from 'config/variables';
import { useState } from 'react';
import { FileUpload } from 'components/Form/Settings';
import { MdCloudUpload } from 'react-icons/md';
import { importSettings as importSettingsFunction } from 'modules/helpers/settings/modals';
import { importSettings as importSettingsFunction } from 'utils/helpers/settings/modals';
import { Header } from '../components/Layout';
import default_settings from 'modules/default_settings.json';
import default_settings from 'utils/data/default_settings.json';
function ImportSettings(props) {
const [importedSettings, setImportedSettings] = useState([]);

View File

@ -1,7 +1,7 @@
import variables from 'config/variables';
import { useState } from 'react';
import { MdAutoAwesome, MdLightMode, MdDarkMode } from 'react-icons/md';
import { loadSettings } from 'modules/helpers/settings';
import { loadSettings } from 'utils/helpers/settings';
import { Header } from '../components/Layout';
function ThemeSelection() {

View File

@ -2,7 +2,7 @@ import variables from 'config/variables';
import { PureComponent } from 'react';
import { MdArrowBackIosNew, MdArrowForwardIos, MdOutlinePreview } from 'react-icons/md';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import { ProgressBar } from './components/Elements';
import { Button } from 'components/Elements';

View File

@ -15,10 +15,10 @@ import {
import { FaDiscord, FaGithub } from 'react-icons/fa';
import { Radio, Checkbox, FileUpload } from 'components/Form/Settings';
import { loadSettings } from 'modules/helpers/settings';
import { importSettings } from 'modules/helpers/settings/modals';
import { loadSettings } from 'utils/helpers/settings';
import { importSettings } from 'utils/helpers/settings/modals';
import default_settings from 'modules/default_settings.json';
import default_settings from 'utils/data/default_settings.json';
import languages from '@/i18n/languages.json';
class WelcomeSections extends PureComponent {

View File

@ -9,7 +9,7 @@ import Date from './time/Date';
import Message from './message/Message';
import { WidgetsLayout } from 'components/Layout';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
// weather is lazy loaded due to the size of the weather icons module
// since we're using react-icons this might not be accurate,

View File

@ -5,17 +5,17 @@ import { PureComponent } from 'react';
import PhotoInformation from './PhotoInformation';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import {
videoCheck,
offlineBackground,
getGradient,
randomColourStyleBuilder,
} from 'modules/helpers/background/widget';
} from 'utils/helpers/background/widget';
import './scss/index.scss';
import { decodeBlurHash } from 'fast-blurhash';
import { supportsAVIF } from 'modules/helpers/background/avif';
import { supportsAVIF } from 'utils/helpers/background/avif';
export default class Background extends PureComponent {
constructor() {

View File

@ -1,6 +1,6 @@
import variables from 'config/variables';
import { memo } from 'react';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import { Tooltip } from 'components/Elements';
import { MdClose, MdDone } from 'react-icons/md';

View File

@ -1,8 +1,8 @@
import variables from 'config/variables';
import { PureComponent, createRef } from 'react';
import { nth, convertTimezone } from 'modules/helpers/date';
import EventBus from 'modules/helpers/eventbus';
import { nth, convertTimezone } from 'utils/helpers/date';
import EventBus from 'utils/helpers/eventbus';
import './greeting.scss';

View File

@ -1,5 +1,5 @@
import { useState, useEffect, useRef } from 'react';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import './message.scss';
const Message = () => {

View File

@ -6,7 +6,7 @@ import { MdPlaylistRemove, MdOutlineApps } from 'react-icons/md';
import { Tooltip } from 'components/Elements';
import { shift, useFloating } from '@floating-ui/react-dom';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
class Apps extends PureComponent {
constructor() {

View File

@ -8,7 +8,7 @@ import Todo from './Todo';
import Apps from './Apps';
import Maximise from '../background/Maximise';
import { Tooltip } from 'components/Elements';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import './scss/index.scss';

View File

@ -7,8 +7,8 @@ import TextareaAutosize from '@mui/material/TextareaAutosize';
import { toast } from 'react-toastify';
import { Tooltip } from 'components/Elements';
import { saveFile } from 'modules/helpers/settings/modals';
import EventBus from 'modules/helpers/eventbus';
import { saveFile } from 'utils/helpers/settings/modals';
import EventBus from 'utils/helpers/eventbus';
class Notes extends PureComponent {
constructor() {

View File

@ -15,7 +15,7 @@ import { Tooltip } from 'components/Elements';
import Checkbox from '@mui/material/Checkbox';
import { shift, useFloating } from '@floating-ui/react-dom';
import { sortableContainer, sortableElement, sortableHandle } from '@muetab/react-sortable-hoc';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
const SortableItem = sortableElement(({ value }) => <div>{value}</div>);
const SortableContainer = sortableContainer(({ children }) => <div>{children}</div>);

View File

@ -1,7 +1,7 @@
import { PureComponent, createRef } from 'react';
import { Tooltip } from 'components/Elements';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import './quicklinks.scss';

View File

@ -18,7 +18,7 @@ import { ShareModal } from 'components/Elements';
import offline_quotes from './offline_quotes.json';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import './quote.scss';

View File

@ -7,7 +7,7 @@ import { FaYandex } from 'react-icons/fa';
import { Tooltip } from 'components/Elements';
import AutocompleteInput from 'features/helpers/autocomplete/Autocomplete';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import './search.scss';

View File

@ -1,7 +1,7 @@
import { PureComponent, Suspense, lazy } from 'react';
import { convertTimezone } from 'modules/helpers/date';
import EventBus from 'modules/helpers/eventbus';
import { convertTimezone } from 'utils/helpers/date';
import EventBus from 'utils/helpers/eventbus';
import './clock.scss';

View File

@ -1,8 +1,8 @@
import variables from 'config/variables';
import { PureComponent, createRef } from 'react';
import { nth, convertTimezone } from '../../../modules/helpers/date';
import EventBus from 'modules/helpers/eventbus';
import { nth, convertTimezone } from 'utils/helpers/date';
import EventBus from 'utils/helpers/eventbus';
import './date.scss';

View File

@ -4,7 +4,7 @@ import { PureComponent } from 'react';
import WeatherIcon from './WeatherIcon';
import Expanded from './Expanded';
import EventBus from 'modules/helpers/eventbus';
import EventBus from 'utils/helpers/eventbus';
import './weather.scss';

View File

@ -10,7 +10,7 @@ import './scss/index.scss';
// the toast css is based on default so we need to import it
import 'react-toastify/dist/ReactToastify.min.css';
import { initTranslations } from './modules/translations';
import { initTranslations } from 'utils/translations';
const languagecode = localStorage.getItem('language') || 'en_GB';
variables.language = initTranslations(languagecode);

View File

View File

@ -1,5 +1,5 @@
// since there is so much code in the component, we have moved it to a separate file
import offlineImages from './offlineImages.json';
import offlineImages from 'utils/data/offline_images.json';
/**
* If the URL starts with `data:video/` or ends with `.mp4`, `.webm`, or `.ogg`, then it's a video.

View File

@ -1,7 +1,7 @@
import variables from 'config/variables';
import experimentalInit from '../experimental';
import defaultSettings from 'modules/default_settings.json';
import defaultSettings from 'utils/data/default_settings.json';
import languages from '@/i18n/languages.json';
/**

View File

@ -98,9 +98,10 @@ export default defineConfig(({ command, mode }) => {
extensions: ['.js', '.jsx'],
alias: {
'@': path.resolve(__dirname, './src'),
i18n: path.resolve(__dirname, './src/i18n'),
features: path.resolve(__dirname, './src/features'),
components: path.resolve(__dirname, './src/components'),
modules: path.resolve(__dirname, './src/modules'),
utils: path.resolve(__dirname, './src/utils'),
translations: path.resolve(__dirname, './src/i18n/locales'),
config: path.resolve(__dirname, './src/config'),
scss: path.resolve(__dirname, './src/scss'),