Skip to content

Commit

Permalink
update other labwareInternals components to accommodate passing fill
Browse files Browse the repository at this point in the history
  • Loading branch information
ncdiehl11 committed Jul 30, 2024
1 parent 89e036f commit 4368f3d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface LabwareOutlineProps {
highlight?: boolean
/** [legacy] override the border color */
stroke?: CSSProperties['stroke']
fill?: CSSProperties['fill']
}

const OUTLINE_THICKNESS_MM = 1
Expand All @@ -30,13 +31,19 @@ export function LabwareOutline(props: LabwareOutlineProps): JSX.Element {
isTiprack = false,
highlight = false,
stroke,
fill,
} = props
const {
parameters = { isTiprack },
dimensions = { xDimension: width, yDimension: height },
} = definition ?? {}

const backgroundFill = parameters.isTiprack ? '#CCCCCC' : COLORS.white
let backgroundFill
if (fill != null) {
backgroundFill = fill
} else {
backgroundFill = parameters.isTiprack ? '#CCCCCC' : COLORS.white
}
return (
<>
{highlight ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Render labware definition to SVG. XY is in robot coordinates.
import * as React from 'react'
import styled from 'styled-components'
import styled, { CSSProperties } from 'styled-components'

Check failure on line 3 in components/src/hardware-sim/Labware/labwareInternals/StaticLabware.tsx

View workflow job for this annotation

GitHub Actions / js checks

Import "CSSProperties" is only used as types

Check failure on line 3 in components/src/hardware-sim/Labware/labwareInternals/StaticLabware.tsx

View workflow job for this annotation

GitHub Actions / js checks

Import "CSSProperties" is only used as types
import flatMap from 'lodash/flatMap'

import { LabwareOutline } from './LabwareOutline'
Expand All @@ -22,6 +22,7 @@ export interface StaticLabwareProps {
onMouseEnterWell?: (e: WellMouseEvent) => unknown
/** Optional callback to be executed when mouse leaves a well element */
onMouseLeaveWell?: (e: WellMouseEvent) => unknown
fill?: CSSProperties['fill']
}

const TipDecoration = React.memo(function TipDecoration(props: {
Expand Down Expand Up @@ -55,13 +56,18 @@ export function StaticLabwareComponent(props: StaticLabwareProps): JSX.Element {
onLabwareClick,
onMouseEnterWell,
onMouseLeaveWell,
fill,
} = props

const { isTiprack } = definition.parameters
return (
<g onClick={onLabwareClick}>
<LabwareDetailGroup>
<LabwareOutline definition={definition} highlight={highlight} />
<LabwareOutline
definition={definition}
highlight={highlight}
fill={fill}
/>
</LabwareDetailGroup>
<g>
{flatMap(
Expand All @@ -78,6 +84,7 @@ export function StaticLabwareComponent(props: StaticLabwareProps): JSX.Element {
{...(isTiprack
? STYLE_BY_WELL_CONTENTS.tipPresent
: STYLE_BY_WELL_CONTENTS.defaultWell)}
fill={fill}
/>

{isTiprack ? (
Expand Down
6 changes: 4 additions & 2 deletions components/src/hardware-sim/Labware/labwareInternals/Well.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ export function WellComponent(props: WellProps): JSX.Element {
wellName,
stroke = COLORS.black90,
strokeWidth = 1,
fill = COLORS.white,
fill,
onMouseEnterWell,
onMouseLeaveWell,
isInteractive = onMouseEnterWell != null || onMouseLeaveWell != null,
} = props
const { x, y } = well

const wellFill = fill ?? COLORS.white

const pointerEvents: React.CSSProperties['pointerEvents'] = isInteractive
? 'auto'
: 'none'
Expand All @@ -46,7 +48,7 @@ export function WellComponent(props: WellProps): JSX.Element {
onMouseLeaveWell != null
? (event: React.MouseEvent) => onMouseLeaveWell({ wellName, event })
: undefined,
style: { pointerEvents, stroke, strokeWidth, fill },
style: { pointerEvents, stroke, strokeWidth, fill: wellFill },
}

if (well.shape === 'circular') {
Expand Down

0 comments on commit 4368f3d

Please sign in to comment.