Skip to content

Commit 99ee06a

Browse files
authored
feat(protocol-visualization): port SlotDetailsEmptyState (#21249)
# Overview This is a simple porting of `SlotDetailsEmptyState` component and related tests from `app` into `ProtocolVisualization` with minimal changes. This is step 3 of the porting plan. ## Risk assessment - None. Only copies over the said files in a package that is not used anywhere yet.
1 parent c51f2e6 commit 99ee06a

4 files changed

Lines changed: 81 additions & 0 deletions

File tree

protocol-visualization/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export { AnnotatedSteps } from './organisms/AnnotatedSteps'
1111

1212
export type { GroupedCommands, LeafNode } from './types'
1313

14+
export { SlotDetailsEmptyState } from './molecules/SlotDetailsEmptyState'
15+
1416
/**
1517
* Package identifier string (useful for diagnostics or feature flags).
1618
*/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { screen } from '@testing-library/react'
2+
import { beforeEach, describe, it } from 'vitest'
3+
4+
import { SlotDetailsEmptyState } from '..'
5+
import { renderWithProviders } from '../../../__testing-utils__'
6+
7+
import type { ComponentProps } from 'react'
8+
9+
const render = (props: ComponentProps<typeof SlotDetailsEmptyState>) => {
10+
return renderWithProviders(<SlotDetailsEmptyState {...props} />) // TODO: add i18n rendering option
11+
}
12+
13+
describe('SlotDetailsEmptyState', () => {
14+
let props: ComponentProps<typeof SlotDetailsEmptyState>
15+
16+
beforeEach(() => {
17+
props = {
18+
slotId: 'A1',
19+
}
20+
})
21+
22+
it('should render slot empty state', () => {
23+
render(props)
24+
screen.getByText('A1')
25+
screen.getByText('slot_empty')
26+
})
27+
})
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useTranslation } from 'react-i18next'
2+
3+
import { COLORS, RobotInfoLabel, StyledText } from '@opentrons/components'
4+
5+
import styles from './slotdetailsemptystate.module.css'
6+
7+
interface SlotDetailsEmptyStateProps {
8+
slotId: string
9+
}
10+
11+
export function SlotDetailsEmptyState(
12+
props: SlotDetailsEmptyStateProps
13+
): JSX.Element {
14+
const { slotId } = props
15+
const { t } = useTranslation('protocol_visualization')
16+
return (
17+
<div className={styles.slot_empty_container}>
18+
<div className={styles.slot_empty_header}>
19+
<RobotInfoLabel deckLabel={slotId} />
20+
</div>
21+
<div className={styles.slot_empty_body}>
22+
<StyledText desktopStyle="bodyDefaultRegular" color={COLORS.grey50}>
23+
{t('slot_empty')}
24+
</StyledText>
25+
</div>
26+
</div>
27+
)
28+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.slot_empty_container {
2+
display: flex;
3+
width: 100%;
4+
height: 100%;
5+
flex-direction: column;
6+
gap: var(--spacing-16);
7+
}
8+
9+
.slot_empty_header {
10+
display: flex;
11+
width: 100%;
12+
justify-content: flex-start;
13+
}
14+
15+
.slot_empty_body {
16+
display: flex;
17+
width: 100%;
18+
height: 100%;
19+
align-items: center;
20+
justify-content: center;
21+
padding: var(--spacing-16) var(--spacing-24);
22+
border-radius: var(--border-radius-4);
23+
background-color: var(--grey-10);
24+
}

0 commit comments

Comments
 (0)