Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Docs - Stepper Component #2727

Open
wants to merge 99 commits into
base: dchyun/stepper-component
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
4fd91cf
HDS-4411 `Stepper::Navigation` and `Stepper::List` components added
dchyun Feb 19, 2025
66be071
Fix: A11y improvements
dchyun Feb 19, 2025
b0e562e
Feat: Add panel component, align to tabs implementation
dchyun Feb 21, 2025
09f4046
Fix: a11y structure improvements for non-interactive steps
dchyun Feb 21, 2025
92dc1b6
Feat: body block when using `@steps`
dchyun Feb 21, 2025
2e3c41d
Fix: showcase active state and a11y automated tests
dchyun Feb 21, 2025
c9ba689
Feat: Tests added, Bugs from tests fixed in list and navigation
dchyun Feb 24, 2025
baa601d
Fix: Convert did-insert to custom modifier
dchyun Feb 24, 2025
6f991ed
Feat: Assertion for number of panels and steps
dchyun Feb 24, 2025
2d7a237
Chore: Linting fixes
dchyun Feb 24, 2025
15c6acd
Feat: Design style alignment
dchyun Feb 25, 2025
a06afa1
Feat: Move isInteractive from `Navigation::Step` to `Navigation`, hav…
dchyun Feb 26, 2025
8e3ec18
Feat: Rename `Stepper::Navigation` to `Stepper::Nav`
dchyun Feb 26, 2025
fd3779c
Fix: Prevent click and keyboard on non-interactive steps
dchyun Feb 26, 2025
564d428
Chore: Linting fixes
dchyun Feb 26, 2025
563ad91
Fix: Align class names in List
dchyun Feb 26, 2025
9e582a6
Fix: List failing test
dchyun Feb 26, 2025
da2209c
Fix: Navigation interactive title color
dchyun Feb 26, 2025
d17403c
Fix: Remove stepNumber arg from step sub components
dchyun Feb 27, 2025
b1531ef
Chore: Linting fixes
dchyun Feb 27, 2025
a41411f
Feat: Convert list step to custom modifier
dchyun Feb 27, 2025
8e554fa
Chore: Add changeset
dchyun Feb 27, 2025
3cce0a5
Fix: Address design feedback
dchyun Mar 3, 2025
488881c
Feat: `Stepper::Nav` mobile design
dchyun Mar 3, 2025
a0038f5
Chore: Address changeset feedback
dchyun Mar 4, 2025
268676f
Fix: Align to BEM class naming
dchyun Mar 4, 2025
5fac2c8
Fix: Address list feedback
dchyun Mar 5, 2025
17049ec
Fix: Remove insert & destroy actions from `Stepper::List`
dchyun Mar 5, 2025
a650005
Fix: Prevent steps from getting set to complete initially
dchyun Mar 6, 2025
111c5f0
Feat: Separate stepper showcase to sub pages
dchyun Mar 6, 2025
590340a
Fix: Address a11y feedback
dchyun Mar 6, 2025
c590aa6
Fix: Address feedback
dchyun Mar 6, 2025
47f435f
Feat: `Stepper::Nav` animation
dchyun Mar 7, 2025
e8224a8
Fix: Add showcase list examples and cleanup
dchyun Mar 7, 2025
ff36d5b
Feat: Nav support for not using panel blocks
dchyun Mar 7, 2025
7c61313
Feat: Add `ariaLabel` arg for nav and list
dchyun Mar 7, 2025
15903b0
Fix: Address a11y feedback
dchyun Mar 7, 2025
b53bf7a
Fix: Step ordering issue when steps added or removed
dchyun Mar 10, 2025
2beeb11
Chore: Showcase linting
dchyun Mar 10, 2025
27378c7
Chore: component linting
dchyun Mar 10, 2025
6daf6da
Fix: Nav style and animation bugs
dchyun Mar 11, 2025
4aad551
Fix: Address style color feedback
dchyun Mar 11, 2025
dd9c9fa
Feat: Style updates for nav interactive indicator
dchyun Mar 12, 2025
26f710f
Feat: Nav - set `isInteractive` default value to `true`
dchyun Mar 12, 2025
90f4b0e
Stepper documentation
majedelass Feb 27, 2025
8309a02
Feat: Stepper code docs
dchyun Feb 27, 2025
ff36a4e
Updated page structure to follow naming convention
majedelass Feb 27, 2025
80ae667
Updated wording within docs.
majedelass Feb 27, 2025
6c6bda1
Updated wording in specifications tab.
majedelass Feb 27, 2025
d4ba71b
Updated indicator docs by removing 'out of order'
majedelass Feb 27, 2025
5e52b8d
updated figma path
majedelass Feb 27, 2025
58ecc31
adding related links to each component
majedelass Feb 28, 2025
be486ca
Updating text and images for Stepper List
majedelass Feb 28, 2025
c38f89c
Updated text and images for Stepper Nav
majedelass Feb 28, 2025
e7bdd10
Apply suggestions from code review
majedelass Mar 3, 2025
776e128
Feat: Stepper accessibility docs
dchyun Mar 3, 2025
d57da2c
Apply suggestions from code review
majedelass Mar 4, 2025
35a4be8
update image to fix buttons.
majedelass Mar 4, 2025
50cc95c
updated spacing image
majedelass Mar 4, 2025
dbaf6cd
removed overview.md files
majedelass Mar 4, 2025
9651578
Fix: Address feedback in code and accessibility docs
dchyun Mar 4, 2025
ea44beb
Chore: Rename assets from navigation to nav
dchyun Mar 4, 2025
acf70f8
Chore: Linting fixes
dchyun Mar 4, 2025
876ab90
Fix: Failing docs tests
dchyun Mar 4, 2025
5bc8464
Fix: Nav api default values
dchyun Mar 4, 2025
0cd1217
Apply suggestions from code review
majedelass Mar 4, 2025
84417f9
Updated image sizing in specification sections
majedelass Mar 5, 2025
c390995
Apply suggestions from code review
majedelass Mar 5, 2025
53e3b96
updated to include related components in keywords
majedelass Mar 5, 2025
f4c9e67
added dont guidelines for progressive disclosure
majedelass Mar 5, 2025
89c4ea2
Apply suggestions from code review
majedelass Mar 5, 2025
7dfa7e0
Fix: Address feedback in code docs
dchyun Mar 5, 2025
9177d62
Apply suggestions from code review
majedelass Mar 5, 2025
4bf820b
Apply suggestions from code review
majedelass Mar 6, 2025
97c3001
Apply suggestions from code review
majedelass Mar 6, 2025
062a276
Apply suggestions from code review
majedelass Mar 6, 2025
e408a7c
Apply suggestions from code review
majedelass Mar 6, 2025
eceb184
Fix: Address Nav code docs feedback
dchyun Mar 7, 2025
ed06fb4
Feat: Add `ariaLabel` arg to docs
dchyun Mar 7, 2025
63c3495
Apply suggestions from code review
majedelass Mar 10, 2025
bb246c9
added illustrations for each stepper component
majedelass Mar 10, 2025
aebe71d
updated path for figma component links
majedelass Mar 10, 2025
00db3fe
updated examples for progressive disclosure
majedelass Mar 11, 2025
10173ec
Fix: Address nav docs feedback
dchyun Mar 11, 2025
fe8dbe8
Feat: No panels example for nav code docs
dchyun Mar 11, 2025
2d9e1c3
Fix: Address nav code feedback
dchyun Mar 11, 2025
b80119a
Apply suggestions from code review
majedelass Mar 12, 2025
efa8e41
Feat: Update nav docs to `isInteractive` default of `true`
dchyun Mar 12, 2025
05d897d
Fix: Update component api component names
dchyun Mar 12, 2025
877185d
updated images to reflect A11Y changes
majedelass Mar 13, 2025
3ca7931
Apply suggestions from code review
majedelass Mar 13, 2025
c700e64
updated images in accessibility tab
majedelass Mar 13, 2025
8171fcd
updated do for list progressive disclosure.
majedelass Mar 13, 2025
92e8a4e
Apply suggestions from code review
majedelass Mar 13, 2025
e8533d7
Apply suggestions from code review
majedelass Mar 13, 2025
2605057
Apply suggestions from code review
majedelass Mar 13, 2025
aad558b
Feat: `Stepper::Nav` add `Button` example
dchyun Mar 13, 2025
825b1ab
Fix: Remove extra Nav code example
dchyun Mar 13, 2025
865118c
Apply suggestions from code review
majedelass Mar 14, 2025
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
7 changes: 7 additions & 0 deletions .changeset/four-jokes-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@hashicorp/design-system-components": minor
---

`Stepper::List` - Added `Stepper::List` component and related sub-components

`Stepper::Navigation` - Added `Stepper::Navigation` component and related sub-components
5 changes: 5 additions & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@
"./components/hds/side-nav/portal/index.js": "./dist/_app_/components/hds/side-nav/portal/index.js",
"./components/hds/side-nav/portal/target.js": "./dist/_app_/components/hds/side-nav/portal/target.js",
"./components/hds/side-nav/toggle-button.js": "./dist/_app_/components/hds/side-nav/toggle-button.js",
"./components/hds/stepper/list/index.js": "./dist/_app_/components/hds/stepper/list/index.js",
"./components/hds/stepper/list/step.js": "./dist/_app_/components/hds/stepper/list/step.js",
"./components/hds/stepper/nav/index.js": "./dist/_app_/components/hds/stepper/nav/index.js",
"./components/hds/stepper/nav/panel.js": "./dist/_app_/components/hds/stepper/nav/panel.js",
"./components/hds/stepper/nav/step.js": "./dist/_app_/components/hds/stepper/nav/step.js",
"./components/hds/stepper/step/indicator.js": "./dist/_app_/components/hds/stepper/step/indicator.js",
"./components/hds/stepper/task/indicator.js": "./dist/_app_/components/hds/stepper/task/indicator.js",
"./components/hds/table/index.js": "./dist/_app_/components/hds/table/index.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ export { default as HdsSideNavPortalTarget } from './components/hds/side-nav/por
export { default as HdsSideNavToggleButton } from './components/hds/side-nav/toggle-button.ts';

// Stepper
export { default as HdsStepperList } from './components/hds/stepper/list/index.ts';
export { default as HdsStepperListStep } from './components/hds/stepper/list/step.ts';
export { default as HdsStepperNav } from './components/hds/stepper/nav/index.ts';
export { default as HdsStepperNavPanel } from './components/hds/stepper/nav/panel.ts';
export { default as HdsStepperNavStep } from './components/hds/stepper/nav/step.ts';
export { default as HdsStepperStepIndicator } from './components/hds/stepper/step/indicator.ts';
export { default as HdsStepperTaskIndicator } from './components/hds/stepper/task/indicator.ts';
export * from './components/hds/stepper/types.ts';
Expand Down
17 changes: 17 additions & 0 deletions packages/components/src/components/hds/stepper/list/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
<ol class="hds-stepper-list" aria-label={{@ariaLabel}} ...attributes>
{{yield
(hash
Step=(component
"hds/stepper/list/step"
titleTag=this.titleTag
stepIds=this._stepIds
didInsertNode=this.didInsertStep
willDestroyNode=this.willDestroyStep
)
)
}}
</ol>
52 changes: 52 additions & 0 deletions packages/components/src/components/hds/stepper/list/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { schedule } from '@ember/runloop';
import type { ComponentLike } from '@glint/template';
import type { HdsStepperListStepSignature } from './step';

import { HdsStepperTitleTagValues } from '../types.ts';
import type { HdsStepperTitleTags, HdsStepperListStepIds } from '../types.ts';

export interface HdsStepperListSignature {
Args: {
titleTag?: HdsStepperTitleTags;
ariaLabel: string;
};
Blocks: {
default: [
{
Step?: ComponentLike<HdsStepperListStepSignature>;
},
];
};
Element: HTMLElement;
}

export default class HdsStepperList extends Component<HdsStepperListSignature> {
@tracked private _stepIds: HdsStepperListStepIds = [];

get titleTag(): HdsStepperTitleTags {
return this.args.titleTag ?? HdsStepperTitleTagValues.Div;
}

@action
didInsertStep(element: HTMLElement): void {
// eslint-disable-next-line ember/no-runloop
schedule('afterRender', (): void => {
this._stepIds = [...this._stepIds, element.id];
});
}

@action
willDestroyStep(element: HTMLElement): void {
this._stepIds = this._stepIds.filter(
(stepId): boolean => stepId !== element.id
);
}
}
32 changes: 32 additions & 0 deletions packages/components/src/components/hds/stepper/list/step.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
<li class={{this.classNames}} ...attributes id={{this._stepId}} {{this._setUpStep @didInsertNode @willDestroyNode}}>
<div class="hds-stepper-list__step-progress">
<Hds::Stepper::Step::Indicator
@text="{{this.stepNumber}}"
@status={{this.status}}
@isInteractive={{false}}
class="hds-stepper-list__step-indicator"
/>
</div>
<div class="hds-stepper-list__step-text">
<Hds::Text::Body class="hds-stepper-list__step-title" @tag={{this.titleTag}} @size="200" @weight="semibold">
{{yield to="title"}}
<span class="sr-only">{{this.statusSrOnlyText}}</span>
</Hds::Text::Body>
<Hds::Text::Body
class="hds-stepper-list__step-description"
@tag="div"
@size="100"
@weight="regular"
@color="regular"
>
{{yield to="description"}}
</Hds::Text::Body>
<div class="hds-stepper-list__step-content">
{{yield to="content"}}
</div>
</div>
</li>
96 changes: 96 additions & 0 deletions packages/components/src/components/hds/stepper/list/step.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import { assert } from '@ember/debug';
import { guidFor } from '@ember/object/internals';
import { modifier } from 'ember-modifier';

import {
HdsStepperStatusesValues,
HdsStepperTitleTagValues,
} from '../types.ts';
import {
type HdsStepperStatuses,
type HdsStepperTitleTags,
type HdsStepperListStepIds,
HdsStepperStatusToSrOnlyText,
} from '../types.ts';

export const DEFAULT_STATUS = HdsStepperStatusesValues.Incomplete;
export const STATUSES: string[] = Object.values(HdsStepperStatusesValues);
export const MAPPING_STATUS_TO_SR_ONLY_TEXT = HdsStepperStatusToSrOnlyText;

export interface HdsStepperListStepSignature {
Args: {
status: HdsStepperStatusesValues;
titleTag?: HdsStepperTitleTags;
stepIds?: HdsStepperListStepIds;
didInsertNode?: (element: HTMLElement) => void;
willDestroyNode?: (element: HTMLElement) => void;
};
Blocks: {
title: [];
description?: [];
content?: [];
};
Element: HTMLElement;
}

export default class HdsStepperListStep extends Component<HdsStepperListStepSignature> {
private _stepId = 'step-' + guidFor(this);

private _setUpStep = modifier(
(
element: HTMLElement,
[insertCallbackFunction, destoryCallbackFunction]
) => {
if (typeof insertCallbackFunction === 'function') {
insertCallbackFunction(element);
}

return () => {
if (typeof destoryCallbackFunction === 'function') {
destoryCallbackFunction(element);
}
};
}
);

get stepNumber(): number | undefined {
return this.args.stepIds
? this.args.stepIds.indexOf(this._stepId) + 1
: undefined;
}

get status(): HdsStepperStatuses {
const { status = DEFAULT_STATUS } = this.args;

assert(
`@status for "Hds::Stepper::List::Step" must be one of the following: ${STATUSES.join(
', '
)}; received: ${status}`,
STATUSES.includes(status)
);

return status;
}

get statusSrOnlyText(): string {
return MAPPING_STATUS_TO_SR_ONLY_TEXT[this.status];
}

get titleTag(): HdsStepperTitleTags {
return this.args.titleTag ?? HdsStepperTitleTagValues.Div;
}

get classNames(): string {
const classes = ['hds-stepper-list__step'];

classes.push(`hds-stepper-list__step--${this.status}`);

return classes.join(' ');
}
}
76 changes: 76 additions & 0 deletions packages/components/src/components/hds/stepper/nav/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
<div
class={{this.classNames}}
...attributes
{{style --progress-bar-width=this.progressBarWidthStyle}}
{{this._setUpStepperNav}}
>
<ol class="hds-stepper-nav__list" aria-label={{@ariaLabel}} role={{if this.isInteractive "tablist"}}>
{{#if @steps}}
{{#each @steps as |step|}}
<Hds::Stepper::Nav::Step
@currentStep={{this.currentStep}}
@isNavInteractive={{this.isInteractive}}
@titleTag={{this.titleTag}}
@didInsertNode={{this.didInsertStep}}
@willDestroyNode={{this.willDestroyStep}}
@stepIds={{this._stepIds}}
@panelIds={{this._panelIds}}
@onStepChange={{@onStepChange}}
@onKeyUp={{this.onKeyUp}}
>
<:title>{{step.title}}</:title>
<:description>{{step.description}}</:description>
</Hds::Stepper::Nav::Step>
{{/each}}
{{else}}
{{yield
(hash
Step=(component
"hds/stepper/nav/step"
currentStep=this.currentStep
isNavInteractive=this.isInteractive
titleTag=this.titleTag
stepIds=this._stepIds
panelIds=this._panelIds
didInsertNode=this.didInsertStep
willDestroyNode=this.willDestroyStep
onStepChange=@onStepChange
onKeyUp=this.onKeyUp
)
)
}}
{{/if}}
</ol>
{{#if (and @steps (has-block "body"))}}
{{#each @steps}}
<Hds::Stepper::Nav::Panel
@currentStep={{this.currentStep}}
@isNavInteractive={{this.isInteractive}}
@stepIds={{this._stepIds}}
@panelIds={{this._panelIds}}
@didInsertNode={{this.didInsertPanel}}
@willDestroyNode={{this.willDestroyPanel}}
>
{{yield to="body"}}
</Hds::Stepper::Nav::Panel>
{{/each}}
{{else}}
{{yield
(hash
Panel=(component
"hds/stepper/nav/panel"
currentStep=this.currentStep
isNavInteractive=this.isInteractive
stepIds=this._stepIds
panelIds=this._panelIds
didInsertNode=this.didInsertPanel
willDestroyNode=this.willDestroyPanel
)
)
}}
{{/if}}
</div>
Loading