Skip to content

Commit 074f5e2

Browse files
committed
chore(Stepper): update docs
1 parent 34ffab3 commit 074f5e2

3 files changed

Lines changed: 25 additions & 11 deletions

File tree

src/components/Stepper/sgds-step.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import SgdsIcon from "../Icon/sgds-icon";
66
import stepStyle from "./step.css";
77

88
/**
9-
* @summary A step within a stepper component
10-
* @slot default - Additional content to display under the step header
9+
* @summary A single step within an sgds-stepper. Manages its own active, completed, and disabled states based on props set by the parent stepper.
1110
*
11+
* @slot default - Optional content displayed below the step header label
1212
*/
1313
export class SgdsStep extends SgdsElement {
1414
static styles = [...SgdsElement.styles, stepStyle];
@@ -23,7 +23,7 @@ export class SgdsStep extends SgdsElement {
2323
@property({ type: String, reflect: true })
2424
iconName: string | undefined;
2525

26-
/** Optional component to render for this step */
26+
/** Optional component reference associated with this step. Retrievable via `sgds-stepper.getComponent()`. */
2727
@property({ type: Object })
2828
component: unknown;
2929

src/components/Stepper/sgds-stepper.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export type { IStepMetaData };
1717
* @event sgds-next-step - Emitted right before the next step is reached. Event is fired when nextStep method is called.
1818
* @event sgds-previous-step - Emitted right before the previous step is reached. Event is fired when previousStep method is called.
1919
* @event sgds-last-step - Emitted right before the last step is reached. Event is fired when lastStep method is called.
20-
* @event sgds-first-step - Emitted on hide after animation has completed. Event is fired when firstStep method is called.
21-
* @event sgds-arrived - Emitted right after the activeStep has updated its state, when upcoming step has arrived. Call `getMethod()` on this event to get the current step's component.
20+
* @event sgds-first-step - Emitted right before the first step is reached. Event is fired when firstStep method is called.
21+
* @event sgds-arrived - Emitted right after the activeStep has updated its state, when upcoming step has arrived. Call `getComponent()` on the stepper to get the current step's component.
2222
* @event sgds-reset - Emitted right before the step is reset to its defaultActiveStep. Event is fired when reset method is called.
2323
* @slot default - slot for sgds-step children
2424
*
@@ -62,7 +62,7 @@ export class SgdsStepper extends SgdsElement {
6262

6363
/**
6464
* Indicates the presence of the default slot.
65-
* Used for server-side rendering to determine table structure.
65+
* Used to switch between slotted sgds-step children and the legacy steps property.
6666
* @type {boolean}
6767
* @internal
6868
* @default false
@@ -109,10 +109,9 @@ export class SgdsStepper extends SgdsElement {
109109
}
110110
}
111111

112-
/** By default, it returns the corresponding component of the current activeStep as defined in the steps metadata. To get other components, pass in your desired step number as the parameter*/
112+
/** Returns the component associated with the given step index. Defaults to the current activeStep if no argument is provided. */
113113
public getComponent(step: number = this.activeStep) {
114114
const items = this.hasDefaultSlot ? this._items : this.steps;
115-
console.log(step, this._items);
116115

117116
if (items && items.length > 0) {
118117
return items[step]?.component;

stories/component-templates/Stepper/basic.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
import { html } from "lit";
22
import { ifDefined } from "lit/directives/if-defined.js";
33

4-
export const Template = ({ stepHeaders, activeStep, clickable, orientation }) => {
4+
export const Template = ({ steps, activeStep, clickable, orientation }) => {
55
return html`
66
<sgds-stepper activeStep=${ifDefined(activeStep)} ?clickable=${clickable} orientation=${ifDefined(orientation)}>
7-
${stepHeaders.map(header => html`<sgds-step stepHeader="${header}"></sgds-step> `)}
7+
${steps.map(
8+
header => html`<sgds-step stepHeader="${header.stepHeader}" .component=${header.component}></sgds-step> `
9+
)}
810
</sgds-stepper>
911
`;
1012
};
1113

1214
export const args = {
13-
stepHeaders: ["Personal Details", "Address and Contact Information", "Review"]
15+
steps: [
16+
{
17+
stepHeader: "Personal Details",
18+
component: "1 test"
19+
},
20+
{
21+
stepHeader: "Address and Contact Information",
22+
component: "2 test"
23+
},
24+
{
25+
stepHeader: "Review",
26+
component: "3 test"
27+
}
28+
]
1429
};
1530

1631
export const parameters = {};

0 commit comments

Comments
 (0)