-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/Add area coordinate component in object result view.
- Loading branch information
1 parent
79eba65
commit 6ce9cf8
Showing
7 changed files
with
136 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...atures/Results/CaseResult/CaseResultView/ObjectCaseResult/ResultArea/ResultArea.styled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import styled from 'styled-components'; | ||
import { spacings } from '../../../../../../tokens/spacings'; | ||
|
||
export const Wrapper = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
width: 500px; | ||
`; | ||
|
||
export const Info = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
row-gap: ${spacings.MEDIUM}; | ||
width: 150px; | ||
`; | ||
|
||
export const Coordinates = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
row-gap: ${spacings.MEDIUM}; | ||
`; | ||
|
||
export const CoordinateRow = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
column-gap: ${spacings.MEDIUM}; | ||
`; | ||
|
||
export const RowElement = styled.div` | ||
white-space: nowrap; | ||
`; |
80 changes: 80 additions & 0 deletions
80
src/features/Results/CaseResult/CaseResultView/ObjectCaseResult/ResultArea/ResultArea.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* eslint-disable max-lines-per-function */ | ||
import { Label, Typography } from '@equinor/eds-core-react'; | ||
import { GetChannelResultsDto } from '../../../../../../api/generated'; | ||
import * as Styled from './ResultArea.styled'; | ||
|
||
export const ResultArea = ({ | ||
computeMethod, | ||
modelArea, | ||
data, | ||
}: { | ||
computeMethod?: string; | ||
modelArea: string; | ||
data: GetChannelResultsDto; | ||
}) => { | ||
const xCoordinate = data.box?.filter((b) => b.m === 0)[0]; | ||
const yCoordinate = data.box?.filter((b) => b.m === 1)[0]; | ||
|
||
const xLength = () => { | ||
if (xCoordinate && yCoordinate) return yCoordinate?.x - xCoordinate?.x; | ||
}; | ||
|
||
const yLength = () => { | ||
if (xCoordinate && yCoordinate) { | ||
const value = yCoordinate?.y - xCoordinate?.y; | ||
return value; | ||
} | ||
}; | ||
|
||
const area = () => { | ||
const x = xLength(); | ||
const y = yLength(); | ||
|
||
if (x && y) return x * y + ' m^2'; | ||
}; | ||
|
||
return ( | ||
<Styled.Wrapper> | ||
<Styled.Info> | ||
<div> | ||
<Typography variant="h5"> {computeMethod}</Typography> | ||
<Typography variant="body_short"> {modelArea}</Typography> | ||
</div> | ||
<div> | ||
<Label label="Area size"></Label> | ||
<Typography variant="body_short">{area() ? area() : '-'}</Typography> | ||
</div> | ||
</Styled.Info> | ||
<Styled.Coordinates> | ||
<Styled.CoordinateRow> | ||
<Styled.RowElement> | ||
<Label label="X start"></Label> | ||
<Typography variant="body_short"> | ||
{modelArea === 'Whole model' ? '-' : xCoordinate?.x + ' m'} | ||
</Typography> | ||
</Styled.RowElement> | ||
<Styled.RowElement> | ||
<Label label="X length"></Label> | ||
<Typography variant="body_short"> | ||
{modelArea === 'Whole model' ? '-' : xLength() + ' m'} | ||
</Typography> | ||
</Styled.RowElement> | ||
</Styled.CoordinateRow> | ||
<Styled.CoordinateRow> | ||
<Styled.RowElement> | ||
<Label label="Y start"></Label> | ||
<Typography variant="body_short"> | ||
{modelArea === 'Whole model' ? '-' : yCoordinate?.x + ' m'} | ||
</Typography> | ||
</Styled.RowElement> | ||
<Styled.RowElement> | ||
<Label label="Y length"></Label> | ||
<Typography variant="body_short"> | ||
{modelArea === 'Whole model' ? '-' : yLength() + ' m'} | ||
</Typography> | ||
</Styled.RowElement> | ||
</Styled.CoordinateRow> | ||
</Styled.Coordinates> | ||
</Styled.Wrapper> | ||
); | ||
}; |