Skip to content

Commit 1ae94ec

Browse files
authored
feat(app): add Skeleton component for second window (#20298)
* feat(app): add Skeleton component for second window
1 parent a102faf commit 1ae94ec

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { BORDERS } from '@opentrons/components'
2+
3+
import { Skeleton } from '/app/atoms/Skeleton'
4+
5+
import styles from './skeletonforslotdetail.module.css'
6+
7+
// backgroundSize 23px + 360px from the default design size
8+
export function SkeletonForSlotDetail(): JSX.Element {
9+
return (
10+
<div className={styles.slot_loading_container}>
11+
<div className={styles.slot_loading_header}>
12+
<Skeleton
13+
width="23px"
14+
height="20px"
15+
borderRadius={BORDERS.borderRadius4}
16+
backgroundSize="24rem"
17+
/>
18+
</div>
19+
<div className={styles.slot_loading_body}>
20+
<Skeleton
21+
width="100%"
22+
height="100%"
23+
backgroundSize="24rem"
24+
borderRadius={BORDERS.borderRadius4}
25+
/>
26+
</div>
27+
</div>
28+
)
29+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { screen } from '@testing-library/react'
2+
import { beforeEach, describe, expect, it, vi } from 'vitest'
3+
4+
import { renderWithProviders } from '/app/__testing-utils__'
5+
import { Skeleton } from '/app/atoms/Skeleton'
6+
7+
import { SkeletonForSlotDetail } from '../SkeletonForSlotDetail'
8+
9+
vi.mock('/app/atoms/Skeleton')
10+
11+
const render = () => {
12+
return renderWithProviders(<SkeletonForSlotDetail />)
13+
}
14+
15+
describe('SkeletonForSlotDetail', () => {
16+
beforeEach(() => {
17+
vi.mocked(Skeleton).mockReturnValue(<div>mock Skeleton</div>)
18+
})
19+
it('should render two Skeleton components', () => {
20+
render()
21+
expect(screen.getAllByText('mock Skeleton')).toHaveLength(2)
22+
})
23+
})

app/src/pages/Desktop/StepDetailViewer/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { useParams } from 'react-router-dom'
33

44
import { SlotDetails } from '/app/organisms/Desktop/ProtocolVisualization/SlotDetails'
55

6+
import { SkeletonForSlotDetail } from './SkeletonForSlotDetail'
7+
68
import type {
79
Liquid,
810
ProtocolAnalysisOutput,
@@ -74,7 +76,7 @@ export function StepDetailViewer(): JSX.Element {
7476
}, [protocolKey])
7577

7678
if (loading) {
77-
return <div>loading</div>
79+
return <SkeletonForSlotDetail />
7880
}
7981
if (!data) {
8082
return <div>no data found</div>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.slot_loading_container {
2+
display: flex;
3+
width: 100%;
4+
height: 100%;
5+
flex-direction: column;
6+
padding: var(--spacing-16) var(--spacing-20);
7+
gap: var(--spacing-16);
8+
}
9+
10+
.slot_loading_header {
11+
display: flex;
12+
width: 100%;
13+
justify-content: flex-start;
14+
}
15+
16+
.slot_loading_body {
17+
display: flex;
18+
width: 100%;
19+
height: 100%;
20+
align-items: center;
21+
justify-content: center;
22+
border-radius: var(--border-radius-4);
23+
background-color: var(--grey-10);
24+
}

0 commit comments

Comments
 (0)