Skip to content

Commit 028f6f6

Browse files
committed
refactor: use ProgressIndicator in ComponentContext
1 parent d5a34c5 commit 028f6f6

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

src/components/Loading/UploadProgressIndicator.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import clsx from 'clsx';
22
import React from 'react';
33

44
import { useComponentContext } from '../../context';
5-
import { CircularProgressIndicator as DefaultCircularProgressIndicator } from './CircularProgressIndicator';
5+
import { CircularProgressIndicator as DefaultProgressIndicator } from './progress-indicators';
66
import { LoadingIndicator as DefaultLoadingIndicator } from './LoadingIndicator';
77

88
export type UploadProgressIndicatorProps = {
@@ -15,8 +15,8 @@ export const UploadProgressIndicator = ({
1515
uploadProgress,
1616
}: UploadProgressIndicatorProps) => {
1717
const {
18-
CircularProgressIndicator = DefaultCircularProgressIndicator,
1918
LoadingIndicator = DefaultLoadingIndicator,
19+
ProgressIndicator = DefaultProgressIndicator,
2020
} = useComponentContext();
2121

2222
if (uploadProgress === undefined) {
@@ -25,7 +25,7 @@ export const UploadProgressIndicator = ({
2525

2626
return (
2727
<div className={clsx('str-chat__attachment-upload-progress', className)}>
28-
<CircularProgressIndicator percent={uploadProgress} />
28+
<ProgressIndicator percent={uploadProgress} />
2929
</div>
3030
);
3131
};

src/components/Loading/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ export * from './LoadingChannel';
22
export * from './LoadingChannels';
33
export * from './LoadingErrorIndicator';
44
export * from './LoadingIndicator';
5-
export * from './CircularProgressIndicator';
5+
export * from './progress-indicators';
66
export * from './UploadProgressIndicator';
77
export * from './UploadedSizeIndicator';

src/components/Loading/CircularProgressIndicator.tsx renamed to src/components/Loading/progress-indicators.tsx

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

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

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

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

File renamed without changes.
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 'CircularProgressIndicator';
3+
@use 'ProgressIndicator';

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 { CircularProgressIndicatorProps } from '../components/Loading/CircularProgressIndicator';
77+
import type { ProgressIndicatorProps } from '../components/Loading/progress-indicators';
7878
import type { UploadedSizeIndicatorProps } from '../components/Loading/UploadedSizeIndicator';
7979

8080
export type ComponentContextValue = {
@@ -150,8 +150,8 @@ export type ComponentContextValue = {
150150
LoadingErrorIndicator?: React.ComponentType<LoadingErrorIndicatorProps>;
151151
/** 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) */
152152
LoadingIndicator?: React.ComponentType<LoadingIndicatorProps>;
153-
/** 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) */
154-
CircularProgressIndicator?: React.ComponentType<CircularProgressIndicatorProps>;
153+
/** 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/progress-indicators.tsx) */
154+
ProgressIndicator?: React.ComponentType<ProgressIndicatorProps>;
155155
/** 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) */
156156
Message?: React.ComponentType<MessageUIComponentProps>;
157157
/** 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)