Skip to content

Commit

Permalink
fix(app): fix intervention icon sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed Nov 21, 2024
1 parent d8ad367 commit 6db5cb3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
18 changes: 13 additions & 5 deletions app/src/molecules/InterventionModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {

import { getIsOnDevice } from '/app/redux/config'

import type { IconName } from '@opentrons/components'
import { ModalContentOneColSimpleButtons } from './ModalContentOneColSimpleButtons'
import { TwoColumn } from './TwoColumn'
import { OneColumn } from './OneColumn'
Expand All @@ -32,6 +31,10 @@ import { ModalContentMixed } from './ModalContentMixed'
import { DescriptionContent } from './DescriptionContent'
import { DeckMapContent } from './DeckMapContent'
import { CategorizedStepContent } from './CategorizedStepContent'

import type { FlattenSimpleInterpolation } from 'styled-components'
import type { IconName } from '@opentrons/components'

export {
ModalContentOneColSimpleButtons,
TwoColumn,
Expand Down Expand Up @@ -122,6 +125,8 @@ export interface InterventionModalProps {
type?: ModalType
/** optional icon name */
iconName?: IconName | null | undefined
/* Optional icon size override. */
iconSize?: string
/** modal contents */
children: React.ReactNode
}
Expand All @@ -133,6 +138,7 @@ export function InterventionModal({
iconName,
iconHeading,
children,
iconSize,
}: InterventionModalProps): JSX.Element {
const modalType = type ?? 'intervention-required'
const headerColor =
Expand Down Expand Up @@ -166,7 +172,7 @@ export function InterventionModal({
{titleHeading}
<Flex alignItems={ALIGN_CENTER} onClick={iconHeadingOnClick}>
{iconName != null ? (
<Icon name={iconName} css={ICON_STYLE} />
<Icon name={iconName} css={buildIconStyle(iconSize)} />
) : null}
{iconHeading != null ? iconHeading : null}
</Flex>
Expand All @@ -178,9 +184,11 @@ export function InterventionModal({
)
}

const ICON_STYLE = css`
width: ${SPACING.spacing32};
height: ${SPACING.spacing32};
const buildIconStyle = (
iconSize: string | undefined
): FlattenSimpleInterpolation => css`
width: ${iconSize ?? SPACING.spacing16};
height: ${iconSize ?? SPACING.spacing16};
margin: ${SPACING.spacing4};
cursor: ${CURSOR_POINTER};
Expand Down
6 changes: 5 additions & 1 deletion app/src/organisms/InterventionModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,22 @@ export function InterventionModal({
}
})()

const { iconName, headerTitle, headerTitleOnDevice } = (() => {
const { iconName, headerTitle, headerTitleOnDevice, iconSize } = (() => {
switch (command.commandType) {
case 'waitForResume':
case 'pause':
return {
iconName: 'pause-circle' as IconName,
headerTitle: t('pause_on', { robot_name: robotName }),
headerTitleOnDevice: t('pause'),
iconSize: SPACING.spacing32,
}
case 'moveLabware':
return {
iconName: 'move-xy-circle' as IconName,
headerTitle: t('move_labware_on', { robot_name: robotName }),
headerTitleOnDevice: t('move_labware'),
iconSize: undefined,
}
default:
console.warn(
Expand All @@ -189,6 +191,7 @@ export function InterventionModal({
iconName: null,
headerTitle: '',
headerTitleOnDevice: '',
iconSize: undefined,
}
}
})()
Expand Down Expand Up @@ -228,6 +231,7 @@ export function InterventionModal({
iconHeading={<LegacyStyledText as="h1">{headerTitle}</LegacyStyledText>}
iconName={iconName}
type="intervention-required"
iconSize={iconSize}
>
<Box {...CONTENT_STYLE}>
{childContent}
Expand Down

0 comments on commit 6db5cb3

Please sign in to comment.