Skip to content

Commit 498655c

Browse files
committed
Add custom icon rendering and new horizontal layout
1 parent 25faf8e commit 498655c

File tree

4 files changed

+45
-21
lines changed

4 files changed

+45
-21
lines changed

pages/steps/permutations-utils.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -773,14 +773,9 @@ export const stepsPermutations = createPermutations<StepsProps>([
773773
details: step.details && <i>Custom details for {step.details}</i>,
774774
}),
775775
step => ({
776-
header: <Icon name="status-positive" variant="success" ariaLabel="step status" />,
777-
details: (
778-
<div>
779-
{step.header}
780-
<br />
781-
{step.details && <i>Custom details for {step.details}</i>}
782-
</div>
783-
),
776+
header: step.header,
777+
details: step.details && <i>Custom details for {step.details}</i>,
778+
icon: <Icon ariaLabel="success" name="status-positive" variant="success" />,
784779
}),
785780
],
786781
},

src/steps/interfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ export interface StepsProps extends BaseComponentProps {
2626
* The function is called for each step and should return an object with the following keys:
2727
* * `header` (React.ReactNode) - Summary corresponding to the step.
2828
* * `details` (React.ReactNode) - (Optional) Additional information corresponding to the step.
29+
* * `icon` (React.ReactNode) - (Optional) Replaces the standard step icon from the status indicator.
2930
*
3031
* @awsuiSystem core
3132
*/
3233
renderStep?: (step: StepsProps.Step) => {
3334
header: React.ReactNode;
3435
details?: React.ReactNode;
36+
icon?: React.ReactNode;
3537
};
3638
/**
3739
* Provides an `aria-label` to the progress steps container.

src/steps/internal.tsx

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import React from 'react';
44
import clsx from 'clsx';
55

6+
import { BoxProps } from '../box/interfaces';
7+
import InternalBox from '../box/internal';
68
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
79
import { SomeRequired } from '../internal/types';
810
import StatusIndicator from '../status-indicator/internal';
@@ -12,6 +14,17 @@ import styles from './styles.css.js';
1214

1315
type InternalStepsProps = SomeRequired<StepsProps, 'steps'> & InternalBaseComponentProps;
1416

17+
const statusToColor: Record<StepsProps.Status, BoxProps.Color> = {
18+
error: 'text-status-error',
19+
warning: 'text-status-warning',
20+
success: 'text-status-success',
21+
info: 'text-status-info',
22+
stopped: 'text-status-inactive',
23+
pending: 'text-status-inactive',
24+
'in-progress': 'text-status-inactive',
25+
loading: 'text-status-inactive',
26+
};
27+
1528
const CustomStep = ({
1629
step,
1730
orientation,
@@ -21,14 +34,19 @@ const CustomStep = ({
2134
orientation: StepsProps.Orientation;
2235
renderStep: Required<StepsProps>['renderStep'];
2336
}) => {
24-
const { header, details } = renderStep(step);
37+
const { status, statusIconAriaLabel } = step;
38+
const { header, details, icon } = renderStep(step);
2539
return (
26-
<li className={clsx(styles.container, styles.custom)}>
40+
<li className={styles.container}>
2741
<div className={styles.header}>
28-
<span>{header}</span>
29-
{orientation === 'horizontal' && <hr className={styles.connector} role="none" />}
42+
{icon ? icon : <StatusIndicator type={status} iconAriaLabel={statusIconAriaLabel} />}
43+
{orientation === 'vertical' ? header : <hr className={styles.connector} role="none" />}
3044
</div>
31-
{orientation === 'vertical' && <hr className={styles.connector} role="none" />}
45+
{orientation === 'vertical' ? (
46+
<hr className={styles.connector} role="none" />
47+
) : (
48+
<div className={styles['horizontal-header']}>{header}</div>
49+
)}
3250
{details && <div className={styles.details}>{details}</div>}
3351
</li>
3452
);
@@ -45,11 +63,17 @@ const InternalStep = ({
4563
<li className={styles.container}>
4664
<div className={styles.header}>
4765
<StatusIndicator type={status} iconAriaLabel={statusIconAriaLabel}>
48-
{header}
66+
{orientation === 'vertical' && header}
4967
</StatusIndicator>
5068
{orientation === 'horizontal' && <hr className={styles.connector} role="none" />}
5169
</div>
52-
{orientation === 'vertical' && <hr className={styles.connector} role="none" />}
70+
{orientation === 'vertical' ? (
71+
<hr className={styles.connector} role="none" />
72+
) : (
73+
<div className={styles['horizontal-header']}>
74+
<InternalBox color={statusToColor[status]}>{header}</InternalBox>
75+
</div>
76+
)}
5377
{details && <div className={styles.details}>{details}</div>}
5478
</li>
5579
);

src/steps/styles.scss

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
grid-template-rows: minmax(awsui.$space-static-l, auto);
2121

2222
> .header {
23+
display: flex;
24+
gap: awsui.$space-xxs;
2325
grid-row: 1;
2426
grid-column: 1 / span 2;
2527
}
@@ -89,17 +91,18 @@
8991
block-size: awsui.$border-divider-list-width;
9092
inline-size: auto;
9193
min-inline-size: awsui.$space-static-xs;
92-
margin-inline: awsui.$space-static-xxxs;
94+
margin-inline-end: awsui.$space-static-xxs;
9395
}
9496
}
9597

96-
> .details {
97-
display: flex;
98-
grid-column: 2 / span 2;
98+
> .horizontal-header {
99+
grid-row: 2;
100+
grid-column: 1 / span 3;
99101
}
100102

101-
&.custom > .details {
102-
grid-column: span 3;
103+
> .details {
104+
grid-row: 3;
105+
grid-column: 1 / span 3;
103106
}
104107
}
105108

0 commit comments

Comments
 (0)