Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimization: added lazy loading for all modals #557

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ gh-pages/
npm-debug.log*
build/
*.sw[pomn]
# That's /src/lib/aframe-loader-3dtiles-component.min.js
dist/48406973e3ad4d65cbdd.js*
dist/aframe-mapbox-component.min.js
dist/notyf.min.css
dist/viewer-styles.css
dist
3 changes: 0 additions & 3 deletions dist/aframe-street-component.js

This file was deleted.

26 changes: 14 additions & 12 deletions src/editor/components/Main.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { Button, HelpButton, Logo, ZoomButtons } from './components';
import { CameraToolbar } from './viewport';
import { Compass32Icon } from '../icons';
import { Component } from 'react';
import ComponentsSidebar from './components/Sidebar';
import { Compass32Icon } from '../icons';
import Events from '../lib/Events';
import { ModalHelp } from './modals/ModalHelp';
import ModalTextures from './modals/ModalTextures';
import { Button, HelpButton, Logo, ZoomButtons } from './components';
import ComponentsSidebar from './components/Sidebar';
import {
ModalHelp,
ModalTextures,
ProfileModal,
ScenesModal,
ScreenshotModal,
SignInModal
} from './modals';
import SceneGraph from './scenegraph/SceneGraph';
import { ScreenshotModal } from './modals/ScreenshotModal';
import TransformToolbar from './viewport/TransformToolbar';
import { CameraToolbar, TransformToolbar } from './viewport';
// import ViewportHUD from "./viewport/ViewportHUD";
import { injectCSS } from '../lib/utils';
import { SignInModal } from './modals/SignInModal';
import { ProfileModal } from './modals/ProfileModal';
import { ScenesModal } from './modals/ScenesModal';
import { SceneEditTitle } from './components/SceneEditTitle';
import { AddLayerButton } from './components/AddLayerButton';
import { AddLayerPanel } from './components/AddLayerPanel';
import { SceneEditTitle } from './components/SceneEditTitle';

THREE.ImageUtils.crossOrigin = '';
// Megahack to include font-awesome.
injectCSS(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import Events from '../../lib/Events';
import Modal from './Modal.jsx';
import { insertNewAsset } from '../../lib/assetsUtils';
import Events from '../../../lib/Events.js';
import Modal from '../Modal.jsx';
import { insertNewAsset } from '../../../lib/assetsUtils.js';

function getFilename(url, converted = false) {
var filename = url.split('/').pop();
Expand All @@ -29,7 +29,7 @@ function getValidId(name) {
.toLowerCase();
}

export default class ModalTextures extends React.Component {
class ModalTextures extends React.Component {
static propTypes = {
isOpen: PropTypes.bool,
onClose: PropTypes.func,
Expand Down Expand Up @@ -426,3 +426,5 @@ export default class ModalTextures extends React.Component {
);
}
}

export { ModalTextures };
1 change: 1 addition & 0 deletions src/editor/components/modals/ModalTextures/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ModalTextures } from './ModalTextures.js';
45 changes: 45 additions & 0 deletions src/editor/components/modals/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { lazy } from 'react';

const ModalHelp = lazy(() =>
import('./ModalHelp').then((module) => ({ default: module.ModalHelp }))
);
const ModalTextures = lazy(() =>
import('./ModalTextures').then((module) => ({
default: module.ModalTextures
}))
);
const ScreenshotModal = lazy(() =>
import('./ScreenshotModal').then((module) => ({
default: module.ScreenshotModal
}))
);
const SignInModal = lazy(() =>
import('./SignInModal').then((module) => ({
default: module.SignInModal
}))
);
const ProfileModal = lazy(() =>
import('./ProfileModal').then((module) => ({
default: module.ProfileModal
}))
);
const ScenesModal = lazy(() =>
import('./ScenesModal').then((module) => ({
default: module.ScenesModal
}))
);
const SavingModal = lazy(() =>
import('./SavingModal').then((module) => ({
default: module.SavingModal
}))
);

export {
ModalHelp,
ModalTextures,
ScreenshotModal,
SignInModal,
ProfileModal,
ScenesModal,
SavingModal
};
2 changes: 1 addition & 1 deletion src/editor/components/scenegraph/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Cloud24Icon, RemixIcon, Save24Icon, Upload24Icon } from '../../icons';
import Events from '../../lib/Events';
import { saveBlob } from '../../lib/utils';
import { Button, ProfileButton, ScreenshotButton } from '../components';
import { SavingModal } from '../modals/SavingModal';
import { SavingModal } from '../modals';
import { uploadThumbnailImage } from '../modals/ScreenshotModal/ScreenshotModal.component.jsx';
import { sendMetric } from '../../services/ga.js';

Expand Down
4 changes: 3 additions & 1 deletion src/editor/components/viewport/TransformToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var TransformButtons = [
{ value: 'scale', icon: 'fa-expand' }
];

export default class TransformToolbar extends React.Component {
class TransformToolbar extends React.Component {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -93,3 +93,5 @@ export default class TransformToolbar extends React.Component {
);
}
}

export { TransformToolbar };
1 change: 1 addition & 0 deletions src/editor/components/viewport/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { CameraToolbar } from './CameraToolbar';
export { TransformToolbar } from './TransformToolbar';
Loading