@patternfly/react-core 4.248.0 → 4.249.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 +11 -0
- package/dist/esm/components/Icon/Icon.d.ts +25 -0
- package/dist/esm/components/Icon/Icon.d.ts.map +1 -0
- package/dist/esm/components/Icon/Icon.js +14 -0
- package/dist/esm/components/Icon/Icon.js.map +1 -0
- package/dist/esm/components/Icon/index.d.ts +2 -0
- package/dist/esm/components/Icon/index.d.ts.map +1 -0
- package/dist/esm/components/Icon/index.js +2 -0
- package/dist/esm/components/Icon/index.js.map +1 -0
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/js/components/Icon/Icon.d.ts +25 -0
- package/dist/js/components/Icon/Icon.d.ts.map +1 -0
- package/dist/js/components/Icon/Icon.js +18 -0
- package/dist/js/components/Icon/Icon.js.map +1 -0
- package/dist/js/components/Icon/index.d.ts +2 -0
- package/dist/js/components/Icon/index.d.ts.map +1 -0
- package/dist/js/components/Icon/index.js +5 -0
- package/dist/js/components/Icon/index.js.map +1 -0
- package/dist/js/components/index.d.ts +1 -0
- package/dist/js/components/index.d.ts.map +1 -1
- package/dist/js/components/index.js +1 -0
- package/dist/js/components/index.js.map +1 -1
- package/dist/umd/react-core.min.css +865 -728
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +2 -2
- package/src/components/Icon/Icon.tsx +66 -0
- package/src/components/Icon/__tests__/Icon.test.tsx +196 -0
- package/src/components/Icon/__tests__/__snapshots__/Icon.test.tsx.snap +82 -0
- package/src/components/Icon/examples/Icon.md +61 -0
- package/src/components/Icon/examples/IconBasic.tsx +23 -0
- package/src/components/Icon/examples/IconContentSizes.tsx +20 -0
- package/src/components/Icon/examples/IconCustomProgress.tsx +24 -0
- package/src/components/Icon/examples/IconInline.tsx +62 -0
- package/src/components/Icon/examples/IconProgress.tsx +24 -0
- package/src/components/Icon/examples/IconSizes.tsx +20 -0
- package/src/components/Icon/examples/IconStatus.tsx +27 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.249.0",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^16.8 || ^17 || ^18",
|
|
71
71
|
"react-dom": "^16.8 || ^17 || ^18"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "af40c12e9dc55ed508ebc5e07415ec93d61bd639"
|
|
74
74
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from '@patternfly/react-styles/css/components/Icon/icon';
|
|
3
|
+
import { css } from '@patternfly/react-styles';
|
|
4
|
+
import { Spinner } from '../Spinner';
|
|
5
|
+
|
|
6
|
+
export interface IconComponentProps extends Omit<React.HTMLProps<HTMLSpanElement>, 'size'> {
|
|
7
|
+
/** Icon content */
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
/** Icon when isInProgress is set to true. Defaults to a 1em spinner. */
|
|
10
|
+
progressIcon?: React.ReactNode;
|
|
11
|
+
/** Additional classes applied to the icon container */
|
|
12
|
+
className?: string;
|
|
13
|
+
/** Size of the icon component container and icon. */
|
|
14
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
15
|
+
/** Size of icon. Overrides the icon size set by the size property. */
|
|
16
|
+
iconSize?: 'sm' | 'md' | 'lg' | 'xl';
|
|
17
|
+
/** Size of progress icon. Overrides the icon size set by the size property. */
|
|
18
|
+
progressIconSize?: 'sm' | 'md' | 'lg' | 'xl';
|
|
19
|
+
/** Status color of the icon */
|
|
20
|
+
status?: 'default' | 'info' | 'success' | 'warning' | 'danger';
|
|
21
|
+
/** Indicates the icon is inline and should inherit the text font size and color. Overriden by size and iconSize properties. */
|
|
22
|
+
isInline?: boolean;
|
|
23
|
+
/** Indicates the icon is in progress. Setting this property to true will swap the icon with the progressIcon. */
|
|
24
|
+
isInProgress?: boolean;
|
|
25
|
+
/** Aria-label for the default progress icon */
|
|
26
|
+
defaultProgressArialabel?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Icon: React.FunctionComponent<IconComponentProps> = ({
|
|
30
|
+
children,
|
|
31
|
+
className,
|
|
32
|
+
progressIcon,
|
|
33
|
+
size,
|
|
34
|
+
iconSize,
|
|
35
|
+
progressIconSize,
|
|
36
|
+
status,
|
|
37
|
+
isInline = false,
|
|
38
|
+
isInProgress = false,
|
|
39
|
+
defaultProgressArialabel = 'Loading...',
|
|
40
|
+
...props
|
|
41
|
+
}: IconComponentProps) => {
|
|
42
|
+
const _progressIcon = progressIcon ? (
|
|
43
|
+
progressIcon
|
|
44
|
+
) : (
|
|
45
|
+
<Spinner diameter="1em" isSVG aria-label={defaultProgressArialabel} />
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<span
|
|
50
|
+
className={css(
|
|
51
|
+
styles.icon,
|
|
52
|
+
isInline && styles.modifiers.inline,
|
|
53
|
+
isInProgress && styles.modifiers.inProgress,
|
|
54
|
+
styles.modifiers[size],
|
|
55
|
+
className
|
|
56
|
+
)}
|
|
57
|
+
{...props}
|
|
58
|
+
>
|
|
59
|
+
<span className={css(styles.iconContent, styles.modifiers[iconSize], styles.modifiers[status])}>{children}</span>
|
|
60
|
+
{isInProgress && (
|
|
61
|
+
<span className={css(styles.iconProgress, styles.modifiers[progressIconSize], className)}>{_progressIcon}</span>
|
|
62
|
+
)}
|
|
63
|
+
</span>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
Icon.displayName = 'Icon';
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { Icon } from '../Icon';
|
|
4
|
+
import { CheckIcon } from '@patternfly/react-icons';
|
|
5
|
+
|
|
6
|
+
test('renders basic icon successfully', () => {
|
|
7
|
+
const { asFragment } = render(
|
|
8
|
+
<Icon>
|
|
9
|
+
<CheckIcon />
|
|
10
|
+
</Icon>
|
|
11
|
+
);
|
|
12
|
+
expect(asFragment()).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('checks basic icon structure', () => {
|
|
16
|
+
const { asFragment } = render(
|
|
17
|
+
<Icon title="icon">
|
|
18
|
+
<CheckIcon />
|
|
19
|
+
</Icon>
|
|
20
|
+
);
|
|
21
|
+
const iconContainer = screen.getByTitle('icon');
|
|
22
|
+
expect(iconContainer).toHaveClass('pf-c-icon');
|
|
23
|
+
const iconContent = iconContainer.querySelector('.pf-c-icon__content');
|
|
24
|
+
expect(iconContent).toHaveClass('pf-c-icon__content');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('renders without children', () => {
|
|
28
|
+
const { asFragment } = render(<Icon></Icon>);
|
|
29
|
+
expect(asFragment()).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('sets additional custom class successfully', () => {
|
|
33
|
+
render(
|
|
34
|
+
<Icon className="test" title="custom-icon">
|
|
35
|
+
<CheckIcon />
|
|
36
|
+
</Icon>
|
|
37
|
+
);
|
|
38
|
+
const iconContainer = screen.getByTitle('custom-icon');
|
|
39
|
+
|
|
40
|
+
expect(iconContainer).toHaveClass('test');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
Object.values(['sm', 'md', 'lg', 'xl']).forEach(size => {
|
|
44
|
+
test(`sets icon size modifier successfully - ${size}`, () => {
|
|
45
|
+
render(
|
|
46
|
+
<Icon iconSize={size as 'sm' | 'md' | 'lg' | 'xl'} title={`content-${size}-icon`}>
|
|
47
|
+
<CheckIcon />
|
|
48
|
+
</Icon>
|
|
49
|
+
);
|
|
50
|
+
const iconContainer = screen.getByTitle(`content-${size}-icon`).querySelector('.pf-c-icon__content');
|
|
51
|
+
|
|
52
|
+
expect(iconContainer).toHaveClass(`pf-m-${size}`);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('check icon without iconSize', () => {
|
|
57
|
+
render(
|
|
58
|
+
<Icon title="no-icon-size">
|
|
59
|
+
<CheckIcon />
|
|
60
|
+
</Icon>
|
|
61
|
+
);
|
|
62
|
+
const iconContainer = screen.getByTitle('no-icon-size').querySelector('.pf-c-icon__content');
|
|
63
|
+
expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
Object.values(['sm', 'md', 'lg', 'xl']).forEach(size => {
|
|
67
|
+
test(`sets progress icon size modifier successfully - ${size}`, () => {
|
|
68
|
+
render(
|
|
69
|
+
<Icon isInProgress progressIconSize={size as 'sm' | 'md' | 'lg' | 'xl'} title={`progress-content-${size}-icon`}>
|
|
70
|
+
<CheckIcon />
|
|
71
|
+
</Icon>
|
|
72
|
+
);
|
|
73
|
+
const iconContainer = screen.getByTitle(`progress-content-${size}-icon`).querySelector('.pf-c-icon__progress');
|
|
74
|
+
|
|
75
|
+
expect(iconContainer).toHaveClass(`pf-m-${size}`);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('check icon without progress icon size', () => {
|
|
80
|
+
render(
|
|
81
|
+
<Icon title="no-progress-icon-size">
|
|
82
|
+
<CheckIcon />
|
|
83
|
+
</Icon>
|
|
84
|
+
);
|
|
85
|
+
const iconContainer = screen.getByTitle('no-progress-icon-size').querySelector('.pf-c-icon__progress');
|
|
86
|
+
expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
Object.values(['sm', 'md', 'lg', 'xl']).forEach(size => {
|
|
90
|
+
test(`sets size modifier successfully - ${size}`, () => {
|
|
91
|
+
render(
|
|
92
|
+
<Icon size={size as 'sm' | 'md' | 'lg' | 'xl'} title={`${size}-icon`}>
|
|
93
|
+
<CheckIcon />
|
|
94
|
+
</Icon>
|
|
95
|
+
);
|
|
96
|
+
const iconContainer = screen.getByTitle(`${size}-icon`);
|
|
97
|
+
|
|
98
|
+
expect(iconContainer).toHaveClass(`pf-m-${size}`);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('check icon without size', () => {
|
|
103
|
+
render(
|
|
104
|
+
<Icon title="no-size">
|
|
105
|
+
<CheckIcon />
|
|
106
|
+
</Icon>
|
|
107
|
+
);
|
|
108
|
+
const iconContainer = screen.getByTitle('no-size');
|
|
109
|
+
expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
Object.values(['default', 'info', 'success', 'warning', 'danger']).forEach(status => {
|
|
113
|
+
test(`sets status modifier successfully - ${status}`, () => {
|
|
114
|
+
render(
|
|
115
|
+
<Icon status={status as 'default' | 'info' | 'success' | 'warning' | 'danger'} title={`${status}-icon`}>
|
|
116
|
+
<CheckIcon />
|
|
117
|
+
</Icon>
|
|
118
|
+
);
|
|
119
|
+
const iconContent = screen.getByTitle(`${status}-icon`).querySelector('.pf-c-icon__content');
|
|
120
|
+
|
|
121
|
+
expect(iconContent).toHaveClass(`pf-m-${status}`);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('check icon without status', () => {
|
|
126
|
+
render(
|
|
127
|
+
<Icon title="no-status">
|
|
128
|
+
<CheckIcon />
|
|
129
|
+
</Icon>
|
|
130
|
+
);
|
|
131
|
+
const iconContent = screen.getByTitle('no-status').querySelector('.pf-c-icon__content');
|
|
132
|
+
expect(Array.from(iconContent?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('sets isInline successfully', () => {
|
|
136
|
+
render(
|
|
137
|
+
<Icon isInline title="inline-icon">
|
|
138
|
+
<CheckIcon />
|
|
139
|
+
</Icon>
|
|
140
|
+
);
|
|
141
|
+
const iconContainer = screen.getByTitle('inline-icon');
|
|
142
|
+
|
|
143
|
+
expect(iconContainer).toHaveClass('pf-m-inline');
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test('check icon without isInline', () => {
|
|
147
|
+
render(
|
|
148
|
+
<Icon title="no-inline">
|
|
149
|
+
<CheckIcon />
|
|
150
|
+
</Icon>
|
|
151
|
+
);
|
|
152
|
+
const iconContainer = screen.getByTitle('no-inline');
|
|
153
|
+
expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('sets isInProgress successfully', () => {
|
|
157
|
+
render(
|
|
158
|
+
<Icon isInProgress title="progress-icon">
|
|
159
|
+
<CheckIcon />
|
|
160
|
+
</Icon>
|
|
161
|
+
);
|
|
162
|
+
const iconContainer = screen.getByTitle('progress-icon');
|
|
163
|
+
expect(iconContainer).toHaveClass('pf-m-in-progress');
|
|
164
|
+
|
|
165
|
+
const iconContent = iconContainer.querySelector('.pf-c-icon__progress');
|
|
166
|
+
expect(iconContent).toHaveClass('pf-c-icon__progress');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('check icon without isInProgress', () => {
|
|
170
|
+
render(
|
|
171
|
+
<Icon title="no-in-progress">
|
|
172
|
+
<CheckIcon />
|
|
173
|
+
</Icon>
|
|
174
|
+
);
|
|
175
|
+
const iconContainer = screen.getByTitle('no-in-progress');
|
|
176
|
+
expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('sets default progres aria-label successfully', () => {
|
|
180
|
+
render(
|
|
181
|
+
<Icon isInProgress defaultProgressArialabel="test" title="progress-icon">
|
|
182
|
+
<CheckIcon />
|
|
183
|
+
</Icon>
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
expect(screen.getByLabelText('test'));
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test('renders progress icon successfully', () => {
|
|
190
|
+
const { asFragment } = render(
|
|
191
|
+
<Icon isInProgress progressIcon={<CheckIcon />}>
|
|
192
|
+
<CheckIcon />
|
|
193
|
+
</Icon>
|
|
194
|
+
);
|
|
195
|
+
expect(asFragment()).toMatchSnapshot();
|
|
196
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`renders basic icon successfully 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<span
|
|
6
|
+
class="pf-c-icon"
|
|
7
|
+
>
|
|
8
|
+
<span
|
|
9
|
+
class="pf-c-icon__content"
|
|
10
|
+
>
|
|
11
|
+
<svg
|
|
12
|
+
aria-hidden="true"
|
|
13
|
+
fill="currentColor"
|
|
14
|
+
height="1em"
|
|
15
|
+
role="img"
|
|
16
|
+
style="vertical-align: -0.125em;"
|
|
17
|
+
viewBox="0 0 512 512"
|
|
18
|
+
width="1em"
|
|
19
|
+
>
|
|
20
|
+
<path
|
|
21
|
+
d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"
|
|
22
|
+
/>
|
|
23
|
+
</svg>
|
|
24
|
+
</span>
|
|
25
|
+
</span>
|
|
26
|
+
</DocumentFragment>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`renders progress icon successfully 1`] = `
|
|
30
|
+
<DocumentFragment>
|
|
31
|
+
<span
|
|
32
|
+
class="pf-c-icon pf-m-in-progress"
|
|
33
|
+
>
|
|
34
|
+
<span
|
|
35
|
+
class="pf-c-icon__content"
|
|
36
|
+
>
|
|
37
|
+
<svg
|
|
38
|
+
aria-hidden="true"
|
|
39
|
+
fill="currentColor"
|
|
40
|
+
height="1em"
|
|
41
|
+
role="img"
|
|
42
|
+
style="vertical-align: -0.125em;"
|
|
43
|
+
viewBox="0 0 512 512"
|
|
44
|
+
width="1em"
|
|
45
|
+
>
|
|
46
|
+
<path
|
|
47
|
+
d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"
|
|
48
|
+
/>
|
|
49
|
+
</svg>
|
|
50
|
+
</span>
|
|
51
|
+
<span
|
|
52
|
+
class="pf-c-icon__progress"
|
|
53
|
+
>
|
|
54
|
+
<svg
|
|
55
|
+
aria-hidden="true"
|
|
56
|
+
fill="currentColor"
|
|
57
|
+
height="1em"
|
|
58
|
+
role="img"
|
|
59
|
+
style="vertical-align: -0.125em;"
|
|
60
|
+
viewBox="0 0 512 512"
|
|
61
|
+
width="1em"
|
|
62
|
+
>
|
|
63
|
+
<path
|
|
64
|
+
d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"
|
|
65
|
+
/>
|
|
66
|
+
</svg>
|
|
67
|
+
</span>
|
|
68
|
+
</span>
|
|
69
|
+
</DocumentFragment>
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
exports[`renders without children 1`] = `
|
|
73
|
+
<DocumentFragment>
|
|
74
|
+
<span
|
|
75
|
+
class="pf-c-icon"
|
|
76
|
+
>
|
|
77
|
+
<span
|
|
78
|
+
class="pf-c-icon__content"
|
|
79
|
+
/>
|
|
80
|
+
</span>
|
|
81
|
+
</DocumentFragment>
|
|
82
|
+
`;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Icon
|
|
3
|
+
section: components
|
|
4
|
+
cssPrefix: pf-c-icon
|
|
5
|
+
propComponents: ['Icon']
|
|
6
|
+
beta: true
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
import LongArrowAltDownIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-down-icon';
|
|
10
|
+
import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
|
|
11
|
+
import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
|
|
12
|
+
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
13
|
+
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
14
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
15
|
+
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
|
|
16
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
17
|
+
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
|
|
18
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### Basic
|
|
23
|
+
|
|
24
|
+
```ts file="IconBasic.tsx"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Sizes
|
|
28
|
+
|
|
29
|
+
```ts file="IconSizes.tsx"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Status colors
|
|
33
|
+
|
|
34
|
+
The following example demonstrates the various status variants of an icon. Keep in mind that these icons are displayed out of a typical context, and that you should not rely on color alone to convey status to users.
|
|
35
|
+
|
|
36
|
+
```ts file="IconStatus.tsx"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Sizing an icon within the icon container
|
|
40
|
+
|
|
41
|
+
Providing both size and iconSize properties allows the icon container to maintain a consistent size, even if the icon changes in size.
|
|
42
|
+
|
|
43
|
+
```ts file="IconContentSizes.tsx"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Inline
|
|
47
|
+
|
|
48
|
+
```ts file="IconInline.tsx"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### In progress
|
|
52
|
+
|
|
53
|
+
Passing the `isInProgress` property will swap the icon to a progress icon. By default this progress icon will be a `Spinner` but may be customized or overriden using the `progressIcon` property.
|
|
54
|
+
|
|
55
|
+
```ts file="IconProgress.tsx"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Custom in progress icon
|
|
59
|
+
|
|
60
|
+
```ts file="IconCustomProgress.tsx"
|
|
61
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon } from '@patternfly/react-core';
|
|
3
|
+
import LongArrowAltDownIcon from '@patternfly/react-icons/dist/esm/icons/long-arrow-alt-down-icon';
|
|
4
|
+
import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
|
|
5
|
+
import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
|
|
6
|
+
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
7
|
+
|
|
8
|
+
export const IconBasic: React.FunctionComponent = () => (
|
|
9
|
+
<React.Fragment>
|
|
10
|
+
<Icon>
|
|
11
|
+
<LongArrowAltDownIcon />
|
|
12
|
+
</Icon>
|
|
13
|
+
<Icon>
|
|
14
|
+
<AngleRightIcon />
|
|
15
|
+
</Icon>
|
|
16
|
+
<Icon>
|
|
17
|
+
<AngleDownIcon />
|
|
18
|
+
</Icon>
|
|
19
|
+
<Icon>
|
|
20
|
+
<CogIcon />
|
|
21
|
+
</Icon>
|
|
22
|
+
</React.Fragment>
|
|
23
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon } from '@patternfly/react-core';
|
|
3
|
+
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
4
|
+
|
|
5
|
+
export const IconContentSizes: React.FunctionComponent = () => (
|
|
6
|
+
<React.Fragment>
|
|
7
|
+
<Icon size="xl" iconSize="sm">
|
|
8
|
+
<PlusCircleIcon />
|
|
9
|
+
</Icon>
|
|
10
|
+
<Icon size="xl" iconSize="md">
|
|
11
|
+
<PlusCircleIcon />
|
|
12
|
+
</Icon>
|
|
13
|
+
<Icon size="xl" iconSize="lg">
|
|
14
|
+
<PlusCircleIcon />
|
|
15
|
+
</Icon>
|
|
16
|
+
<Icon size="xl">
|
|
17
|
+
<PlusCircleIcon />
|
|
18
|
+
</Icon>
|
|
19
|
+
</React.Fragment>
|
|
20
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon, Spinner, Checkbox } from '@patternfly/react-core';
|
|
3
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
4
|
+
|
|
5
|
+
export const IconProgress: React.FunctionComponent = () => {
|
|
6
|
+
const [isInProgress, setIsInProgress] = React.useState<boolean>(false);
|
|
7
|
+
return (
|
|
8
|
+
<React.Fragment>
|
|
9
|
+
<div style={{ marginBottom: '12px' }}>
|
|
10
|
+
<Checkbox
|
|
11
|
+
label="Toggle in progress state"
|
|
12
|
+
isChecked={isInProgress}
|
|
13
|
+
onChange={checked => setIsInProgress(checked)}
|
|
14
|
+
aria-label="Set icon progress state"
|
|
15
|
+
id="toggle-icon-progress-custom"
|
|
16
|
+
name="toggle-icon-progress-custom"
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
<Icon isInProgress={isInProgress} progressIcon={<Spinner diameter="2em" isSVG aria-label="Loading..." />}>
|
|
20
|
+
<CheckCircleIcon />
|
|
21
|
+
</Icon>
|
|
22
|
+
</React.Fragment>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon, Text, TextContent } from '@patternfly/react-core';
|
|
3
|
+
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
4
|
+
|
|
5
|
+
export const IconInline: React.FunctionComponent = () => (
|
|
6
|
+
<React.Fragment>
|
|
7
|
+
<TextContent>
|
|
8
|
+
<Text component="h1">
|
|
9
|
+
Heading
|
|
10
|
+
<Icon isInline>
|
|
11
|
+
<PlusCircleIcon />
|
|
12
|
+
</Icon>
|
|
13
|
+
</Text>
|
|
14
|
+
<Text component="p">
|
|
15
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit Sed hendrerit nisi in cursus maximus.
|
|
16
|
+
</Text>
|
|
17
|
+
<Text component="h2">
|
|
18
|
+
Second level
|
|
19
|
+
<Icon isInline>
|
|
20
|
+
<PlusCircleIcon />
|
|
21
|
+
</Icon>
|
|
22
|
+
</Text>
|
|
23
|
+
<Text component="p">
|
|
24
|
+
<Icon isInline>
|
|
25
|
+
<PlusCircleIcon />
|
|
26
|
+
</Icon>
|
|
27
|
+
Curabitur accumsan turpis pharetra
|
|
28
|
+
<strong>
|
|
29
|
+
augue tincidunt
|
|
30
|
+
<Icon isInline>
|
|
31
|
+
<PlusCircleIcon />
|
|
32
|
+
</Icon>
|
|
33
|
+
</strong>
|
|
34
|
+
blandit. Quisque condimentum maximus mi, sit amet commodo arcu rutrum id. Proin pretium urna vel cursus
|
|
35
|
+
venenatis. Suspendisse potenti.
|
|
36
|
+
</Text>
|
|
37
|
+
<small>
|
|
38
|
+
Sometimes you need small text
|
|
39
|
+
<Icon isInline>
|
|
40
|
+
<PlusCircleIcon />
|
|
41
|
+
</Icon>
|
|
42
|
+
</small>
|
|
43
|
+
Inline with size specified:
|
|
44
|
+
<Icon size="sm" isInline>
|
|
45
|
+
<PlusCircleIcon />
|
|
46
|
+
</Icon>
|
|
47
|
+
small,
|
|
48
|
+
<Icon size="md" isInline>
|
|
49
|
+
<PlusCircleIcon />
|
|
50
|
+
</Icon>
|
|
51
|
+
medium,
|
|
52
|
+
<Icon size="lg" isInline>
|
|
53
|
+
<PlusCircleIcon />
|
|
54
|
+
</Icon>
|
|
55
|
+
large,
|
|
56
|
+
<Icon size="xl" isInline>
|
|
57
|
+
<PlusCircleIcon />
|
|
58
|
+
</Icon>
|
|
59
|
+
extra large
|
|
60
|
+
</TextContent>
|
|
61
|
+
</React.Fragment>
|
|
62
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon, Checkbox } from '@patternfly/react-core';
|
|
3
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
4
|
+
|
|
5
|
+
export const IconProgress: React.FunctionComponent = () => {
|
|
6
|
+
const [isInProgress, setIsInProgress] = React.useState<boolean>(false);
|
|
7
|
+
return (
|
|
8
|
+
<React.Fragment>
|
|
9
|
+
<div style={{ marginBottom: '12px' }}>
|
|
10
|
+
<Checkbox
|
|
11
|
+
label="Toggle in progress state"
|
|
12
|
+
isChecked={isInProgress}
|
|
13
|
+
onChange={checked => setIsInProgress(checked)}
|
|
14
|
+
aria-label="Set icon progress state"
|
|
15
|
+
id="toggle-icon-progress"
|
|
16
|
+
name="toggle-icon-progress"
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
<Icon isInProgress={isInProgress}>
|
|
20
|
+
<CheckCircleIcon />
|
|
21
|
+
</Icon>
|
|
22
|
+
</React.Fragment>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon } from '@patternfly/react-core';
|
|
3
|
+
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
4
|
+
|
|
5
|
+
export const IconSizes: React.FunctionComponent = () => (
|
|
6
|
+
<React.Fragment>
|
|
7
|
+
<Icon size="sm">
|
|
8
|
+
<PlusCircleIcon />
|
|
9
|
+
</Icon>
|
|
10
|
+
<Icon size="md">
|
|
11
|
+
<PlusCircleIcon />
|
|
12
|
+
</Icon>
|
|
13
|
+
<Icon size="lg">
|
|
14
|
+
<PlusCircleIcon />
|
|
15
|
+
</Icon>
|
|
16
|
+
<Icon size="xl">
|
|
17
|
+
<PlusCircleIcon />
|
|
18
|
+
</Icon>
|
|
19
|
+
</React.Fragment>
|
|
20
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon } from '@patternfly/react-core';
|
|
3
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
4
|
+
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
|
|
5
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
6
|
+
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
|
|
7
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
8
|
+
|
|
9
|
+
export const IconStatus: React.FunctionComponent = () => (
|
|
10
|
+
<React.Fragment>
|
|
11
|
+
<Icon status="danger">
|
|
12
|
+
<ExclamationCircleIcon />
|
|
13
|
+
</Icon>
|
|
14
|
+
<Icon status="warning">
|
|
15
|
+
<ExclamationTriangleIcon />
|
|
16
|
+
</Icon>
|
|
17
|
+
<Icon status="success">
|
|
18
|
+
<CheckCircleIcon />
|
|
19
|
+
</Icon>
|
|
20
|
+
<Icon status="info">
|
|
21
|
+
<InfoCircleIcon />
|
|
22
|
+
</Icon>
|
|
23
|
+
<Icon status="default">
|
|
24
|
+
<BellIcon />
|
|
25
|
+
</Icon>
|
|
26
|
+
</React.Fragment>
|
|
27
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Icon';
|
package/src/components/index.ts
CHANGED