Skip to content

Commit

Permalink
Merge pull request #122 from Exabyte-io/update/SOF-6455
Browse files Browse the repository at this point in the history
SOF-6455: Upgrade Wave to MUI 5 or above
  • Loading branch information
unsigned6 committed Feb 7, 2023
2 parents 0121fa9 + 7a82d22 commit 7b07f14
Show file tree
Hide file tree
Showing 9 changed files with 596 additions and 378 deletions.
853 changes: 530 additions & 323 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@
"@babel/preset-env": "7.16.4",
"@babel/preset-react": "7.16.7",
"@babel/runtime-corejs2": "7.16.7",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@exabyte-io/periodic-table.js": "2022.5.5-2",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.7",
"@mui/styles": "^5.11.7",
"classnames": "2.3.1",
"enzyme-adapter-react-16": "^1.15.6",
"jquery": "3.6.0",
"mixwith": "^0.1.1",
"prop-types": "^15.8.0",
"react-bootstrap": "0.32.4",
"react-jss": "^8.6.1",
"react-scripts": "^4.0.3",
"sass": "1.45.2",
"sprintf-js": "^1.1.2",
Expand Down
3 changes: 3 additions & 0 deletions src/MuiClassNameSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { unstable_ClassNameGenerator as ClassNameGenerator } from "@mui/material/className";

ClassNameGenerator.configure((componentName) => `wave-${componentName}`);
12 changes: 6 additions & 6 deletions src/components/AlertDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// TODO: move that component to cove.js and reuse it here
import Button from "@material-ui/core/Button";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogContentText from "@material-ui/core/DialogContentText";
import DialogTitle from "@material-ui/core/DialogTitle";
import Button from "@mui/material/Button";
import Dialog from "@mui/material/Dialog";
import DialogActions from "@mui/material/DialogActions";
import DialogContent from "@mui/material/DialogContent";
import DialogContentText from "@mui/material/DialogContentText";
import DialogTitle from "@mui/material/DialogTitle";
import React, { useImperativeHandle, useState } from "react";

export const AlertDialog = React.forwardRef((props, ref) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/IconToolbar.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Close from "@material-ui/icons/Close";
import Close from "@mui/icons-material/Close";
import setClass from "classnames";
import PropTypes from "prop-types";
import React from "react";
Expand All @@ -17,7 +17,7 @@ export class IconToolbar extends React.Component {
}

// eslint-disable-next-line no-unused-vars
handleToggleActive(e) {
handleToggleActive() {
const { isActive } = this.state;
this.setState({ isActive: !isActive });
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/LoadingIndicator.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CircularProgress from "@material-ui/core/CircularProgress";
import CircularProgress from "@mui/material/CircularProgress";
import React from "react";

export const LoadingIndicator = function LoadingIndicator() {
Expand Down
12 changes: 9 additions & 3 deletions src/components/RoundIconButton.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import IconButton from "@material-ui/core/IconButton";
import Tooltip from "@material-ui/core/Tooltip";
import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip";
import PropTypes from "prop-types";
import React from "react";
import _ from "underscore";
Expand Down Expand Up @@ -30,7 +30,12 @@ export class RoundIconButton extends React.Component {
const { id, label, title, onClick, tooltipPlacement, isToggleable } = this.props;
const { isToggled } = this.state;
return (
<Tooltip id={id} title={title.toUpperCase()} placement={tooltipPlacement}>
<Tooltip
id={id}
title={title.toUpperCase()}
placement={tooltipPlacement}
disableInteractive
>
<IconButton
aria-checked={isToggleable && isToggled}
aria-label={label || title.toLowerCase()}
Expand All @@ -49,6 +54,7 @@ export class RoundIconButton extends React.Component {
"isToggleable",
"isToggled",
)}
size="large"
/>
</Tooltip>
);
Expand Down
79 changes: 39 additions & 40 deletions src/components/ThreeDEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
/* eslint-disable react/sort-comp */
// import "../MuiClassNameSetup";

import { Made } from "@exabyte-io/made.js";
import { createGenerateClassName, Tooltip } from "@material-ui/core";
import Autorenew from "@material-ui/icons/Autorenew";
import BubbleChart from "@material-ui/icons/BubbleChart";
import CloudDownload from "@material-ui/icons/CloudDownload";
import ControlCameraRounded from "@material-ui/icons/ControlCameraRounded";
import DeleteIcon from "@material-ui/icons/Delete";
import Edit from "@material-ui/icons/Edit";
import FormatShapes from "@material-ui/icons/FormatShapes";
import GpsFixed from "@material-ui/icons/GpsFixed";
import HeightIcon from "@material-ui/icons/Height";
import ImportExport from "@material-ui/icons/ImportExport";
import LooksIcon from "@material-ui/icons/Looks";
import Menu from "@material-ui/icons/Menu";
import NotInterested from "@material-ui/icons/NotInterested";
import PictureInPicture from "@material-ui/icons/PictureInPicture";
import PowerSettingsNew from "@material-ui/icons/PowerSettingsNew";
import RemoveRedEye from "@material-ui/icons/RemoveRedEye";
import Replay from "@material-ui/icons/Replay";
import Spellcheck from "@material-ui/icons/Spellcheck";
import SquareFootIcon from "@material-ui/icons/SquareFoot";
import SwitchCamera from "@material-ui/icons/SwitchCamera";
import ThreeDRotation from "@material-ui/icons/ThreeDRotation";
import Autorenew from "@mui/icons-material/Autorenew";
import BubbleChart from "@mui/icons-material/BubbleChart";
import CloudDownload from "@mui/icons-material/CloudDownload";
import ControlCameraRounded from "@mui/icons-material/ControlCameraRounded";
import DeleteIcon from "@mui/icons-material/Delete";
import Edit from "@mui/icons-material/Edit";
import FormatShapes from "@mui/icons-material/FormatShapes";
import GpsFixed from "@mui/icons-material/GpsFixed";
import HeightIcon from "@mui/icons-material/Height";
import ImportExport from "@mui/icons-material/ImportExport";
import LooksIcon from "@mui/icons-material/Looks";
import Menu from "@mui/icons-material/Menu";
import NotInterested from "@mui/icons-material/NotInterested";
import PictureInPicture from "@mui/icons-material/PictureInPicture";
import PowerSettingsNew from "@mui/icons-material/PowerSettingsNew";
import RemoveRedEye from "@mui/icons-material/RemoveRedEye";
import Replay from "@mui/icons-material/Replay";
import Spellcheck from "@mui/icons-material/Spellcheck";
import SquareFootIcon from "@mui/icons-material/SquareFoot";
import SwitchCamera from "@mui/icons-material/SwitchCamera";
import ThreeDRotation from "@mui/icons-material/ThreeDRotation";
import { Tooltip } from "@mui/material";
import { StyledEngineProvider } from "@mui/material/styles";
import setClass from "classnames";
import $ from "jquery";
import PropTypes from "prop-types";
import React from "react";
import { JssProvider } from "react-jss";

import settings from "../settings";
import { exportToDisk } from "../utils";
Expand All @@ -35,12 +37,6 @@ import { RoundIconButton } from "./RoundIconButton";
import { ThreejsEditorModal } from "./ThreejsEditorModal";
import { WaveComponent } from "./WaveComponent";

/**
* This is to avoid class name conflicts when the component is used inside other material-ui dependent components.
* See https://material-ui.com/customization/css-in-js/#creategenerateclassname-options-class-name-generator for more information.
*/
const generateClassName = createGenerateClassName({ productionPrefix: "wave" });

/**
* Wrapper component containing 3D visualization through `WaveComponent` and the associated controls
*/
Expand Down Expand Up @@ -171,10 +167,7 @@ export class ThreeDEditor extends React.Component {

// eslint-disable-next-line class-methods-use-this
getPrimitiveOrConventionalMaterial(material, isConventionalCellShown = false) {
const primitiveOrConventionalMaterial = isConventionalCellShown
? material.getACopyWithConventionalCell()
: material.clone();
return primitiveOrConventionalMaterial;
return isConventionalCellShown ? material.getACopyWithConventionalCell() : material.clone();
}

handleToggleConventionalCell() {
Expand Down Expand Up @@ -450,7 +443,12 @@ export class ThreeDEditor extends React.Component {
isToggled={this._getWaveProperty("isDrawBondsEnabled")}
onClick={this.handleToggleBonds}
>
<Menu />
<Menu
anchorOrigin={{
vertical: "top",
horizontal: "left",
}}
/>
</RoundIconButton>,

<RoundIconButton
Expand Down Expand Up @@ -572,7 +570,7 @@ export class ThreeDEditor extends React.Component {
getParametersToolbarItems() {
const { viewerSettings } = this.state;
return [
<Tooltip key="RADIUS" title="RADIUS" placement="top">
<Tooltip key="RADIUS" title="RADIUS" placement="top" disableInteractive>
<input
className="inverse stepper sphere-radius"
id="sphere-radius"
Expand All @@ -585,7 +583,7 @@ export class ThreeDEditor extends React.Component {
/>
</Tooltip>,

<Tooltip key="A" title="A" placement="top">
<Tooltip key="A" title="A" placement="top" disableInteractive>
<input
className="inverse stepper cell-repetitions"
id="repetitionsAlongLatticeVectorA"
Expand All @@ -598,7 +596,7 @@ export class ThreeDEditor extends React.Component {
/>
</Tooltip>,

<Tooltip key="B" title="B" placement="top">
<Tooltip key="B" title="B" placement="top" disableInteractive>
<input
className="inverse stepper cell-repetitions"
id="repetitionsAlongLatticeVectorB"
Expand All @@ -611,7 +609,7 @@ export class ThreeDEditor extends React.Component {
/>
</Tooltip>,

<Tooltip key="C" title="C" placement="top">
<Tooltip key="C" title="C" placement="top" disableInteractive>
<input
className="inverse stepper cell-repetitions"
id="repetitionsAlongLatticeVectorC"
Expand All @@ -628,6 +626,7 @@ export class ThreeDEditor extends React.Component {
key="CHEMICAL_CONNECTIVITY_FACTOR"
title="CHEMICAL CONNECTIVITY FACTOR"
placement="top"
disableInteractive
>
<input
className="inverse stepper cell-repetitions"
Expand Down Expand Up @@ -782,9 +781,9 @@ export class ThreeDEditor extends React.Component {

render() {
return (
<JssProvider generateClassName={generateClassName}>
<StyledEngineProvider injectFirst>
{this.renderWaveOrThreejsEditorModal()}
</JssProvider>
</StyledEngineProvider>
);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./stylesheets/main.scss";
import "./MuiClassNameSetup";

import { Made } from "@exabyte-io/made.js";
import React from "react";
Expand Down

0 comments on commit 7b07f14

Please sign in to comment.