@availity/mui-progress 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.3.0](https://github.com/Availity/element/compare/@availity/mui-progress@0.2.2...@availity/mui-progress@0.3.0) (2024-09-03)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **mui-progress:** add LinearProgress component ([1f82d8f](https://github.com/Availity/element/commit/1f82d8f0691e1dc5d6b5f86993dfc2a0e2e1aeb8))
|
|
11
|
+
|
|
5
12
|
## [0.2.2](https://github.com/Availity/element/compare/@availity/mui-progress@0.2.1...@availity/mui-progress@0.2.2) (2024-08-08)
|
|
6
13
|
|
|
7
14
|
### Dependency Updates
|
package/README.md
CHANGED
|
@@ -48,14 +48,16 @@ yarn add @availity/mui-progress
|
|
|
48
48
|
|
|
49
49
|
### Usage
|
|
50
50
|
|
|
51
|
+
The two progress components we have are `CircularProgress` and `LinearProgress`.
|
|
52
|
+
|
|
51
53
|
#### Import through @availity/element
|
|
52
54
|
|
|
53
55
|
```tsx
|
|
54
|
-
import { CircularProgress } from '@availity/element';
|
|
56
|
+
import { CircularProgress, LinearProgress } from '@availity/element';
|
|
55
57
|
```
|
|
56
58
|
|
|
57
59
|
#### Direct import
|
|
58
60
|
|
|
59
61
|
```tsx
|
|
60
|
-
import { CircularProgress } from '@availity/mui-progress';
|
|
62
|
+
import { CircularProgress, LinearProgress } from '@availity/mui-progress';
|
|
61
63
|
```
|
package/package.json
CHANGED
|
@@ -4,14 +4,14 @@ import type { Meta, StoryObj } from '@storybook/react';
|
|
|
4
4
|
import { CircularProgress, CircularProgressProps } from './CircularProgress';
|
|
5
5
|
|
|
6
6
|
const meta: Meta<typeof CircularProgress> = {
|
|
7
|
-
title: 'Components/Progress/
|
|
7
|
+
title: 'Components/Progress/CircularProgress',
|
|
8
8
|
component: CircularProgress,
|
|
9
9
|
tags: ['autodocs'],
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export default meta;
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const _CircularProgress: StoryObj<typeof CircularProgress> = {
|
|
15
15
|
render: (args: CircularProgressProps) => <CircularProgress {...args} />,
|
|
16
16
|
args: {},
|
|
17
17
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { LinearProgress, LinearProgressProps } from './LinearProgress';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof LinearProgress> = {
|
|
5
|
+
title: 'Components/Progress/LinearProgress',
|
|
6
|
+
component: LinearProgress,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
export const _LinearProgress: StoryObj<typeof LinearProgress> = {
|
|
13
|
+
render: (args: LinearProgressProps) => <LinearProgress {...args} />,
|
|
14
|
+
args: {
|
|
15
|
+
value: 50,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
|
|
3
|
+
import { LinearProgress } from './LinearProgress';
|
|
4
|
+
|
|
5
|
+
describe('LinearProgress', () => {
|
|
6
|
+
test('should render successfully', () => {
|
|
7
|
+
render(<LinearProgress />);
|
|
8
|
+
|
|
9
|
+
expect(screen.getByRole('progressbar')).toBeDefined();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('should show default value of 0', () => {
|
|
13
|
+
render(<LinearProgress />);
|
|
14
|
+
expect(screen.getByText('0%')).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('should show show value as percentage', () => {
|
|
18
|
+
render(<LinearProgress value={50} />);
|
|
19
|
+
expect(screen.getByText('50%')).toBeDefined();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('should show icon when value is 100', () => {
|
|
23
|
+
const { container } = render(<LinearProgress value={100} />);
|
|
24
|
+
const svgEl = container.querySelector("[data-icon='complete']") as HTMLImageElement;
|
|
25
|
+
expect(screen.getByText('100%')).toBeDefined();
|
|
26
|
+
expect(svgEl.classList.toString()).toContain('MuiSvgIcon-root');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SuccessCircleIcon } from '@availity/mui-icon';
|
|
2
|
+
import { Box, Stack } from '@availity/mui-layout';
|
|
3
|
+
import { Typography } from '@availity/mui-typography';
|
|
4
|
+
import MuiLinearProgress, { LinearProgressProps as MuiLinearProgressProps } from '@mui/material/LinearProgress';
|
|
5
|
+
|
|
6
|
+
export type LinearProgressProps = Omit<MuiLinearProgressProps, 'color'>;
|
|
7
|
+
|
|
8
|
+
export const LinearProgress = ({ variant = 'determinate', value = 0, sx, ...props }: LinearProgressProps) => {
|
|
9
|
+
return (
|
|
10
|
+
<Stack direction="row" alignItems="center">
|
|
11
|
+
<Box sx={{ width: '100%', mr: 0.5 }}>
|
|
12
|
+
<MuiLinearProgress variant={variant} {...props} value={value} color="success" sx={{ width: '100%', ...sx }} />
|
|
13
|
+
</Box>
|
|
14
|
+
{value === 100 && <SuccessCircleIcon color="success" data-icon="complete" />}
|
|
15
|
+
<Typography variant="body2" sx={{ color: 'text.secondary', ml: 1 }}>{`${Math.round(value)}%`}</Typography>
|
|
16
|
+
</Stack>
|
|
17
|
+
);
|
|
18
|
+
};
|