Skip to content

Commit

Permalink
remove dragPreview
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader committed Feb 15, 2024
1 parent d605ca6 commit bbf8958
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import type { DeckDefinition, DeckSlot } from '@opentrons/shared-data'

export interface RobotCoordinateSpaceWithDOMCoordsRenderProps {
deckSlotsById: { [slotId: string]: DeckSlot }
getRobotCoordsFromDOMCoords: (
domX: number,
domY: number
) => { x: number; y: number }
}

interface RobotCoordinateSpaceWithDOMCoordsProps
Expand All @@ -19,32 +15,12 @@ interface RobotCoordinateSpaceWithDOMCoordsProps
) => React.ReactNode
}

type GetRobotCoordsFromDOMCoords = RobotCoordinateSpaceWithDOMCoordsRenderProps['getRobotCoordsFromDOMCoords']

export function RobotCoordinateSpaceWithDOMCoords(
props: RobotCoordinateSpaceWithDOMCoordsProps
): JSX.Element | null {
const { children, deckDef, viewBox, ...restProps } = props
const wrapperRef = React.useRef<SVGSVGElement>(null)
const getRobotCoordsFromDOMCoords: GetRobotCoordsFromDOMCoords = (x, y) => {
if (wrapperRef.current == null) return { x: 0, y: 0 }

const cursorPoint = wrapperRef.current.createSVGPoint()

cursorPoint.x = x
cursorPoint.y = y

const screenCTM = wrapperRef.current.getScreenCTM()

if (!screenCTM) return { x, y }

const transformedY = wrapperRef.current.clientHeight - y

cursorPoint.y = transformedY
const transformedPoint = cursorPoint.matrixTransform(screenCTM.inverse())

return transformedPoint
}
if (deckDef == null && viewBox == null) return null

let wholeDeckViewBox
Expand All @@ -66,7 +42,7 @@ export function RobotCoordinateSpaceWithDOMCoords(
transform="scale(1, -1)"
{...restProps}
>
{children?.({ deckSlotsById, getRobotCoordsFromDOMCoords })}
{children?.({ deckSlotsById })}
</Svg>
)
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,8 @@ export const EditLabware = (props: Props): JSX.Element | null => {

if (swapBlocked) {
contents = null
} else if (draggedLabware) {
contents = (
<div
className={cx(styles.overlay_button, {
[styles.drag_text]: isBeingDragged,
})}
>
{t(
`overlay.slot.${isBeingDragged ? 'drag_to_new_slot' : 'place_here'}`
)}
</div>
// <LabwareOnDeckFromComp
// x={cursor.x}
// y={cursor.y}
// labwareOnDeck={draggedLabware.labwareOnDeck}
// />
)
} else if (draggedLabware != null) {
contents = null

Check warning on line 119 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L119

Added line #L119 was not covered by tests
} else {
contents = (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}

.slot_overlay.disabled {
background-color: color-mod(var(--c-light-gray) alpha(0.9));
background-color: color-mod(var(--c-light-gray) alpha(0.7));
color: var(--c-font-dark);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { SlotControls } from './SlotControls'
export { AdapterControls } from './AdapterControls'
export { LabwareControls } from './LabwareControls'
export { DragPreview } from './DragPreview'
9 changes: 2 additions & 7 deletions protocol-designer/src/components/DeckSetup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
FlexTrash,
Module,
RobotCoordinateSpaceWithDOMCoords,
RobotWorkSpaceRenderProps,
SingleSlotFixture,
StagingAreaFixture,
StagingAreaLocation,
Expand Down Expand Up @@ -64,7 +63,6 @@ import {
AdapterControls,
SlotControls,
LabwareControls,
DragPreview,
} from './LabwareOverlays'
import { FlexModuleTag } from './FlexModuleTag'
import { Ot2ModuleTag } from './Ot2ModuleTag'
Expand Down Expand Up @@ -102,7 +100,6 @@ const OT2_STANDARD_DECK_VIEW_LAYER_BLOCK_LIST: string[] = [
]

interface ContentsProps {
getRobotCoordsFromDOMCoords: RobotWorkSpaceRenderProps['getRobotCoordsFromDOMCoords']
activeDeckSetup: InitialDeckSetup
selectedTerminalItemId?: TerminalItemId | null
showGen1MultichannelCollisionWarnings: boolean
Expand All @@ -118,7 +115,6 @@ const darkFill = COLORS.grey60
export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
const {
activeDeckSetup,
getRobotCoordsFromDOMCoords,
showGen1MultichannelCollisionWarnings,
deckDef,
robotType,
Expand Down Expand Up @@ -482,7 +478,6 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
</React.Fragment>
)
})}
<DragPreview getRobotCoordsFromDOMCoords={getRobotCoordsFromDOMCoords} />
</>
)
}
Expand Down Expand Up @@ -567,7 +562,7 @@ export const DeckSetup = (): JSX.Element => {
: deckDef.cornerOffsetFromOrigin[1]
} ${deckDef.dimensions[0]} ${deckDef.dimensions[1]}`}
>
{({ getRobotCoordsFromDOMCoords }) => (
{() => (
<>
{robotType === OT2_ROBOT_TYPE ? (
<DeckFromLayers
Expand Down Expand Up @@ -652,7 +647,7 @@ export const DeckSetup = (): JSX.Element => {
)}
{...{
deckDef,
getRobotCoordsFromDOMCoords,

showGen1MultichannelCollisionWarnings,
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import styles from './StepItem.css'

interface DragDropStepItemProps extends ConnectedStepItemProps {
stepId: StepIdType
findStepIndex: (stepIdType: StepIdType) => number
clickDrop: () => void
moveStep: (dragIndex: number, value: number) => void
setIsOver: React.Dispatch<React.SetStateAction<boolean>>
Expand Down Expand Up @@ -141,9 +140,6 @@ export const DraggableStepItems = (
[]
)

const findStepIndex = (stepId: StepIdType): number =>
stepIds.findIndex(id => stepId === id)

const currentIds = isOver ? stepIds : orderedStepIds

return (

Check warning on line 145 in protocol-designer/src/components/steplist/DraggableStepItems.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/steplist/DraggableStepItems.tsx#L145

Added line #L145 was not covered by tests
Expand All @@ -158,7 +154,6 @@ export const DraggableStepItems = (
// @ts-expect-error
onStepContextMenu={makeStepOnContextMenu(stepId)}
moveStep={moveStep}
findStepIndex={findStepIndex}
clickDrop={clickDrop}
setIsOver={setIsOver}
index={index}
Expand Down

0 comments on commit bbf8958

Please sign in to comment.