Skip to content

Commit

Permalink
Make the StepList props with default values optional
Browse files Browse the repository at this point in the history
  • Loading branch information
pwolfert authored and forrestbaer committed Jan 31, 2022
1 parent c206ec6 commit 8135c45
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
6 changes: 3 additions & 3 deletions packages/design-system/src/components/StepList/Step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export interface StepProps {
editText: string;
resumeText: string;
startText: string;
actionsLabelText?: string;
descriptionLabelText?: string;
substepsLabelText?: string;
actionsLabelText: string;
descriptionLabelText: string;
substepsLabelText: string;
}

export const Step = ({ step, ...props }: StepProps) => {
Expand Down
53 changes: 32 additions & 21 deletions packages/design-system/src/components/StepList/StepList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,59 @@ export interface StepListProps {
* clicked. The step's `href` property will be passed as a parameter.
*/
onStepLinkClick?: StepLinkProps['onClick'];
completedText: string;
editText: string;
resumeText: string;
startText: string;
completedText?: string;
editText?: string;
resumeText?: string;
startText?: string;
/**
* A template string for the aria-label describing a step's actions where
* the substring `%{step}` is replaced with that step's `heading`.
*/
actionsLabelText: string;
actionsLabelText?: string;
/**
* A template string for the aria-label for a step's description where
* the substring `%{step}` is replaced with that step's `heading`.
*/
descriptionLabelText: string;
descriptionLabelText?: string;
/**
* A template string for the aria-label describing a step's substeps where
* the substring `%{step}` is replaced with that step's `heading`.
*/
substepsLabelText: string;
substepsLabelText?: string;
}

export const StepList = ({ steps, ...props }: StepListProps) => (
export const StepList = ({
steps,
component,
showSubSubSteps = false,
completedText = 'Completed',
editText = 'Edit',
resumeText = 'Resume',
startText = 'Start',
actionsLabelText = 'Primary actions for %{step}',
descriptionLabelText = 'Description for %{step}',
substepsLabelText = 'Secondary actions for %{step}',
...otherProps
}: StepListProps) => (
<ol className="ds-c-step-list">
{steps.map((step, i) => (
<Step
step={{ ...step, ...{ component: props.component || step.component } }}
step={{ ...step, ...{ component: component || step.component } }}
key={step.id || i}
{...props}
{...{
showSubSubSteps,
completedText,
editText,
resumeText,
startText,
actionsLabelText,
descriptionLabelText,
substepsLabelText,
...otherProps,
}}
/>
))}
</ol>
);

StepList.defaultProps = {
showSubSubSteps: false,
completedText: 'Completed',
editText: 'Edit',
resumeText: 'Resume',
startText: 'Start',
actionsLabelText: 'Primary actions for %{step}',
descriptionLabelText: 'Description for %{step}',
substepsLabelText: 'Secondary actions for %{step}',
};

export default StepList;

0 comments on commit 8135c45

Please sign in to comment.