Skip to content

Commit 51fc8dc

Browse files
fix(rtl-demo): update paginated table demo layout and status labels (#12491)
- Remove Card wrapper so toolbar and table render directly on the page - Switch status labels from color variants to semantic LabelStatus props - Fix button and label icons to use pf-v6-m-mirror-inline-rtl directly, removing the Icon wrapper that was overriding on-brand icon color tokens Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0cd3a4d commit 51fc8dc

1 file changed

Lines changed: 50 additions & 72 deletions

File tree

packages/react-core/src/demos/RTL/examples/PaginatedTable.tsx

Lines changed: 50 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ import {
66
BreadcrumbItem,
77
Button,
88
ButtonVariant,
9-
Card,
109
Content,
1110
Divider,
1211
Dropdown,
1312
DropdownGroup,
1413
DropdownItem,
1514
DropdownList,
16-
Icon,
1715
Label,
18-
LabelColor,
16+
LabelStatus,
1917
Masthead,
2018
MastheadMain,
2119
MastheadLogo,
@@ -48,11 +46,11 @@ import AlignRightIcon from '@patternfly/react-icons/dist/esm/icons/align-right-i
4846
import ToolsIcon from '@patternfly/react-icons/dist/esm/icons/tools-icon';
4947
import RhUiRunningIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-running-icon';
5048
import RhUiClockFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-clock-fill-icon';
49+
import RhUiStopCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-stop-circle-fill-icon';
5150
import pfLogo from '@patternfly/react-core/src/demos/assets/pf-logo.svg';
5251
import RhUiSettingsFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-settings-fill-icon';
5352
import RhUiQuestionMarkCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-question-mark-circle-fill-icon';
5453
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
55-
import RhUiStopCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-stop-circle-fill-icon';
5654
import RhUiEllipsisVerticalFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ellipsis-vertical-fill-icon';
5755
import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg';
5856
import { rows } from '@patternfly/react-core/dist/esm/demos/sampleDataRTL';
@@ -180,42 +178,28 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
180178
case 'Running':
181179
case 'רץ':
182180
return (
183-
<Label
184-
color={LabelColor.green}
185-
icon={
186-
<Icon shouldMirrorRTL>
187-
<RhUiRunningIcon />
188-
</Icon>
189-
}
190-
>
181+
<Label status={LabelStatus.success} icon={<RhUiRunningIcon className="pf-v6-m-mirror-inline-rtl" />}>
191182
{translation.table.rows.status.running}
192183
</Label>
193184
);
194185
case 'Stopped':
195186
case 'עצר':
196187
return (
197-
<Label
198-
icon={
199-
<Icon shouldMirrorRTL>
200-
<RhUiStopCircleFillIcon />
201-
</Icon>
202-
}
203-
color={LabelColor.red}
204-
>
188+
<Label status={LabelStatus.danger} icon={<RhUiStopCircleFillIcon className="pf-v6-m-mirror-inline-rtl" />}>
205189
{translation.table.rows.status.stopped}
206190
</Label>
207191
);
208192
case 'Needs maintenance':
209193
case 'זקוק לתחזוקה':
210194
return (
211-
<Label icon={<ToolsIcon />} color={LabelColor.blue}>
195+
<Label status={LabelStatus.info} icon={<ToolsIcon />}>
212196
{translation.table.rows.status.needsMaintenance}
213197
</Label>
214198
);
215199
case 'Down':
216200
case 'מטה':
217201
return (
218-
<Label icon={<RhUiClockFillIcon />} color={LabelColor.orange}>
202+
<Label status={LabelStatus.warning} icon={<RhUiClockFillIcon />}>
219203
{translation.table.rows.status.down}
220204
</Label>
221205
);
@@ -229,11 +213,7 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
229213
<ToolbarItem>
230214
<Button
231215
variant="primary"
232-
icon={
233-
<Icon shouldMirrorRTL>
234-
<AlignRightIcon />
235-
</Icon>
236-
}
216+
icon={<AlignRightIcon className="pf-v6-m-mirror-inline-rtl" />}
237217
iconPosition="end"
238218
onClick={switchTranslation}
239219
>
@@ -443,52 +423,50 @@ export const PaginatedTableAction: React.FunctionComponent = () => {
443423
</Content>
444424
</PageSection>
445425
<PageSection>
446-
<Card>
447-
{toolbarItems}
448-
<Table variant="compact" aria-label={translation.table.ariaLabel}>
449-
<Thead>
450-
<Tr>
451-
{columns.map((column, columnIndex) => (
452-
<Th key={columnIndex}>{column}</Th>
453-
))}
454-
</Tr>
455-
</Thead>
456-
<Tbody>
457-
{paginatedRows.map((row: Row, rowIndex: number) => (
458-
<Tr key={rowIndex}>
459-
<>
460-
{Object.entries(row).map(([key, value]) => {
461-
if (key === 'status') {
462-
return (
463-
<Td key={key} width={15} dataLabel="Status">
464-
{renderLabel(value)}
465-
</Td>
466-
);
467-
} else if (key === 'url') {
468-
return (
469-
// Passing dir="rtl" forces truncation at the start of the URL,
470-
// resulting in the unique portion being visible regardless of language
471-
<Td key={key} dataLabel="URL" width={15}>
472-
<a href="#">
473-
<Truncate content={row.url} position={isDirRTL ? 'end' : 'start'} />
474-
</a>
475-
</Td>
476-
);
477-
} else {
478-
return (
479-
<Td key={key} dataLabel={key === 'lastModified' ? 'Last modified' : capitalize(key)}>
480-
{value}
481-
</Td>
482-
);
483-
}
484-
})}
485-
</>
486-
</Tr>
426+
{toolbarItems}
427+
<Table variant="compact" aria-label={translation.table.ariaLabel}>
428+
<Thead>
429+
<Tr>
430+
{columns.map((column, columnIndex) => (
431+
<Th key={columnIndex}>{column}</Th>
487432
))}
488-
</Tbody>
489-
</Table>
490-
{renderPagination(PaginationVariant.bottom)}
491-
</Card>
433+
</Tr>
434+
</Thead>
435+
<Tbody>
436+
{paginatedRows.map((row: Row, rowIndex: number) => (
437+
<Tr key={rowIndex}>
438+
<>
439+
{Object.entries(row).map(([key, value]) => {
440+
if (key === 'status') {
441+
return (
442+
<Td key={key} width={15} dataLabel="Status">
443+
{renderLabel(value)}
444+
</Td>
445+
);
446+
} else if (key === 'url') {
447+
return (
448+
// Passing dir="rtl" forces truncation at the start of the URL,
449+
// resulting in the unique portion being visible regardless of language
450+
<Td key={key} dataLabel="URL" width={15}>
451+
<a href="#">
452+
<Truncate content={row.url} position={isDirRTL ? 'end' : 'start'} />
453+
</a>
454+
</Td>
455+
);
456+
} else {
457+
return (
458+
<Td key={key} dataLabel={key === 'lastModified' ? 'Last modified' : capitalize(key)}>
459+
{value}
460+
</Td>
461+
);
462+
}
463+
})}
464+
</>
465+
</Tr>
466+
))}
467+
</Tbody>
468+
</Table>
469+
{renderPagination(PaginationVariant.bottom)}
492470
</PageSection>
493471
</Page>
494472
</Fragment>

0 commit comments

Comments
 (0)