5.1.0 • Published 6 days ago

@purpurds/stepper v5.1.0

Weekly downloads
-
License
AGPL-3.0-only
Repository
-
Last release
6 days ago

import { Meta, Stories, StoryObj, ArgTypes, Primary, Subtitle } from "@storybook/blocks";

import as StepperStories from "./src/stepper.stories"; import as StepperContentStories from "./src/stepper-content.stories"; import packageInfo from "./package.json";

Stepper

Version {packageInfo.version}

Showcase

Properties

Stepper

Stepper.Content

Installation

Via NPM

Add the dependency to your consumer app like "@purpurds/purpur": "x.y.z"

In MyApp.tsx

import "@purpurds/purpur/styles";

In MyComponent.tsx

The user of this stepper has to provide a handler for when a step has been clicked. This handler will be called with the index of the step. The consumer then has to set which step is current and send it back to the Stepper. The Stepper also takes two labels. The scrollButtonLabels is for explaining the scroll buttons that are visible when there is horizontal overflow when displaying the steps to screen readers. The completedStepLabel is for screen readers to read that a step is completed, the label is prepended to the step label.

Example of handler and content rendering.

import { Stepper } from "@purpurds/purpur";

const scrollLabels: ScrollButtonLabels = {
  leftScrollButtonText: "Scroll left",
  rightScrollButtonText: "Scroll right",
};

export const MyComponent = () => {
  const [currentStep, setCurrentStep] = useState<number>(0);

  return (
    <>
      <Stepper
        data-testid="stepper"
        variant="primary"
        scrollButtonLabels={scrollLabels}
        completedStepLabel="Completed step"
        currentStepIndex={currentStep}
        onStepChange={setCurrentStep}
      >
        <Stepper.Content finished label="Step 1">
          This is the content in step 1
        </Stepper.Content>
        <Stepper.Content label="Step 2">This is the content in step 2</Stepper.Content>
        <Stepper.Content disabled label="Step 3">
          This is the content in step 3
        </Stepper.Content>
      </Stepper>
    </>
  );
};
5.1.0

6 days ago

5.0.0

11 days ago

4.5.0

13 days ago

4.6.0

12 days ago

4.5.1

13 days ago

4.4.0

17 days ago

4.3.0

26 days ago

4.2.0

26 days ago

4.1.1

1 month ago

4.1.0

1 month ago

4.0.2

1 month ago

4.0.1

1 month ago

3.7.1

2 months ago

4.0.0

2 months ago

3.7.0

2 months ago

3.6.0

2 months ago

3.4.0

2 months ago