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

Upgraded MaterialUI to v5 #244

Open
wants to merge 6 commits into
base: master
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- [#219](https://github.com/equinor/webviz-core-components/pull/219) - Pinned `dash` version to `2.4.x`, added more info output to GitHub workflow, switched to React version `16.14.0` in order to comply with non-maintained `react-colorscales` requirements, implemented adjustments to `Overlay` and `ScrollArea`
- [#240](https://github.com/equinor/webviz-core-components/pull/240) - Settings groups remain open when others are toggled (independent toggle state).
- [#244](https://github.com/equinor/webviz-core-components/pull/244) - Upgraded `MaterialUI` to `v5`.

## [0.5.7] - 2022-05-05

Expand Down
9,278 changes: 5,034 additions & 4,244 deletions react/package-lock.json

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@
"author": "Equinor <noreply@equinor.com>",
"license": "MIT",
"dependencies": {
"@equinor/eds-core-react": "^0.17.0",
"@emerson-eps/color-tables": "^0.4.9",
"@emotion/react": "^11.10.0",
"@emotion/styled": "^11.10.0",
"@equinor/eds-core-react": "^0.20.4",
"@equinor/eds-icons": "^0.10.0",
"@material-ui/core": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.57",
"@mui/icons-material": "^5.10.2",
"@mui/lab": "*",
"@mui/material": "^5.10.2",
"@mui/styles": "^5.10.2",
"@react-hook/size": "^2.1.2",
"animate.css": "^4.1.1",
"classnames": "^2.2.6",
"html2canvas": "^1.0.0-rc.7",
"lodash": "^4.17.21",
"notistack": "^1.0.5",
"react-colorscales": "^0.7.3",
"notistack": "^2.0.5",
"react-draggable": "^4.4.4",
"react-is": "^17.0.2",
"reactour": "^1.18.3",
"styled-components": "^5.2.1",
"uuid": "^8.3.2"
},
Expand All @@ -76,7 +78,6 @@
"@types/lodash": "^4.14.176",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"@types/reactour": "^1.18.1",
"@types/uuid": "^8.3.2",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
Expand All @@ -95,10 +96,10 @@
"jest": "^26.6.3",
"mini-css-extract-plugin": "^1.3.9",
"prop-types": "^15.7.2",
"react": "^16.14.0",
"react": "^17.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to stick to react 17 ?

"react-docgen": "^5.3.1",
"react-dom": "^16.14.0",
"react-test-renderer": "^16.14.0",
"react-dom": "^17.0.0",
"react-test-renderer": "^17.0.0",
"rimraf": "^2.7.1",
"style-loader": "^2.0.0",
"styled-jsx": "^3.4.4",
Expand Down
30 changes: 10 additions & 20 deletions react/src/demo/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,22 @@
*/

/* eslint no-magic-numbers: 0 */
import { Button } from "@material-ui/core";
import { Button } from "@mui/material";
import React from "react";

import { WebvizPluginPlaceholder, SmartNodeSelector, Dialog } from "../lib";

const steps = [
{
selector: "#blue-rect",
content: "This is my first step",
},
{
selector: "#green-rect",
content: "This is my second step",
},
];
import {
WebvizPluginPlaceholder,
SmartNodeSelector,
Dialog,
ColorScales,
} from "../lib";

type SmartNodeSelectorProps = {
selectedTags: string[];
selectedNodes: string[];
selectedIds: string[];
};

type MenuProps = {
url: string;
};

const App: React.FC = () => {
const [nodeSelectorState, setNodeSelectorState] =
React.useState<SmartNodeSelectorProps>({
Expand All @@ -40,14 +30,15 @@ const App: React.FC = () => {
selectedTags: [],
});

const [currentPage, setCurrentPage] = React.useState<MenuProps>({
const currentPage = {
url: "",
});
};

const [dialogOpen, setDialogOpen] = React.useState<boolean>(false);

return (
<div>
<ColorScales id="test" />
{currentPage.url.split("#")[1] === "dialog" && (
<>
<h1>Dialog</h1>
Expand Down Expand Up @@ -84,7 +75,6 @@ const App: React.FC = () => {
setProps={() => {
return;
}}
tour_steps={steps}
feedback_url={
"https://github.com/equinor/webviz-core-components/issues/" +
"new?title=New+feedback&body=Feedback+text&labels=userfeedback"
Expand Down
245 changes: 214 additions & 31 deletions react/src/lib/components/ColorScales/ColorScales.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Adapted from https://github.com/plotly/dash-colorscales

import React, { useState } from "react";
import React from "react";
import PropTypes, { InferProps } from "prop-types";
import ColorscalePicker, { Colorscale } from "react-colorscales";
import { ColorLegend } from "@emerson-eps/color-tables";

// Use "Viridis" as the default scale
export const DEFAULT_SCALE = [
Expand Down Expand Up @@ -52,36 +52,219 @@ export type ColorScalesProps = InferProps<typeof propTypes>;
export const ColorScales: React.FC<InferProps<typeof propTypes>> = (
props: InferProps<typeof propTypes>
): JSX.Element => {
const { id, setProps, colorscale, nSwatches, fixSwatches } = props;

const [showColorScalePicker, setShowColorScalePicker] = useState(false);
const [colorScale, setColorScale] = useState(colorscale || DEFAULT_SCALE);

return (
<div id={id}>
<div onClick={() => setShowColorScalePicker(!showColorScalePicker)}>
<Colorscale colorscale={colorScale} width={150} />
</div>
{showColorScalePicker && (
<ColorscalePicker
colorscale={colorScale || DEFAULT_SCALE}
nSwatches={nSwatches || DEFAULT_SCALE.length}
fixSwatches={fixSwatches}
onChange={(newColorScale: string[]) => {
/*
* Send the new value to the parent component.
* In a Dash app, this will send the data back to the
* Python Dash app server.
*/
if (setProps) {
setProps({
colorscale: newColorScale,
});
}
setColorScale(newColorScale);
}}
/>
)}
<div id={props.id}>
<ColorLegend
colorName="Physics"
colorTables={[
{
colors: [
[0, 255, 0, 0],
[0.25, 255, 255, 0],
[0.5, 0, 255, 0],
[0.75, 0, 255, 255],
[1, 0, 0, 255],
],
discrete: false,
name: "Physics",
},
{
colors: [
[0, 255, 0, 0],
[0.2, 255, 255, 0],
[0.4, 0, 255, 0],
[0.6, 0, 255, 255],
[0.8, 0, 0, 255],
[1, 255, 0, 255],
],
discrete: false,
name: "Rainbow",
},
{
colors: [
[0, 255, 246, 117],
[0.11, 255, 243, 53],
[0.18, 255, 241, 0],
[0.25, 155, 193, 0],
[0.32, 255, 155, 23],
[0.39, 255, 162, 61],
[0.46, 255, 126, 45],
[0.53, 227, 112, 24],
[0.6, 246, 96, 31],
[0.67, 229, 39, 48],
[0.74, 252, 177, 170],
[0.81, 236, 103, 146],
[0.88, 226, 44, 118],
[1, 126, 40, 111],
],
discrete: false,
name: "Porosity",
},
{
colors: [
[0, 119, 63, 49],
[0.148, 135, 49, 45],
[0.246, 154, 89, 24],
[0.344, 191, 88, 22],
[0.441, 190, 142, 97],
[0.539, 255, 126, 45],
[0.637, 255, 162, 61],
[0.734, 255, 155, 23],
[0.832, 255, 241, 0],
[1, 255, 246, 117],
],
discrete: false,
name: "Permeability",
},
{
colors: [
[0, 0, 0, 255],
[0.5, 255, 255, 255],
[1, 255, 2, 2],
],
discrete: false,
name: "Seismic",
},
{
colors: [
[0, 252, 174, 169],
[0.1, 226, 44, 118],
[0.168, 229, 39, 48],
[0.234, 150, 40, 34],
[0.301, 255, 126, 45],
[0.367, 255, 162, 61],
[0.434, 255, 241, 0],
[0.5, 219, 228, 163],
[0.566, 0, 143, 74],
[0.633, 0, 110, 78],
[0.699, 0, 124, 140],
[0.766, 116, 190, 230],
[0.832, 0, 143, 212],
[0.898, 0, 51, 116],
[1, 74, 19, 86],
],
discrete: false,
name: "Time/Depth",
},
{
colors: [
[0, 255, 120, 61],
[1, 255, 193, 0],
[2, 255, 155, 76],
[3, 255, 223, 161],
[4, 226, 44, 118],
[5, 255, 243, 53],
[6, 255, 212, 179],
[7, 255, 155, 23],
[8, 255, 246, 117],
[9, 255, 241, 0],
[10, 255, 211, 178],
[11, 255, 173, 128],
[12, 248, 152, 0],
[13, 154, 89, 24],
[14, 0, 138, 185],
[15, 82, 161, 40],
[16, 219, 228, 163],
[17, 0, 119, 64],
[18, 0, 110, 172],
[19, 116, 190, 230],
[20, 0, 155, 212],
[21, 0, 117, 190],
[22, 143, 40, 112],
[23, 220, 153, 190],
[24, 226, 44, 118],
[25, 126, 40, 111],
[26, 73, 69, 43],
[27, 203, 63, 42],
[28, 255, 198, 190],
[29, 135, 49, 45],
[30, 150, 136, 120],
[31, 198, 182, 175],
[32, 166, 154, 145],
[33, 191, 88, 22],
[34, 255, 212, 179],
[35, 251, 139, 105],
[36, 154, 89, 24],
[37, 186, 222, 200],
[38, 0, 124, 140],
[39, 87, 84, 83],
],
discrete: true,
name: "Stratigraphy",
},
{
colors: [
[0, 255, 193, 0],
[1, 255, 246, 117],
[2, 166, 194, 42],
[3, 149, 160, 24],
[4, 9, 143, 74],
[5, 125, 98, 15],
[6, 0, 108, 154],
[7, 0, 117, 190],
[8, 28, 22, 59],
[9, 39, 142, 199],
[10, 0, 138, 185],
[11, 52, 178, 188],
[12, 235, 63, 34],
[13, 74, 19, 86],
[14, 248, 152, 0],
[15, 1, 1, 1],
[16, 128, 128, 128],
],
discrete: true,
name: "Facies",
},
{
colors: [
[0, 255, 46, 0],
[1, 0, 184, 0],
[2, 0, 25, 255],
[3, 179, 179, 179],
],
discrete: true,
name: "GasOilWater",
},
{
colors: [
[0, 255, 46, 0],
[1, 0, 25, 255],
[2, 179, 179, 179],
],
discrete: true,
name: "GasWater",
},
{
colors: [
[0, 0, 184, 0],
[1, 0, 25, 255],
[2, 179, 179, 179],
],
discrete: true,
name: "OilWater",
},
{
colors: [
[0, 127, 201, 127],
[1, 190, 174, 212],
[2, 253, 192, 134],
[4, 255, 255, 153],
[5, 56, 108, 176],
[6, 240, 2, 127],
[7, 191, 91, 23],
[8, 102, 102, 102],
],
discrete: true,
name: "Accent",
},
]}
dataObjectName="Legend"
discreteData={{ objects: { BELOW: [[], 14] } }}
horizontal
max={0.35}
min={0}
position={[5, 10]}
/>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion react/src/lib/components/Dialog/Dialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
DialogComponent as Dialog,
DialogProps,
} from "./components/DialogComponent";
import { Button } from "@material-ui/core";
import { Button } from "@mui/material";

export default {
title: "Components/Dialog",
Expand Down
Loading