Skip to content

Commit c030c2b

Browse files
authored
feat(statusicon): add Paused status type to StatusIcon (#53)
1 parent a3cae11 commit c030c2b

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/components/StatusIcon/StatusIcon.stories.mdx

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ WarningTriangleIcon and ExclamationCircleIcon that automatically sets the right
2525
<br />
2626
<StatusIcon status="Loading" />
2727
<br />
28+
<StatusIcon status="Paused" />
29+
<br />
2830
<StatusIcon status="Unknown" />
2931
</Story>
3032
</Canvas>
@@ -43,6 +45,8 @@ WarningTriangleIcon and ExclamationCircleIcon that automatically sets the right
4345
<br />
4446
<StatusIcon status="Loading" isDisabled />
4547
<br />
48+
<StatusIcon status="Paused" isDisabled />
49+
<br />
4650
<StatusIcon status="Unknown" isDisabled />
4751
</Story>
4852
</Canvas>
@@ -56,6 +60,7 @@ WarningTriangleIcon and ExclamationCircleIcon that automatically sets the right
5660
<StatusIcon status="Error" label="Error" />
5761
<StatusIcon status="Info" label="Info" />
5862
<StatusIcon status="Loading" label="Loading" />
63+
<StatusIcon status="Paused" label="Paused" />
5964
<StatusIcon status="Unknown" label="Unknown" />
6065
</Story>
6166
</Canvas>

src/components/StatusIcon/StatusIcon.test.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ describe('StatusIcon', () => {
9999
});
100100
});
101101

102+
describe('Paused status', () => {
103+
it('should have label if present', () => {
104+
checkText({ status: 'Paused', label: 'Paused' }, 'Paused');
105+
});
106+
it('should have correct color', () => {
107+
checkColor({ status: 'Paused' }, '#151515');
108+
});
109+
it('should have disabled color if disabled', () => {
110+
checkColor({ status: 'Paused', isDisabled: true }, disabledColor.value);
111+
});
112+
it('should pass down a given className', () => {
113+
checkClass({ status: 'Paused', className: 'foo' }, 'foo', 'svg');
114+
});
115+
});
116+
102117
describe('Unknown status', () => {
103118
it('should have label if present', () => {
104119
checkText({ status: 'Unknown', label: 'Unknown' }, 'Unknown');

src/components/StatusIcon/StatusIcon.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ExclamationCircleIcon,
77
InfoCircleIcon,
88
QuestionCircleIcon,
9+
PauseCircleIcon,
910
} from '@patternfly/react-icons';
1011
import { SVGIconProps } from '@patternfly/react-icons/dist/js/createIcon';
1112
import {
@@ -20,12 +21,12 @@ import {
2021

2122
import './StatusIcon.css';
2223

23-
export type StatusType = 'Ok' | 'Warning' | 'Error' | 'Info' | 'Loading' | 'Unknown';
24+
export type StatusType = 'Ok' | 'Warning' | 'Error' | 'Info' | 'Loading' | 'Paused' | 'Unknown';
2425

2526
type IconListType = {
2627
[key in StatusType]: {
2728
Icon: React.ComponentClass<SVGIconProps> | React.FunctionComponent<SpinnerProps>;
28-
color: { name: string; value: string; var: string };
29+
color?: { name: string; value: string; var: string };
2930
};
3031
};
3132
const iconList: IconListType = {
@@ -49,6 +50,9 @@ const iconList: IconListType = {
4950
Icon: Spinner,
5051
color: loadingColor,
5152
},
53+
Paused: {
54+
Icon: PauseCircleIcon,
55+
},
5256
Unknown: {
5357
Icon: QuestionCircleIcon,
5458
color: unknownColor,
@@ -71,7 +75,7 @@ export const StatusIcon: React.FunctionComponent<IStatusIconProps> = ({
7175
const Icon = iconList[status].Icon;
7276
const icon = (
7377
<Icon
74-
color={isDisabled ? disabledColor.value : iconList[status].color.value}
78+
color={isDisabled ? disabledColor.value : iconList[status].color?.value || '#151515'} // TODO use --pf-global--Color--100 after upgrading PF, for some reason that is resolving to #000 in this version
7579
className={status === 'Loading' ? `${className} status-icon-loading-spinner` : className}
7680
/>
7781
);

0 commit comments

Comments
 (0)