Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4983,6 +4983,39 @@ exports[`Story HTML snapshots > ProgressIndicator > Interactive 1`] = `
</div>"
`;

exports[`Story HTML snapshots > ProgressIndicator > InteractivePath 1`] = `
"<div class="slds-p-around_medium">
<div id="_R_0_" class="slds-path">
<div class="slds-grid slds-path__track">
<div class="slds-grid slds-path__scroller-container">
<div class="slds-path__scroller">
<div class="slds-path__scroller_inner">
<ul class="slds-path__nav" role="listbox" aria-orientation="horizontal" aria-labelledby="_R_0_-stage-name">
<li class="slds-path__item slds-is-complete" role="presentation"><a tabindex="-1" aria-selected="false" class="slds-path__link" href="#" id="_R_0_-path-0" role="option"><span class="slds-path__stage"><svg class="slds-icon slds-icon_x-small" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#check"></use>
</svg><span class="slds-assistive-text">Stage Complete</span></span><span class="slds-path__title">Contacted</span></a></li>
<li class="slds-path__item slds-is-current slds-is-active" role="presentation"><a tabindex="0" aria-selected="true" class="slds-path__link" href="#" id="_R_0_-path-1" role="option"><span class="slds-path__stage"><svg class="slds-icon slds-icon_x-small" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#check"></use>
</svg><span class="slds-assistive-text">Current Stage:</span></span><span class="slds-path__title">Open</span></a></li>
<li class="slds-path__item slds-is-incomplete" role="presentation"><a tabindex="-1" aria-selected="false" class="slds-path__link" href="#" id="_R_0_-path-2" role="option"><span class="slds-path__stage"><svg class="slds-icon slds-icon_x-small" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#check"></use>
</svg></span><span class="slds-path__title">Unqualified</span></a></li>
<li class="slds-path__item slds-is-incomplete" role="presentation"><a tabindex="-1" aria-selected="false" class="slds-path__link" href="#" id="_R_0_-path-3" role="option"><span class="slds-path__stage"><svg class="slds-icon slds-icon_x-small" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#check"></use>
</svg></span><span class="slds-path__title">Nurturing</span></a></li>
<li class="slds-path__item slds-is-incomplete" role="presentation"><a tabindex="-1" aria-selected="false" class="slds-path__link" href="#" id="_R_0_-path-4" role="option"><span class="slds-path__stage"><svg class="slds-icon slds-icon_x-small" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#check"></use>
</svg></span><span class="slds-path__title">Closed</span></a></li>
</ul>
</div>
</div>
</div>
<div class="slds-grid slds-path__action"><span id="_R_0_-stage-name" class="slds-path__stage-name">Stage: Open</span></div>
</div>
</div>
</div>"
`;

exports[`Story HTML snapshots > ProgressIndicator > ModalVariant 1`] = `
"<div class="slds-p-around_medium">
<div id="_R_0_" class="slds-progress slds-progress_shade">
Expand Down Expand Up @@ -5012,6 +5045,39 @@ exports[`Story HTML snapshots > ProgressIndicator > ModalVariant 1`] = `
</div>"
`;

exports[`Story HTML snapshots > ProgressIndicator > Path 1`] = `
"<div class="slds-p-around_medium">
<div id="_R_0_" class="slds-path">
<div class="slds-grid slds-path__track">
<div class="slds-grid slds-path__scroller-container">
<div class="slds-path__scroller">
<div class="slds-path__scroller_inner">
<ul class="slds-path__nav" role="listbox" aria-orientation="horizontal" aria-labelledby="_R_0_-stage-name">
<li class="slds-path__item slds-is-complete" role="presentation"><a tabindex="-1" aria-selected="false" class="slds-path__link" href="#" id="_R_0_-path-0" role="option"><span class="slds-path__stage"><svg class="slds-icon slds-icon_x-small" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#check"></use>
</svg><span class="slds-assistive-text">Stage Complete</span></span><span class="slds-path__title">Contacted</span></a></li>
<li class="slds-path__item slds-is-complete" role="presentation"><a tabindex="-1" aria-selected="false" class="slds-path__link" href="#" id="_R_0_-path-1" role="option"><span class="slds-path__stage"><svg class="slds-icon slds-icon_x-small" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#check"></use>
</svg><span class="slds-assistive-text">Stage Complete</span></span><span class="slds-path__title">Open</span></a></li>
<li class="slds-path__item slds-is-current slds-is-active" role="presentation"><a tabindex="0" aria-selected="true" class="slds-path__link" href="#" id="_R_0_-path-2" role="option"><span class="slds-path__stage"><svg class="slds-icon slds-icon_x-small" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#check"></use>
</svg><span class="slds-assistive-text">Current Stage:</span></span><span class="slds-path__title">Unqualified</span></a></li>
<li class="slds-path__item slds-is-incomplete" role="presentation"><a tabindex="-1" aria-selected="false" class="slds-path__link" href="#" id="_R_0_-path-3" role="option"><span class="slds-path__stage"><svg class="slds-icon slds-icon_x-small" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#check"></use>
</svg></span><span class="slds-path__title">Nurturing</span></a></li>
<li class="slds-path__item slds-is-incomplete" role="presentation"><a tabindex="-1" aria-selected="false" class="slds-path__link" href="#" id="_R_0_-path-4" role="option"><span class="slds-path__stage"><svg class="slds-icon slds-icon_x-small" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#check"></use>
</svg></span><span class="slds-path__title">Closed</span></a></li>
</ul>
</div>
</div>
</div>
<div class="slds-grid slds-path__action"><span id="_R_0_-stage-name" class="slds-path__stage-name">Stage: Unqualified</span></div>
</div>
</div>
</div>"
`;

exports[`Story HTML snapshots > ProgressIndicator > SetupAssistantVariant 1`] = `
"<div class="slds-p-around_medium">
<div id="_R_0_" class="slds-progress slds-progress_vertical slds-progress_success">
Expand Down Expand Up @@ -5040,6 +5106,37 @@ exports[`Story HTML snapshots > ProgressIndicator > SetupAssistantVariant 1`] =
</div>"
`;

exports[`Story HTML snapshots > ProgressIndicator > ShadeVariant 1`] = `
"<div class="slds-p-around_medium">
<div class="slds-theme_shade slds-p-around_medium">
<div id="_R_0_" class="slds-progress slds-progress_shade">
<ol class="slds-progress__list">
<li class="slds-progress__item slds-is-completed">
<div class="slds-tooltip-trigger" style="line-height:1"><button class="slds-button slds-button_icon slds-progress__marker slds-progress__marker_icon" type="button"><svg class="slds-button__icon" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#success"></use>
</svg><span class="slds-assistive-text">Step 1: Step 1: Introduction - Completed</span></button><span></span></div>
</li>
<li class="slds-progress__item slds-is-completed">
<div class="slds-tooltip-trigger" style="line-height:1"><button class="slds-button slds-button_icon slds-progress__marker slds-progress__marker_icon" type="button"><svg class="slds-button__icon" aria-hidden="true">
<use href="/assets/icons/utility-sprite/svg/symbols.svg#success"></use>
</svg><span class="slds-assistive-text">Step 2: Step 2: Configuration - Completed</span></button><span></span></div>
</li>
<li class="slds-progress__item slds-is-active">
<div class="slds-tooltip-trigger" style="display:flex;line-height:1"><button class="slds-button slds-progress__marker" aria-current="step" type="button"><span class="slds-assistive-text">Step 3: Step 3: Review</span></button><span></span></div>
</li>
<li class="slds-progress__item">
<div class="slds-tooltip-trigger" style="display:flex;line-height:1"><button class="slds-button slds-progress__marker" type="button"><span class="slds-assistive-text">Step 4: Step 4: Confirmation</span></button><span></span></div>
</li>
<li class="slds-progress__item">
<div class="slds-tooltip-trigger" style="display:flex;line-height:1"><button class="slds-button slds-progress__marker" type="button"><span class="slds-assistive-text">Step 5: Step 5: Complete</span></button><span></span></div>
</li>
</ol>
<div class="slds-progress-bar slds-progress-bar_x-small" aria-valuemin="0" aria-valuemax="100" aria-valuenow="50" role="progressbar"><span class="slds-progress-bar__value" style="width:50%"><span class="slds-assistive-text">Progress: 50%</span></span></div>
</div>
</div>
</div>"
`;

exports[`Story HTML snapshots > ProgressIndicator > Vertical 1`] = `
"<div class="slds-p-around_medium">
<div id="_R_0_" class="slds-progress slds-progress_vertical">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ const steps = [
{ id: 4, label: 'Step 5: Complete' },
];

const stages = [
{ id: 0, label: 'Contacted' },
{ id: 1, label: 'Open' },
{ id: 2, label: 'Unqualified' },
{ id: 3, label: 'Nurturing' },
{ id: 4, label: 'Closed' },
];

export default {
title: 'Components/ProgressIndicator',
component: ProgressIndicator,
Expand All @@ -27,9 +35,13 @@ export default {
control: { type: 'select' },
options: ['horizontal', 'vertical'],
},
type: {
control: { type: 'select' },
options: ['base', 'path'],
},
variant: {
control: { type: 'select' },
options: ['base', 'modal', 'setup-assistant'],
options: ['base', 'shade', 'modal', 'setup-assistant'],
},
},
};
Expand Down Expand Up @@ -76,7 +88,9 @@ const InteractiveExample = () => {
</button>
<button
className="slds-button slds-button_brand"
onClick={() => setCurrentStep(Math.min(steps.length - 1, currentStep + 1))}
onClick={() =>
setCurrentStep(Math.min(steps.length - 1, currentStep + 1))
}
disabled={currentStep === steps.length - 1}
>
Next
Expand Down Expand Up @@ -126,6 +140,20 @@ export const WithDisabledSteps = {
),
};

// Shade variant
export const ShadeVariant = {
render: () => (
<div className="slds-theme_shade slds-p-around_medium">
<ProgressIndicator
steps={steps}
selectedStep={steps[2]}
completedSteps={[steps[0], steps[1]]}
variant="shade"
/>
</div>
),
};

// Modal variant
export const ModalVariant = {
render: () => (
Expand Down Expand Up @@ -160,3 +188,41 @@ export const AllComplete = {
/>
),
};

// Path type
export const Path = {
render: () => (
<ProgressIndicator
type="path"
steps={stages}
selectedStep={stages[2]}
completedSteps={[stages[0], stages[1]]}
/>
),
};

// Interactive path: click a stage, or Tab to the path and use the arrow keys
const InteractivePathExample = () => {
const [currentStage, setCurrentStage] = useState(1);

const handleStepClick = (event, { step }) => {
const stageIndex = stages.findIndex((s) => s.id === step.id);
if (stageIndex !== -1) {
setCurrentStage(stageIndex);
}
};

return (
<ProgressIndicator
type="path"
steps={stages}
selectedStep={stages[currentStage]}
completedSteps={stages.slice(0, currentStage)}
onStepClick={handleStepClick}
/>
);
};

export const InteractivePath = {
render: () => <InteractivePathExample />,
};
49 changes: 49 additions & 0 deletions components/progress-indicator/__examples__/path.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import IconSettings from '~/components/icon-settings';
import ProgressIndicator from '~/components/progress-indicator'; // `~` is replaced with design-system-react at runtime

const stages = [
{ id: 0, label: 'Contacted' },
{ id: 1, label: 'Open' },
{ id: 2, label: 'Unqualified' },
{ id: 3, label: 'Nurturing' },
{ id: 4, label: 'Closed' },
];

/*
* With `type="path"`, the steps render as the stages of a path. Clicking a stage makes it the current stage, and the stages before it complete. The path is a single tab stop; the arrow keys move between stages.
*/
class Example extends React.Component {
constructor(props) {
super(props);

this.state = {
selectedStep: stages[1],
};
}

handleStepClick = (event, data) => {
this.setState({ selectedStep: data.step });
};

render() {
const { selectedStep } = this.state;

return (
<IconSettings iconPath="/assets/icons">
<ProgressIndicator
id="path-progress-indicator"
completedSteps={stages.slice(0, selectedStep.id)}
onStepClick={this.handleStepClick}
selectedStep={selectedStep}
steps={stages}
type="path"
/>
</IconSettings>
);
}
}

Example.displayName = 'ProgressIndicatorPath';

export default Example; // export is replaced with `ReactDOM.render(<Example />, mountNode);` at runtime
Loading
Loading