From 12bd29194452cf6cc9a2a83eb16648ba5bb36b22 Mon Sep 17 00:00:00 2001 From: Peter Bull Hove Date: Wed, 28 Feb 2024 15:25:02 +0100 Subject: [PATCH] fix: vertical --- .../Components/Bridging/BridgeContainer.jsx | 146 ++++++++++-------- web/src/Components/Bridging/BridgeGraph.jsx | 6 +- web/src/Pages/Main.tsx | 4 +- 3 files changed, 85 insertions(+), 71 deletions(-) diff --git a/web/src/Components/Bridging/BridgeContainer.jsx b/web/src/Components/Bridging/BridgeContainer.jsx index bf6f5f8..c710f5a 100644 --- a/web/src/Components/Bridging/BridgeContainer.jsx +++ b/web/src/Components/Bridging/BridgeContainer.jsx @@ -2,17 +2,17 @@ import React, { useContext, useEffect, useState } from 'react' import styled from 'styled-components' import { Radio, TextField, Typography } from '@equinor/eds-core-react' import { FractionsAPI } from '../../Api' -import { BridgingOption, CeramicDiscsValues } from "../../Enums" +import { BridgingOption, CeramicDiscsValues } from '../../Enums' import { AuthContext } from 'react-oauth2-code-pkce' -import BridgeGraph from "./BridgeGraph" -import {Tooltip} from "../Common/Tooltip"; -import {findDValue, findGraphData} from "../../Utils"; +import BridgeGraph from './BridgeGraph' +import { Tooltip } from '../Common/Tooltip' +import { findDValue, findGraphData } from '../../Utils' import { ErrorToast } from '../Common/Toast' const InputWrapper = styled.div` display: flex; flex-direction: column; - justify-content: space-between; + gap: 10px 5px; ` const RadioWrapper = styled.div` @@ -36,25 +36,25 @@ export default ({ bridges, mode, setMode, bridgeValue, setValue }) => { const [bridgeValueHelperText, setBridgeValueHelperText] = useState(undefined) const [bridgeValueVariant, setBridgeValueVariant] = useState(undefined) const [optimalBridgeGraphData, setOptimalBridgeGraphData] = useState([]) - const { token} = useContext(AuthContext) + const { token } = useContext(AuthContext) // Load size fractions once on first render useEffect(() => { FractionsAPI.getFractionsApi(token) - .then(response => { - setSizeFractions(response.data.size_fractions) - }) - .catch(error => { - ErrorToast(`${error.response.data}`, error.response.status) - console.error('fetch error' + error) - }) + .then(response => { + setSizeFractions(response.data.size_fractions) + }) + .catch(error => { + ErrorToast(`${error.response.data}`, error.response.status) + console.error('fetch error' + error) + }) }, []) useEffect(() => { - if (bridges["Bridge"].length && sizeFractions.length ) { - const x = (findGraphData(sizeFractions, {"Bridge": bridges["Bridge"]})) + if (bridges['Bridge'].length && sizeFractions.length) { + const x = findGraphData(sizeFractions, { Bridge: bridges['Bridge'] }) setOptimalBridgeGraphData(x) - } + } }, [bridges, sizeFractions]) function bridgingOptionChange(event) { @@ -98,75 +98,89 @@ export default ({ bridges, mode, setMode, bridgeValue, setValue }) => { } return ( -
+
+
- Bridging options + Bridging options Bridging based on: - +
- {mode === BridgingOption.CERAMIC_DISCS ? -
- - onBridgeValueChange(event.target.value)}> - {CeramicDiscsValues.map((value, index)=>{ - return - })} - - microns -
- : - onBridgeValueChange(event.target.value)} - variant={bridgeValueVariant} - helperText={bridgeValueHelperText} - /> - } - + {mode === BridgingOption.CERAMIC_DISCS ? ( +
+ + onBridgeValueChange(event.target.value)}> + {CeramicDiscsValues.map((value, index) => { + return ( + + ) + })} + + microns +
+ ) : ( + onBridgeValueChange(event.target.value)} + variant={bridgeValueVariant} + helperText={bridgeValueHelperText} + /> + )}
- - {optimalBridgeGraphData.length > 0 &&
-

Optimal bridge:

-

D10: {findDValue(optimalBridgeGraphData, 10, "Bridge")}µ

-

D50: {findDValue(optimalBridgeGraphData, 50, "Bridge")}µ

-

D90: {findDValue(optimalBridgeGraphData, 90, "Bridge")}µ

-
} + {optimalBridgeGraphData.length > 0 && ( +
+ Optimal Bridge: +

D10: {findDValue(optimalBridgeGraphData, 10, 'Bridge')}µ

+

D50: {findDValue(optimalBridgeGraphData, 50, 'Bridge')}µ

+

D90: {findDValue(optimalBridgeGraphData, 90, 'Bridge')}µ

+
+ )} +
+
+ +
+
) } diff --git a/web/src/Components/Bridging/BridgeGraph.jsx b/web/src/Components/Bridging/BridgeGraph.jsx index 8acc53b..c86d930 100644 --- a/web/src/Components/Bridging/BridgeGraph.jsx +++ b/web/src/Components/Bridging/BridgeGraph.jsx @@ -73,8 +73,8 @@ export function BridgeGraph({ bridges, sizeFractions }) { }, [bridges, sizeFractions]) return ( -
- +
+ {/* Defines a gradient applied to the areaPlot to highlight selected particle size range*/} @@ -96,7 +96,7 @@ export function BridgeGraph({ bridges, sizeFractions }) { /> } /> - + {Object.entries(bridges).map(([name, cumulative], index) => (