Skip to content

Commit 53b1902

Browse files
authored
statusicon doc (#67)
1 parent 9d38ad3 commit 53b1902

File tree

2 files changed

+57
-13
lines changed

2 files changed

+57
-13
lines changed

src/components/icons/StatusIcon/StatusIcon.md

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,42 @@ Spinning icon
44
<StatusIcon status='Running' spin />
55
```
66

7+
Showcase in a list of virtual machines
8+
9+
```js
10+
import { TableComposable, Caption, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
11+
12+
<TableComposable>
13+
<Caption>Virtual Machines list</Caption>
14+
<Thead>
15+
<Tr>
16+
<Th>Name</Th>
17+
<Th>State</Th>
18+
</Tr>
19+
</Thead>
20+
<Tbody>
21+
<Tr>
22+
<Td>Debian virtual machine</Td>
23+
<Td><StatusIcon status='Paused' /> Paused</Td>
24+
</Tr>
25+
26+
<Tr>
27+
<Td>RHEL virtual machine</Td>
28+
<Td><StatusIcon status='Starting' spin /> Starting</Td>
29+
</Tr>
30+
<Tr>
31+
<Td>CentOS virtual machine</Td>
32+
<Td><StatusIcon status='ErrImagePull' /> Error</Td>
33+
</Tr>
34+
</Tbody>
35+
</TableComposable>
36+
```
737

838
All possible statuses
939

1040
```js
41+
import { TableComposable, Caption, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
42+
1143
const possibleStatuses = {
1244
Stopped: 'Stopped',
1345
Migrating: 'Migrating',
@@ -29,20 +61,22 @@ const possibleStatuses = {
2961
Unknown: 'Unknown',
3062
};
3163

32-
<table className='pf-c-table pf-m-grid-md'>
33-
<thead>
34-
<tr>
35-
<th width='250px'>Printable Status</th>
36-
<th>Icon</th>
37-
</tr>
38-
</thead>
64+
<TableComposable>
65+
<Thead>
66+
<Tr>
67+
<Th>Printable Status</Th>
68+
<Th>Icon</Th>
69+
</Tr>
70+
</Thead>
71+
<Tbody>
3972
{Object.values(possibleStatuses).map(status => (
40-
<tr key={status}>
41-
<td>{status}</td>
42-
<td><StatusIcon status={status} /></td>
43-
</tr>
73+
<Tr key={status}>
74+
<Td>{status}</Td>
75+
<Td><StatusIcon status={status} /></Td>
76+
</Tr>
4477
))}
45-
</table>
78+
</Tbody>
79+
</TableComposable>
4680

4781

4882
```

src/components/icons/StatusIcon/StatusIcon.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const statusLabelHandler = {
104104

105105
export const statusToLabel = new Proxy(
106106
{
107+
...statuses,
107108
[statuses.Terminating]: customStatusLabels.Deleting,
108109
[statuses.Provisioning]: customStatusLabels.Starting,
109110
[statuses.WaitingForVolumeBinding]: customStatusLabels.Starting,
@@ -156,7 +157,16 @@ export type StatusIconProps = {
156157
};
157158

158159
/**
159-
* StatusIcon renders status icons for k8s elements to visualize [resource lifecycle phases](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase)
160+
* StatusIcon renders icons for k8s elements to visualize [resource lifecycle phases](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase).
161+
* It can accomodate statuses of different resourceses like virtual machines, virtual machine instances and in general all the resorces that follow the k8s lifecycle pharses.
162+
*
163+
* All the icons are svg based with *width* and *height* of *1em*. The icon *color* inherit the css container's *color* property, except for the error icons that are only red.
164+
*
165+
* Icons has also a *title* for accessibility depends on the provided status and can be inspected on mouse hover
166+
*
167+
* Please use the spin property to indicate that something is “loading” or in the middle of processing following the PatterFly guidelines.
168+
* Indeed having several elements spinnings and moving in the page can distract the user from important tasks and warnings that need more attentions.
169+
*
160170
*/
161171
export const StatusIcon: React.FC<StatusIconProps> = React.memo(
162172
({ status, 'data-test-id': dataTestId, spin = false }) => {

0 commit comments

Comments
 (0)