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 1 commit
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
Next Next commit
feat(app): add module icon tooltips to robot card
closes #8672
  • Loading branch information
jerader committed Apr 29, 2022
commit ea6fec70b4361b5247b3cf3a26833f76f9c8ba65
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}}"
}
10 changes: 8 additions & 2 deletions app/src/organisms/Devices/RobotCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
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'
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 @@ -96,6 +97,11 @@ export function RobotCard(props: RobotCardProps): JSX.Element | null {
key={`${name}_${module.moduleModel}_${i}`}
moduleType={module.moduleType}
size={SPACING.spacing4}
moduleModel={module.model}
tooltipText={t(
'this_robot_has_connected_and_power_on_module',
{ moduleName: getModuleDisplayName(module.model) }
)}
/>
))}
</Flex>
Expand Down
35 changes: 28 additions & 7 deletions components/src/icons/ModuleIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import {
MAGNETIC_MODULE_TYPE,
THERMOCYCLER_MODULE_TYPE,
} from '@opentrons/shared-data'
import { Tooltip } from '@opentrons/app/src/atoms/Tooltip/index'
import { Flex, TOOLTIP_BOTTOM, useHoverTooltip } from '..'
import { SPACING } from '../ui-style-constants'

import type { ModuleType } from '@opentrons/shared-data'
import type { ModuleType, ModuleModel } from '@opentrons/shared-data'
import type { StyleProps } from '../primitives/types'

const MODULE_ICON_NAME_BY_TYPE: { [type in ModuleType]: IconName } = {
Expand All @@ -19,17 +22,35 @@ const MODULE_ICON_NAME_BY_TYPE: { [type in ModuleType]: IconName } = {

interface ModuleIconProps extends StyleProps {
moduleType: ModuleType
moduleModel?: ModuleModel
tooltipText?: string
}

export function ModuleIcon(props: ModuleIconProps): JSX.Element {
const { moduleType, ...styleProps } = props
const { moduleType, moduleModel, tooltipText, ...styleProps } = props
const [targetProps, tooltipProps] = useHoverTooltip({
placement: TOOLTIP_BOTTOM,
})
const iconName = MODULE_ICON_NAME_BY_TYPE[moduleType]

return (
<Icon
name={iconName}
{...styleProps}
data-testid={`ModuleIcon_${iconName}`}
/>
<>
<Icon
name={iconName}
{...styleProps}
data-testid={`ModuleIcon_${iconName}`}
{...targetProps}
/>
{moduleModel != null && (
<Flex position="relative" marginTop={SPACING.spacingM}>
<Tooltip
tooltipProps={tooltipProps}
key={`ModuleIcon_tooltip_${moduleType}`}
>
{tooltipText}
</Tooltip>
</Flex>
)}
</>
)
}