@@ -4,6 +4,7 @@ import React, { Fragment } from 'react';
44
55import { MllSpinnerIcon } from '../Spinner' ;
66
7+ import { ColumnLabel } from './ColumnLabel' ;
78import { RowLabel } from './RowLabel' ;
89import { Well } from './Well' ;
910import { PLATE_FLOW } from './constants' ;
@@ -12,6 +13,7 @@ import {
1213 allCoordinateSystemPositions ,
1314 assertUniquePositions ,
1415 columnForPosition ,
16+ rowForPosition ,
1517 wellAtPosition ,
1618} from './utils' ;
1719
@@ -22,17 +24,21 @@ export * from './types';
2224export * from './utils' ;
2325export { GENERAL_WELL_STYLE } from './wellUtils' ;
2426
25- export function Plate < TCoordinateSystem extends CoordinateSystem > (
26- props : PlateProps < TCoordinateSystem > ,
27- ) {
28- if ( props . data ) {
29- assertUniquePositions ( props . data ) ;
27+ export function Plate < TCoordinateSystem extends CoordinateSystem > ( {
28+ coordinateSystem,
29+ data,
30+ dndContextProps,
31+ isDraggable,
32+ loading,
33+ } : PlateProps < TCoordinateSystem > ) {
34+ if ( data ) {
35+ assertUniquePositions ( data ) ;
3036 }
3137
3238 return (
33- < DndContext { ...props . dndContextProps } >
39+ < DndContext { ...dndContextProps } >
3440 < Spin
35- spinning = { props . loading ?? false }
41+ spinning = { loading ?? false }
3642 indicator = {
3743 < MllSpinnerIcon
3844 style = { {
@@ -44,59 +50,45 @@ export function Plate<TCoordinateSystem extends CoordinateSystem>(
4450 < div
4551 style = { {
4652 display : 'grid' ,
47- gridTemplateColumns : `1fr ${ '4fr ' . repeat (
48- props . coordinateSystem . columns . length ,
53+ gridTemplateColumns : `1fr${ ' 4fr ' . repeat (
54+ coordinateSystem . columns . length ,
4955 ) } `,
5056 gridGap : '3px' ,
5157 } }
5258 >
59+ { /* takes up the space in the upper left corner between A and 1 */ }
5360 < span />
5461
55- { props . coordinateSystem . columns . map ( ( column ) => (
56- < span
57- style = { {
58- display : 'flex' ,
59- justifyContent : 'center' ,
60- padding : 4 ,
61- } }
62- key = { column }
63- >
64- < strong > { column } </ strong >
65- </ span >
62+ { coordinateSystem . columns . map ( ( column ) => (
63+ < ColumnLabel key = { column } column = { column } />
6664 ) ) }
6765
68- { allCoordinateSystemPositions ( props . coordinateSystem ) . map (
69- ( position ) => (
70- < Fragment key = { position } >
71- { columnForPosition (
72- position ,
73- PLATE_FLOW ,
74- props . coordinateSystem ,
75- ) === 1 && (
76- < RowLabel
77- position = { position }
78- coordinateSystem = { props . coordinateSystem }
79- />
80- ) }
81-
82- < Well
83- position = { position }
84- coordinateSystem = { props . coordinateSystem }
85- well = {
86- props . data
87- ? wellAtPosition (
88- position ,
89- props . data ,
90- PLATE_FLOW ,
91- props . coordinateSystem ,
92- )
93- : null
94- }
95- isDraggable = { props . isDraggable ?? false }
66+ { allCoordinateSystemPositions ( coordinateSystem ) . map ( ( position ) => (
67+ < Fragment key = { position } >
68+ { columnForPosition ( position , PLATE_FLOW , coordinateSystem ) ===
69+ 1 && (
70+ < RowLabel
71+ row = { rowForPosition ( position , PLATE_FLOW , coordinateSystem ) }
9672 />
97- </ Fragment >
98- ) ,
99- ) }
73+ ) }
74+
75+ < Well
76+ position = { position }
77+ coordinateSystem = { coordinateSystem }
78+ well = {
79+ data
80+ ? wellAtPosition (
81+ position ,
82+ data ,
83+ PLATE_FLOW ,
84+ coordinateSystem ,
85+ )
86+ : null
87+ }
88+ isDraggable = { isDraggable ?? false }
89+ />
90+ </ Fragment >
91+ ) ) }
10092 </ div >
10193 </ Spin >
10294 </ DndContext >
0 commit comments