-
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.
refactor: seperate coordinateInput into own component
- Loading branch information
1 parent
bdfa2a0
commit 105f2c3
Showing
2 changed files
with
85 additions
and
77 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
47 changes: 47 additions & 0 deletions
47
src/components/AreaCoordinates/CoordinateInput/CoordinateInput.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,47 @@ | ||
import { Icon, Input, Label } from '@equinor/eds-core-react'; | ||
import { error_filled as ERROR_FILLED } from '@equinor/eds-icons'; | ||
import { ModelAreaTypeDto } from '../../../api/generated'; | ||
import { AreaCoordinateType } from '../AreaCoordinates'; | ||
|
||
export const CoordinateInput = ({ | ||
label, | ||
error, | ||
areaCoordinate, | ||
setCoordinates, | ||
position, | ||
axis, | ||
activeArea, | ||
}: { | ||
label: string; | ||
error: boolean; | ||
areaCoordinate: AreaCoordinateType | undefined; | ||
setCoordinates: (target: any, index: number, axis: string) => void; | ||
position: number; | ||
axis: string; | ||
activeArea: ModelAreaTypeDto; | ||
}) => { | ||
return ( | ||
<div> | ||
<Label label={label} /> | ||
<Input | ||
value={ | ||
axis === 'x' | ||
? areaCoordinate?.coordinates[position].x | ||
: areaCoordinate?.coordinates[position].y | ||
} | ||
onChange={(input: { target: any }) => | ||
setCoordinates(input.target, position, axis) | ||
} | ||
rightAdornments={ | ||
error ? ( | ||
<Icon data={ERROR_FILLED} color="red" size={24}></Icon> | ||
) : ( | ||
'meters' | ||
) | ||
} | ||
variant={error ? 'error' : undefined} | ||
disabled={activeArea?.modelAreaTypeId === ''} | ||
/> | ||
</div> | ||
); | ||
}; |