-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated documentation for Progress Indicators (#2271)
- Loading branch information
Showing
19 changed files
with
311 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters