Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated documentation for Progress Indicators #2271

Merged
merged 37 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8f3f408
Updated documentation for progress indicators
smmr-dn Sep 26, 2024
2147191
added value example
smmr-dn Sep 26, 2024
0dda245
Merge branch 'main' into uyen/progress-indicator-doc
smmr-dn Sep 26, 2024
b3f0af7
cleaned up
smmr-dn Sep 26, 2024
75db4f2
Merge branch 'uyen/progress-indicator-doc' of https://github.com/iTwi…
smmr-dn Sep 26, 2024
b9e42ae
wording
smmr-dn Sep 26, 2024
69bcb67
reworded and moved sections around
smmr-dn Sep 27, 2024
6297ccc
added example
smmr-dn Sep 27, 2024
7a5a00b
wording
smmr-dn Sep 27, 2024
77a128a
wording
smmr-dn Sep 27, 2024
06f8afc
Merge branch 'main' into uyen/progress-indicator-doc
smmr-dn Sep 30, 2024
f7f3b29
wording
smmr-dn Sep 30, 2024
46d9a81
Merge branch 'uyen/progress-indicator-doc' of https://github.com/iTwi…
smmr-dn Sep 30, 2024
bee5965
wording
smmr-dn Oct 2, 2024
b03f92e
more wording for status
smmr-dn Oct 2, 2024
972550d
more wording for status
smmr-dn Oct 2, 2024
8d15f25
explicitly mentioned components
smmr-dn Oct 2, 2024
4d1e5b9
Merge branch 'main' into uyen/progress-indicator-doc
smmr-dn Oct 2, 2024
d2beceb
combined examples
smmr-dn Oct 2, 2024
9ad9d13
Merge branch 'uyen/progress-indicator-doc' of https://github.com/iTwi…
smmr-dn Oct 2, 2024
94f8fcf
combined examples
smmr-dn Oct 2, 2024
6249f88
combined examples
smmr-dn Oct 2, 2024
39ddc09
wording
smmr-dn Oct 2, 2024
0e0a2bf
added more into isAnimated example
smmr-dn Oct 2, 2024
a3597bb
Merge branch 'main' into uyen/progress-indicator-doc
smmr-dn Oct 2, 2024
4589bc3
added more into isAnimated example
smmr-dn Oct 2, 2024
273c564
Merge branch 'uyen/progress-indicator-doc' of https://github.com/iTwi…
smmr-dn Oct 2, 2024
f47cbff
comments
smmr-dn Oct 3, 2024
03f4f12
Merge branch 'main' into uyen/progress-indicator-doc
smmr-dn Oct 3, 2024
8505c8f
comments
smmr-dn Oct 3, 2024
ba61469
simpified css
smmr-dn Oct 3, 2024
7d10091
used setInterval
smmr-dn Oct 3, 2024
0b09d44
reorganized
smmr-dn Oct 3, 2024
8bd581a
clearInterval instead of clearTimeout
smmr-dn Oct 3, 2024
c5d68d0
Merge branch 'main' into uyen/progress-indicator-doc
smmr-dn Oct 7, 2024
c654e59
Merge branch 'main' into uyen/progress-indicator-doc
smmr-dn Oct 8, 2024
c4e973b
wording
smmr-dn Oct 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 80 additions & 12 deletions apps/website/src/content/docs/progressindicator.mdx
Original file line number Diff line number Diff line change
@@ -1,37 +1,105 @@
---
title: Progress indicator
description: Progress indicators express an unspecified wait time or display the length of a process.
description: Progress indicators express the length of in-progress operations.
thumbnail: ProgressIndicator
---

<p>{frontmatter.description}</p>

## Progress linear
## Usage

<Placeholder componentPageName='progresslinear--determinate' />
There are two types of progress indicators available as separate components:

<LiveExample src='ProgressLinear.main.jsx' truncate={false}>
<AllExamples.ProgressLinearMainExample client:load />
- `ProgressLinear`: shows progress on a linear bar.
- `ProgressRadial`: shows progress in a circular form.

<LiveExample src='ProgressIndicators.main.jsx' truncate={false}>
<AllExamples.ProgressIndicatorsMainExample client:load />
</LiveExample>

### Props
By default, the progress indicators are considered to be "indeterminate". This is useful for short processes, where it isn't necessary (or possible) to indicate the completion percentage. For longer processes, a "determinate" progress indicator should be used.

<PropsTable path='@itwin/itwinui-react/esm/core/ProgressIndicators/ProgressLinear.d.ts' />
### Value

## Progress radial
To specify a value for determinate progress indicator, the `value` prop can be used. This prop is available for both `ProgressLinear` and `ProgressRadial`. The value must be inclusively between `0` and `100`, representing what percentage of the task has been completed.

<Placeholder componentPageName='progressradial--determinate' />
<LiveExample src='ProgressIndicators.value.jsx' truncate={false}>
<AllExamples.ProgressIndicatorsValueExample client:load />
</LiveExample>

<LiveExample src='ProgressRadial.main.jsx' truncate={false}>
<AllExamples.ProgressRadialMainExample client:load />
Exclusively for `ProgressLinear`, the `isAnimated` flag is helpful when applying animation to the indicator as the value changes.

<LiveExample src='ProgressLinear.isAnimated.jsx'>
<AllExamples.ProgressLinearAnimatedExample client:load />
</LiveExample>

**Note**: If the `indeterminate` prop is set to `true`, this value will be ignored.

### Status

The `status` prop can be used to convey the outcome of a process. The recommended UX flow is to display the default progress indicator during the loading process, and then update the `status` to reflect whether the process was successful, encountered an error, or requires attention.

Three available statuses are:

- `"positive"`: to indicate success.
- `"negative"`: to indicate failure.
- `"warning"`: to indicate a cautionary state or partial success.

<LiveExample src='ProgressLinear.status.jsx'>
<AllExamples.ProgressLinearStatusExample client:load />
</LiveExample>

When using the `status` prop, each `ProgressRadial` is accompanied by a status icon, which provides a visual cue to inform the current progress state better. The status icon can also be replaced by custom [content](#content) for more advanced uses.

<LiveExample src='ProgressRadial.status.jsx'>
<AllExamples.ProgressRadialStatusExample client:load />
</LiveExample>

### Label

Indicator labels can be passed into the `labels` prop as an array. If one label is passed, it will be centered. If there are two labels, each is pushed to one end of the progress indicator. This prop is only available for `ProgressLinear`.

<LiveExample src='ProgressLinear.label.jsx'>
<AllExamples.ProgressLinearLabelExample client:load />
</LiveExample>

### Size

Four `size` options available are:

- `"x-small"`
- `"small"`
- `"medium"` (default)
- `"large"`

This prop is only available for `ProgressRadial`.

<LiveExample src='ProgressRadial.size.jsx'>
<AllExamples.ProgressRadialSizeExample client:load />
</LiveExample>

### Content

The `ProgressRadial` component can be wrapped around JSX elements, such as icons or texts. This content helps provide flexibility to enhance the progress display with additional visual appearance. This prop is only available for `ProgressRadial`.

<LiveExample src='ProgressRadial.content.jsx'>
<AllExamples.ProgressRadialContentExample client:load />
</LiveExample>

**Note**: Indicators of `"x-small"` size will not display its content.

## Accessibility

To make the progress indicator accessible to non-sighted users, a visually-hidden "Loading" message will be automatically included when the `value` is not set to 100%.

To further improve the experience, applications should have a mechanism to inform users once the loading process is complete. Depending on the criticality of the content and how long it takes to load, the progress completion can be indicated using a [live region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions), or by programmatically moving focus to the top of the new content.

### Props
## Props

### ProgressLinear

<PropsTable path='@itwin/itwinui-react/esm/core/ProgressIndicators/ProgressLinear.d.ts' />

### ProgressRadial

<PropsTable path='@itwin/itwinui-react/esm/core/ProgressIndicators/ProgressRadial.d.ts' />
6 changes: 6 additions & 0 deletions examples/ProgressIndicators.main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.demo-container {
display: flex;
flex-direction: column;
width: 200px;
gap: var(--iui-size-s);
}
15 changes: 15 additions & 0 deletions examples/ProgressIndicators.main.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { ProgressLinear, ProgressRadial } from '@itwin/itwinui-react';

export default () => {
return (
<div className='demo-container'>
<ProgressLinear />
<ProgressRadial />
</div>
);
};
6 changes: 6 additions & 0 deletions examples/ProgressIndicators.value.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.demo-container {
display: flex;
flex-direction: column;
width: 200px;
gap: var(--iui-size-s);
}
15 changes: 15 additions & 0 deletions examples/ProgressIndicators.value.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { ProgressLinear, ProgressRadial } from '@itwin/itwinui-react';

export default () => {
return (
<div className='demo-container'>
<ProgressLinear value={20} />
<ProgressRadial value={50} />
</div>
);
};
6 changes: 6 additions & 0 deletions examples/ProgressLinear.isAnimated.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.demo-container {
width: 200px;
display: flex;
flex-direction: column;
gap: var(--iui-size-xs);
}
37 changes: 37 additions & 0 deletions examples/ProgressLinear.isAnimated.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { Button, ProgressLinear } from '@itwin/itwinui-react';

export default () => {
const [value, setValue] = React.useState(0);
const isDone = value === 100;

React.useEffect(() => {
let interval;

if (!isDone) {
interval = setInterval(
() => setValue((prevValue) => prevValue + 20),
1500,
);
}

return () => clearInterval(interval);
}, [isDone]);

return (
<div className='demo-container'>
<ProgressLinear
value={value}
isAnimated={!isDone}
labels={!isDone ? ['Loading...', `${value}%`] : ['Upload succeeded.']}
status={isDone ? 'positive' : undefined}
key={isDone.toString()}
/>
<Button onClick={() => setValue(0)}>Reset process</Button>
</div>
);
};
6 changes: 6 additions & 0 deletions examples/ProgressLinear.label.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.demo-container {
display: flex;
flex-direction: column;
gap: var(--iui-size-s);
width: min(100%, 200px);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { ProgressLinear } from '@itwin/itwinui-react';
export default () => {
return (
<div className='demo-container'>
<ProgressLinear indeterminate />
<ProgressLinear value={50} labels={['Centered Label']} />
<ProgressLinear value={50} labels={['Loading...', '50%']} />
</div>
);
};
3 changes: 0 additions & 3 deletions examples/ProgressLinear.main.css

This file was deleted.

6 changes: 6 additions & 0 deletions examples/ProgressLinear.status.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.demo-container {
display: flex;
flex-direction: column;
gap: var(--iui-size-s);
width: min(100%, 200px);
}
28 changes: 28 additions & 0 deletions examples/ProgressLinear.status.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { ProgressLinear } from '@itwin/itwinui-react';

export default () => {
return (
<div className='demo-container'>
<ProgressLinear
value={100}
labels={['Upload succeeded!']}
status='positive'
/>
<ProgressLinear
value={50}
labels={['Upload failed.', '50%']}
status='negative'
/>
<ProgressLinear
value={75}
labels={['Attention required.', '75%']}
status='warning'
/>
</div>
);
};
14 changes: 14 additions & 0 deletions examples/ProgressRadial.content.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { ProgressRadial, Text } from '@itwin/itwinui-react';

export default () => {
return (
<ProgressRadial value={100} status='positive' size='large'>
<Text variant='small'>100%</Text>
</ProgressRadial>
);
};
6 changes: 6 additions & 0 deletions examples/ProgressRadial.size.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.demo-container {
display: flex;
flex-direction: row;
align-items: center;
gap: var(--iui-size-s);
}
17 changes: 17 additions & 0 deletions examples/ProgressRadial.size.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { ProgressRadial } from '@itwin/itwinui-react';

export default () => {
return (
<div className='demo-container'>
<ProgressRadial size='x-small' />
<ProgressRadial size='small' />
<ProgressRadial />
<ProgressRadial size='large' />
</div>
);
};
6 changes: 6 additions & 0 deletions examples/ProgressRadial.status.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.demo-container {
display: flex;
flex-direction: row;
align-items: center;
gap: var(--iui-size-s);
}
16 changes: 16 additions & 0 deletions examples/ProgressRadial.status.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { ProgressRadial } from '@itwin/itwinui-react';

export default () => {
return (
<div className='demo-container'>
<ProgressRadial value={100} status='positive' />
<ProgressRadial value={50} status='negative' />
<ProgressRadial value={75} status='warning' />
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import * as React from 'react';
import { ProgressRadial } from '@itwin/itwinui-react';

export default () => {
return <ProgressRadial indeterminate />;
return <ProgressRadial value={50} />;
};
52 changes: 44 additions & 8 deletions examples/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -900,17 +900,53 @@ export const PopoverFocusExample = withThemeProvider(PopoverFocusExampleRaw);

// ----------------------------------------------------------------------------

import { default as ProgressLinearMainExampleRaw } from './ProgressLinear.main';
const ProgressLinearMainExample = withThemeProvider(
ProgressLinearMainExampleRaw,
import { default as ProgressIndicatorsMainExampleRaw } from './ProgressIndicators.main';
const ProgressIndicatorsMainExample = withThemeProvider(
ProgressIndicatorsMainExampleRaw,
);
export { ProgressLinearMainExample };
export { ProgressIndicatorsMainExample };

import { default as ProgressRadialMainExampleRaw } from './ProgressRadial.main';
const ProgressRadialMainExample = withThemeProvider(
ProgressRadialMainExampleRaw,
import { default as ProgressIndicatorsValueExampleRaw } from './ProgressIndicators.value';
const ProgressIndicatorsValueExample = withThemeProvider(
ProgressIndicatorsValueExampleRaw,
);
export { ProgressRadialMainExample };
export { ProgressIndicatorsValueExample };

import { default as ProgressLinearAnimatedExampleRaw } from './ProgressLinear.isAnimated';
const ProgressLinearAnimatedExample = withThemeProvider(
ProgressLinearAnimatedExampleRaw,
);
export { ProgressLinearAnimatedExample };

import { default as ProgressLinearLabelExampleRaw } from './ProgressLinear.label';
const ProgressLinearLabelExample = withThemeProvider(
ProgressLinearLabelExampleRaw,
);
export { ProgressLinearLabelExample };

import { default as ProgressLinearStatusExampleRaw } from './ProgressLinear.status';
const ProgressLinearStatusExample = withThemeProvider(
ProgressLinearStatusExampleRaw,
);
export { ProgressLinearStatusExample };

import { default as ProgressRadialSizeExampleRaw } from './ProgressRadial.size';
const ProgressRadialSizeExample = withThemeProvider(
ProgressRadialSizeExampleRaw,
);
export { ProgressRadialSizeExample };

import { default as ProgressRadialContentExampleRaw } from './ProgressRadial.content';
const ProgressRadialContentExample = withThemeProvider(
ProgressRadialContentExampleRaw,
);
export { ProgressRadialContentExample };

import { default as ProgressRadialStatusExampleRaw } from './ProgressRadial.status';
const ProgressRadialStatusExample = withThemeProvider(
ProgressRadialStatusExampleRaw,
);
export { ProgressRadialStatusExample };

// ----------------------------------------------------------------------------

Expand Down
Loading