Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): add module icon tooltips to robot card #10103

Merged
merged 5 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/assets/localization/en/devices_landing.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
"update_robot_software": "Update robot software",
"disconnect_from_network": "Disconnect from network",
"connect_to_network": "Connect to network",
"home_gantry": "Home gantry"
"home_gantry": "Home gantry",
"this_robot_has_connected_and_power_on_module": "This robot has a connected and powered on {{moduleName}}"
}
4 changes: 2 additions & 2 deletions app/src/atoms/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as React from 'react'
import {
COLORS,
TYPOGRAPHY,
UseTooltipResultTooltipProps,
Tooltip as SharedTooltip,
} from '@opentrons/components'
import { Tooltip as SharedTooltip } from '@opentrons/components/src/tooltips/Tooltip'
import type { UseTooltipResultTooltipProps } from '@opentrons/components'

export interface TooltipProps {
key: string
Expand Down
42 changes: 42 additions & 0 deletions app/src/molecules/ModuleIcon/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as React from 'react'
import {
Flex,
ModuleIcon as SharedModuleIcon,
POSITION_RELATIVE,
SPACING,
useHoverTooltip,
} from '@opentrons/components'
import { Tooltip } from '../../atoms/Tooltip'

import type { AttachedModule } from '../../redux/modules/types'

interface ModuleIconProps {
module: AttachedModule
index: number
tooltipText: string
}

export function ModuleIcon(props: ModuleIconProps): JSX.Element {
const { module, index, tooltipText } = props
const [targetProps, tooltipProps] = useHoverTooltip()

return (
<>
<Flex {...targetProps}>
<SharedModuleIcon
moduleType={module.moduleType}
size={SPACING.spacing4}
/>
</Flex>

<Flex position={POSITION_RELATIVE} marginTop={SPACING.spacingM}>
<Tooltip
tooltipProps={tooltipProps}
key={`ModuleIcon_tooltip_${index}`}
>
{tooltipText}
</Tooltip>
</Flex>
</>
)
}
21 changes: 14 additions & 7 deletions app/src/organisms/Devices/RobotCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ import {
DIRECTION_ROW,
SPACING,
TEXT_TRANSFORM_UPPERCASE,
ModuleIcon,
BORDERS,
} from '@opentrons/components'
import { getModuleDisplayName } from '@opentrons/shared-data'

import OT2_PNG from '../../assets/images/OT2-R_HERO.png'
import { StyledText } from '../../atoms/text'
import { UNREACHABLE } from '../../redux/discovery'
import { ModuleIcon } from '../../molecules/ModuleIcon'
import { useAttachedModules, useAttachedPipettes } from './hooks'
import { RobotStatusBanner } from './RobotStatusBanner'
import { RobotOverflowMenu } from './RobotOverflowMenu'

import type { DiscoveredRobot } from '../../redux/discovery/types'
import { UNREACHABLE } from '../../redux/discovery'
// import { UpdateRobotBanner } from '../UpdateRobotBanner'

interface RobotCardProps {
Expand All @@ -34,7 +36,6 @@ export function RobotCard(props: RobotCardProps): JSX.Element | null {
const { robot } = props
const { name = null, local } = robot
const { t } = useTranslation('devices_landing')

const attachedModules = useAttachedModules(name)
const attachedPipettes = useAttachedPipettes(name)

Expand All @@ -44,7 +45,7 @@ export function RobotCard(props: RobotCardProps): JSX.Element | null {
alignItems={ALIGN_CENTER}
backgroundColor={C_WHITE}
border={`1px solid ${C_MED_LIGHT_GRAY}`}
borderRadius="4px"
borderRadius={BORDERS.radiusSoftCorners}
flexDirection={DIRECTION_ROW}
marginBottom={SPACING.spacing3}
padding={SPACING.spacing3}
Expand Down Expand Up @@ -93,9 +94,15 @@ export function RobotCard(props: RobotCardProps): JSX.Element | null {
<Flex>
{attachedModules.map((module, i) => (
<ModuleIcon
key={`${name}_${module.moduleModel}_${i}`}
moduleType={module.moduleType}
size={SPACING.spacing4}
key={`${module.moduleModel}_${i}_${name}`}
tooltipText={t(
'this_robot_has_connected_and_power_on_module',
{
moduleName: getModuleDisplayName(module.moduleModel),
}
)}
index={i}
module={module}
/>
))}
</Flex>
Expand Down