Skip to content

Commit 049c1e6

Browse files
Add loader
1 parent 759b6e1 commit 049c1e6

File tree

7 files changed

+85
-9
lines changed

7 files changed

+85
-9
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { type Theme } from 'baseui';
2+
import { type SkeletonOverrides } from 'baseui/skeleton/types';
3+
import { type StyleObject } from 'styletron-react';
4+
5+
export const overrides = {
6+
borderSkeleton: {
7+
Row: {
8+
style: ({ $theme }: { $theme: Theme }): StyleObject => ({
9+
height: $theme.sizing.scale600,
10+
borderRadius: $theme.borders.radius500,
11+
}),
12+
},
13+
} satisfies SkeletonOverrides,
14+
centralSkeleton: {
15+
Root: {
16+
style: ({ $theme }: { $theme: Theme }): StyleObject => ({
17+
marginLeft: $theme.sizing.scale550,
18+
marginTop: $theme.sizing.scale400,
19+
marginBottom: $theme.sizing.scale400,
20+
}),
21+
},
22+
Row: {
23+
style: ({ $theme }: { $theme: Theme }): StyleObject => ({
24+
height: $theme.sizing.scale600,
25+
borderRadius: $theme.borders.radius500,
26+
}),
27+
},
28+
} satisfies SkeletonOverrides,
29+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use client';
2+
import { Skeleton } from 'baseui/skeleton';
3+
4+
import { overrides } from './pretty-json-skeleton.styles';
5+
import { type Props } from './pretty-json-skeleton.types';
6+
7+
export default function PrettyJsonSkeleton({ width }: Props) {
8+
return (
9+
<div>
10+
<Skeleton
11+
width="20px"
12+
rows={1}
13+
overrides={overrides.borderSkeleton}
14+
animation
15+
/>
16+
<Skeleton
17+
width={width}
18+
rows={3}
19+
overrides={overrides.centralSkeleton}
20+
animation
21+
/>
22+
<Skeleton
23+
width="20px"
24+
rows={1}
25+
overrides={overrides.borderSkeleton}
26+
animation
27+
/>
28+
</div>
29+
);
30+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type Props = {
2+
width: string;
3+
};

src/views/workflow-summary-tab/workflow-summary-tab-json-view/__tests__/workflow-summary-tab-json-view.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jest.mock(
1515
jest.mock('@/components/pretty-json/pretty-json', () =>
1616
jest.fn(() => <div>PrettyJson Mock</div>)
1717
);
18+
jest.mock('@/components/pretty-json-skeleton/pretty-json-skeleton', () =>
19+
jest.fn(() => <div>Mock JSON skeleton</div>)
20+
);
1821

1922
describe('WorkflowSummaryTabJsonView Component', () => {
2023
const inputJson = { input: 'inputJson' };
@@ -25,18 +28,33 @@ describe('WorkflowSummaryTabJsonView Component', () => {
2528
<WorkflowSummaryTabJsonView
2629
inputJson={inputJson}
2730
resultJson={resultJson}
31+
isWorkflowRunning={false}
2832
/>
2933
);
3034

3135
expect(getByText('SegmentedControlRounded Mock')).toBeInTheDocument();
3236
expect(getByText('PrettyJson Mock')).toBeInTheDocument();
3337
});
3438

39+
it('renders loading state correctly', () => {
40+
const { getByText } = render(
41+
<WorkflowSummaryTabJsonView
42+
inputJson={inputJson}
43+
resultJson={resultJson}
44+
isWorkflowRunning={true}
45+
/>
46+
);
47+
48+
expect(getByText('SegmentedControlRounded Mock')).toBeInTheDocument();
49+
expect(getByText('Mock JSON skeleton')).toBeInTheDocument();
50+
});
51+
3552
it('handles tab change', () => {
3653
render(
3754
<WorkflowSummaryTabJsonView
3855
inputJson={inputJson}
3956
resultJson={resultJson}
57+
isWorkflowRunning={false}
4058
/>
4159
);
4260

@@ -51,6 +69,7 @@ describe('WorkflowSummaryTabJsonView Component', () => {
5169
<WorkflowSummaryTabJsonView
5270
inputJson={inputJson}
5371
resultJson={resultJson}
72+
isWorkflowRunning={false}
5473
/>
5574
);
5675

@@ -67,6 +86,7 @@ describe('WorkflowSummaryTabJsonView Component', () => {
6786
<WorkflowSummaryTabJsonView
6887
inputJson={inputJson}
6988
resultJson={resultJson}
89+
isWorkflowRunning={false}
7090
/>
7191
);
7292

src/views/workflow-summary-tab/workflow-summary-tab-json-view/workflow-summary-tab-json-view.styles.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
const cssStylesObj = {
77
jsonViewContainer: (theme) => ({
88
padding: theme.sizing.scale600,
9-
backgroundColor: theme.colors.backgroundSecondary,
9+
backgroundColor: '#F8F8F8',
1010
borderRadius: theme.borders.radius300,
1111
}),
1212
jsonViewHeader: (theme) => ({
@@ -15,9 +15,6 @@ const cssStylesObj = {
1515
gap: theme.sizing.scale600,
1616
marginBottom: theme.sizing.scale700,
1717
}),
18-
spinnerContainer: (theme) => ({
19-
paddingLeft: 0,
20-
}),
2118
} satisfies StyletronCSSObject;
2219

2320
export const cssStyles: StyletronCSSObjectOf<typeof cssStylesObj> =

src/views/workflow-summary-tab/workflow-summary-tab-json-view/workflow-summary-tab-json-view.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import React, { useEffect, useState } from 'react';
33

44
import { Button, KIND as BUTTON_KIND, SHAPE, SIZE } from 'baseui/button';
5-
import { Spinner } from 'baseui/spinner';
65
import { ACCESSIBILITY_TYPE, Tooltip } from 'baseui/tooltip';
76
import copy from 'copy-to-clipboard';
87
import { MdCopyAll } from 'react-icons/md';
98

109
import PrettyJson from '@/components/pretty-json/pretty-json';
1110
import { type JsonValue } from '@/components/pretty-json/pretty-json.types';
11+
import PrettyJsonSkeleton from '@/components/pretty-json-skeleton/pretty-json-skeleton';
1212
import SegmentedControlRounded from '@/components/segmented-control-rounded/segmented-control-rounded';
1313
import useStyletronClasses from '@/hooks/use-styletron-classes';
1414

@@ -70,9 +70,7 @@ export default function WorkflowSummaryTabJsonView({
7070
</Tooltip>
7171
</div>
7272
{activeTab === 'result' && isWorkflowRunning ? (
73-
<div className={cls.spinnerContainer}>
74-
<Spinner $size={16} />
75-
</div>
73+
<PrettyJsonSkeleton width="200px" />
7674
) : (
7775
<PrettyJson json={jsonMap[activeTab]} />
7876
)}

src/views/workflow-summary-tab/workflow-summary-tab.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import React from 'react';
33

44
import { useSuspenseQuery } from '@tanstack/react-query';
5-
import { Spinner } from 'baseui/spinner';
65
import queryString from 'query-string';
76

87
import PageSection from '@/components/page-section/page-section';

0 commit comments

Comments
 (0)