-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
832 additions
and
4 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
protocol-designer/src/assets/images/tip_side_bottom_layer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions
45
protocol-designer/src/assets/images/tip_side_mid_layer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions
49
protocol-designer/src/assets/images/tip_side_top_layer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
protocol-designer/src/assets/images/tip_top_bottom_layer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
77 changes: 77 additions & 0 deletions
77
protocol-designer/src/organisms/TipPositionModal/TipPositionSideView.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,77 @@ | ||
import round from 'lodash/round' | ||
import { useTranslation } from 'react-i18next' | ||
import { | ||
Box, | ||
COLORS, | ||
OVERFLOW_HIDDEN, | ||
POSITION_ABSOLUTE, | ||
POSITION_RELATIVE, | ||
StyledText, | ||
} from '@opentrons/components' | ||
import BOTTOM_LAYER from '../../assets/images/tip_side_bottom_layer.svg' | ||
import MID_LAYER from '../../assets/images/tip_side_mid_layer.svg' | ||
import TOP_LAYER from '../../assets/images/tip_side_top_layer.svg' | ||
|
||
const WELL_HEIGHT_PIXELS = 71 | ||
const WELL_WIDTH_PIXELS = 70 | ||
const PIXEL_DECIMALS = 2 | ||
|
||
interface TipPositionAllVizProps { | ||
mmFromBottom: number | ||
xPosition: number | ||
wellDepthMm: number | ||
xWidthMm: number | ||
} | ||
|
||
export function TipPositionSideView( | ||
props: TipPositionAllVizProps | ||
): JSX.Element { | ||
const { mmFromBottom, xPosition, wellDepthMm, xWidthMm } = props | ||
const { t } = useTranslation('application') | ||
const fractionOfWellHeight = mmFromBottom / wellDepthMm | ||
const pixelsFromBottom = | ||
Number(fractionOfWellHeight) * WELL_HEIGHT_PIXELS - WELL_HEIGHT_PIXELS | ||
const roundedPixelsFromBottom = round(pixelsFromBottom, PIXEL_DECIMALS) | ||
const bottomPx = wellDepthMm | ||
? roundedPixelsFromBottom * 2 | ||
: mmFromBottom - WELL_HEIGHT_PIXELS | ||
|
||
const xPx = (WELL_WIDTH_PIXELS / xWidthMm) * xPosition | ||
const roundedXPx = round(xPx, PIXEL_DECIMALS) | ||
|
||
return ( | ||
<Box | ||
position={POSITION_RELATIVE} | ||
width="253px" | ||
height="288px" | ||
overflow={OVERFLOW_HIDDEN} | ||
> | ||
<img src={BOTTOM_LAYER} style={{ position: POSITION_ABSOLUTE }} /> | ||
<img | ||
src={MID_LAYER} | ||
style={{ | ||
position: POSITION_ABSOLUTE, | ||
transform: `translate(${roundedXPx}px)`, | ||
bottom: `calc(${bottomPx}px + 33px)`, | ||
}} | ||
/> | ||
<img src={TOP_LAYER} style={{ position: POSITION_ABSOLUTE }} /> | ||
{wellDepthMm !== null && ( | ||
<Box position={POSITION_ABSOLUTE} bottom="7.3rem" right="2rem"> | ||
<StyledText desktopStyle="captionRegular" color={COLORS.grey60}> | ||
{round(wellDepthMm, 0)} | ||
{t('units.millimeter')} | ||
</StyledText> | ||
</Box> | ||
)} | ||
{xWidthMm !== null && ( | ||
<Box position={POSITION_ABSOLUTE} bottom="2rem" right="7rem"> | ||
<StyledText desktopStyle="captionRegular" color={COLORS.grey60}> | ||
{xWidthMm} | ||
{t('units.millimeter')} | ||
</StyledText> | ||
</Box> | ||
)} | ||
</Box> | ||
) | ||
} |
61 changes: 61 additions & 0 deletions
61
protocol-designer/src/organisms/TipPositionModal/TipPositionTopView.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,61 @@ | ||
import round from 'lodash/round' | ||
import { useTranslation } from 'react-i18next' | ||
import { | ||
Box, | ||
COLORS, | ||
OVERFLOW_HIDDEN, | ||
POSITION_ABSOLUTE, | ||
POSITION_RELATIVE, | ||
StyledText, | ||
} from '@opentrons/components' | ||
import BOTTOM_LAYER from '../../assets/images/tip_top_bottom_layer.svg' | ||
import MID_LAYER from '../../assets/images/tip_top_mid_layer.svg' | ||
import TOP_LAYER from '../../assets/images/tip_top_top_layer.svg' | ||
|
||
const WELL_WIDTH_PIXELS = 70 | ||
const PIXEL_DECIMALS = 2 | ||
|
||
interface TipPositionAllVizProps { | ||
xPosition: number | ||
xWidthMm: number | ||
yPosition: number | ||
yWidthMm: number | ||
} | ||
|
||
export function TipPositionTopView(props: TipPositionAllVizProps): JSX.Element { | ||
const { yPosition, xPosition, yWidthMm, xWidthMm } = props | ||
const { t } = useTranslation('application') | ||
|
||
const xPx = (WELL_WIDTH_PIXELS / xWidthMm) * xPosition | ||
const yPx = (WELL_WIDTH_PIXELS / yWidthMm) * yPosition | ||
|
||
const roundedXPx = round(xPx, PIXEL_DECIMALS) | ||
const roundedYPx = round(yPx, PIXEL_DECIMALS) | ||
const translateY = roundedYPx < 0 ? Math.abs(roundedYPx) : -roundedYPx | ||
return ( | ||
<Box | ||
position={POSITION_RELATIVE} | ||
width="253px" | ||
height="288px" | ||
overflow={OVERFLOW_HIDDEN} | ||
> | ||
<img src={BOTTOM_LAYER} style={{ position: POSITION_ABSOLUTE }} /> | ||
<img | ||
src={MID_LAYER} | ||
style={{ | ||
position: POSITION_ABSOLUTE, | ||
transform: `translate(${roundedXPx}px, ${translateY}px)`, | ||
}} | ||
/> | ||
<img src={TOP_LAYER} style={{ position: POSITION_ABSOLUTE }} /> | ||
{xWidthMm !== null && ( | ||
<Box position={POSITION_ABSOLUTE} bottom="2rem" right="7rem"> | ||
<StyledText desktopStyle="captionRegular" color={COLORS.grey60}> | ||
{xWidthMm} | ||
{t('units.millimeter')} | ||
</StyledText> | ||
</Box> | ||
)} | ||
</Box> | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
protocol-designer/src/organisms/TipPositionModal/constants.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,5 @@ | ||
export const DECIMALS_ALLOWED = 1 | ||
export const SMALL_STEP_MM = 1 | ||
export const LARGE_STEP_MM = 10 | ||
export const TOO_MANY_DECIMALS: 'TOO_MANY_DECIMALS' = 'TOO_MANY_DECIMALS' | ||
export const PERCENT_RANGE_TO_SHOW_WARNING = 0.9 |
Oops, something went wrong.