Skip to content

Commit 77ba34c

Browse files
committed
refactor: rename ProgressIndicator to CircularProgressIndicator
1 parent b45192a commit 77ba34c

File tree

7 files changed

+19
-16
lines changed

7 files changed

+19
-16
lines changed

src/components/Loading/ProgressIndicator.tsx renamed to src/components/Loading/CircularProgressIndicator.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,26 @@ import { useTranslationContext } from '../../context/TranslationContext';
55
const RING_RADIUS = 12;
66
const RING_CIRCUMFERENCE = 2 * Math.PI * RING_RADIUS;
77

8-
export type ProgressIndicatorProps = {
8+
export type CircularProgressIndicatorProps = {
99
/** Clamped 0–100 completion. */
1010
percent: number;
1111
};
1212

1313
/** Circular progress indicator with input from 0 to 100. */
14-
export const ProgressIndicator = ({ percent }: ProgressIndicatorProps) => {
15-
const { t } = useTranslationContext('ProgressIndicator');
14+
export const CircularProgressIndicator = ({
15+
percent,
16+
}: CircularProgressIndicatorProps) => {
17+
const { t } = useTranslationContext('CircularProgressIndicator');
1618
const dashOffset = RING_CIRCUMFERENCE * (1 - percent / 100);
1719

1820
return (
19-
<div className='str-chat__progress-indicator'>
21+
<div className='str-chat__circular-progress-indicator'>
2022
<svg
2123
aria-label={t('aria/Percent complete', { percent })}
2224
aria-valuemax={100}
2325
aria-valuemin={0}
2426
aria-valuenow={percent}
25-
data-testid='progress-ring'
27+
data-testid='circular-progress-ring'
2628
height='100%'
2729
role='progressbar'
2830
viewBox='0 0 32 32'

src/components/Loading/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ export * from './LoadingChannel';
22
export * from './LoadingChannels';
33
export * from './LoadingErrorIndicator';
44
export * from './LoadingIndicator';
5-
export * from './ProgressIndicator';
5+
export * from './CircularProgressIndicator';

src/components/Loading/styling/ProgressIndicator.scss renamed to src/components/Loading/styling/CircularProgressIndicator.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.str-chat__progress-indicator {
1+
.str-chat__circular-progress-indicator {
22
width: 100%;
33
height: 100%;
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@use 'LoadingChannels';
22
@use 'LoadingIndicator';
3-
@use 'ProgressIndicator';
3+
@use 'CircularProgressIndicator';

src/components/MessageComposer/AttachmentPreviewList/AttachmentUploadProgressIndicator.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import clsx from 'clsx';
22
import React, { type ReactNode } from 'react';
33

4-
import { ProgressIndicator as DefaultProgressIndicator } from '../../Loading';
4+
import { CircularProgressIndicator as DefaultCircularProgressIndicator } from '../../Loading';
55
import { useComponentContext } from '../../../context';
66
import { LoadingIndicatorIcon } from '../icons';
77

@@ -17,15 +17,16 @@ export const AttachmentUploadProgressIndicator = ({
1717
fallback,
1818
uploadProgress,
1919
}: AttachmentUploadProgressIndicatorProps) => {
20-
const { ProgressIndicator = DefaultProgressIndicator } = useComponentContext();
20+
const { CircularProgressIndicator = DefaultCircularProgressIndicator } =
21+
useComponentContext();
2122

2223
if (uploadProgress === undefined) {
2324
return <>{fallback ?? <LoadingIndicatorIcon data-testid='loading-indicator' />}</>;
2425
}
2526

2627
return (
2728
<div className={clsx('str-chat__attachment-upload-progress', className)}>
28-
<ProgressIndicator percent={uploadProgress} />
29+
<CircularProgressIndicator percent={uploadProgress} />
2930
</div>
3031
);
3132
};

src/components/MessageComposer/__tests__/AttachmentPreviewList.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ describe('AttachmentPreviewList', () => {
353353
});
354354

355355
expect(screen.getByTestId(LOADING_INDICATOR_TEST_ID)).toBeInTheDocument();
356-
expect(screen.queryByTestId('progress-ring')).not.toBeInTheDocument();
356+
expect(screen.queryByTestId('circular-progress-ring')).not.toBeInTheDocument();
357357
});
358358

359359
it('shows ring while uploading when uploadProgress is numeric', async () => {
@@ -370,7 +370,7 @@ describe('AttachmentPreviewList', () => {
370370
],
371371
});
372372

373-
expect(screen.getByTestId('progress-ring')).toBeInTheDocument();
373+
expect(screen.getByTestId('circular-progress-ring')).toBeInTheDocument();
374374
expect(screen.queryByTestId(LOADING_INDICATOR_TEST_ID)).not.toBeInTheDocument();
375375
});
376376

src/context/ComponentContext.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ import type { VideoPlayerProps } from '../components/VideoPlayer';
7474
import type { EditedMessagePreviewProps } from '../components/MessageComposer/EditedMessagePreview';
7575
import type { FileIconProps } from '../components/FileIcon/FileIcon';
7676
import type { CommandChipProps } from '../components/MessageComposer/CommandChip';
77-
import type { ProgressIndicatorProps } from '../components/Loading/ProgressIndicator';
77+
import type { CircularProgressIndicatorProps } from '../components/Loading/CircularProgressIndicator';
7878

7979
export type ComponentContextValue = {
8080
/** Custom UI component to display additional message composer action buttons left to the textarea, defaults to and accepts same props as: [AdditionalMessageComposerActions](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageComposer/MessageComposerActions.tsx) */
@@ -149,8 +149,8 @@ export type ComponentContextValue = {
149149
LoadingErrorIndicator?: React.ComponentType<LoadingErrorIndicatorProps>;
150150
/** Custom UI component to render while the `MessageList` is loading new messages, defaults to and accepts same props as: [LoadingIndicator](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Loading/LoadingIndicator.tsx) */
151151
LoadingIndicator?: React.ComponentType<LoadingIndicatorProps>;
152-
/** Custom UI component for determinate progress (0–100), defaults to and accepts same props as: [ProgressIndicator](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Loading/ProgressIndicator.tsx) */
153-
ProgressIndicator?: React.ComponentType<ProgressIndicatorProps>;
152+
/** Custom UI component for determinate progress (0–100), defaults to and accepts same props as: [CircularProgressIndicator](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Loading/CircularProgressIndicator.tsx) */
153+
CircularProgressIndicator?: React.ComponentType<CircularProgressIndicatorProps>;
154154
/** Custom UI component to display a message in the standard `MessageList`, defaults to and accepts the same props as: [MessageUI](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/MessageUI.tsx) */
155155
Message?: React.ComponentType<MessageUIComponentProps>;
156156
/** Custom UI component for message actions popup, accepts no props, all the defaults are set within [MessageActions (unstable)](https://github.com/GetStream/stream-chat-react/blob/master/src/experimental/MessageActions/MessageActions.tsx) */

0 commit comments

Comments
 (0)