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

website: Update Stepper documenation #1161

Merged
merged 11 commits into from
Mar 30, 2023
55 changes: 55 additions & 0 deletions apps/website/src/examples/Stepper.long.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { Button, Flex, Stepper } from '@itwin/itwinui-react';

const steps = [
{ name: 'First Step' },
{ name: 'Second Step' },
{ name: 'Third Step' },
{ name: 'Fourth Step' },
{ name: 'Fifth Step' },
{ name: 'Sixth Step' },
{ name: 'Last Step' },
];

export default () => {
const [currentStep, setCurrentStep] = React.useState(2);

return (
<Flex flexDirection='column' gap='m' style={{ minWidth: 'min(100%, 400px)' }}>
<Flex.Item alignSelf='stretch'>
<Stepper
currentStep={currentStep}
steps={steps}
onStepClick={(index: number) => {
setCurrentStep(index);
}}
type='long'
/>
</Flex.Item>

<Flex>
<Button
disabled={currentStep === 0}
onClick={() => {
if (currentStep !== 0) setCurrentStep(currentStep - 1);
}}
>
Previous
</Button>
<Button
styleType='cta'
disabled={currentStep === steps.length - 1}
onClick={() => {
if (currentStep < steps.length - 1) setCurrentStep(currentStep + 1);
}}
>
Next
</Button>
</Flex>
</Flex>
);
};
51 changes: 51 additions & 0 deletions apps/website/src/examples/Stepper.tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { Button, Flex, Stepper } from '@itwin/itwinui-react';

const steps = [
{ name: 'Completed Step', description: 'Completed Tooltip' },
{ name: 'Current Step', description: 'Current Tooltip' },
{ name: 'Next Step', description: 'Next Tooltip' },
{ name: 'Last Step', description: 'Last Tooltip' },
FlyersPh9 marked this conversation as resolved.
Show resolved Hide resolved
];

export default () => {
const [currentStep, setCurrentStep] = React.useState(2);
FlyersPh9 marked this conversation as resolved.
Show resolved Hide resolved

return (
<Flex flexDirection='column' gap='m' style={{ minWidth: 'min(100%, 400px)' }}>
<Flex.Item alignSelf='stretch'>
<Stepper
currentStep={currentStep}
steps={steps}
onStepClick={(index: number) => {
setCurrentStep(index);
}}
/>
</Flex.Item>

<Flex>
<Button
disabled={currentStep === 0}
onClick={() => {
if (currentStep !== 0) setCurrentStep(currentStep - 1);
}}
>
Previous
</Button>
<Button
styleType='cta'
disabled={currentStep === steps.length - 1}
onClick={() => {
if (currentStep < steps.length - 1) setCurrentStep(currentStep + 1);
}}
>
Next
</Button>
</Flex>
</Flex>
);
};
2 changes: 2 additions & 0 deletions apps/website/src/examples/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export { default as SideNavigationMainExample } from './SideNavigation.main';
export { default as SliderMainExample } from './Slider.main';

export { default as StepperMainExample } from './Stepper.main';
export { default as StepperLongExample } from './Stepper.long';
export { default as StepperTooltipExample } from './Stepper.tooltip';

export { default as SurfaceMainExample } from './Surface.main';
export { default as SurfaceCustomExample } from './Surface.custom';
Expand Down
33 changes: 30 additions & 3 deletions apps/website/src/pages/docs/stepper.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,46 @@ group: core

import PropsTable from '~/components/PropsTable.astro';
import LiveExample from '~/components/LiveExample.astro';
import Placeholder from '~/components/Placeholder.astro';
import * as AllExamples from '~/examples';

<p>{frontmatter.description}</p>

<Placeholder componentPageName='core-stepper' />

<LiveExample src='Stepper.main.tsx'>
<AllExamples.StepperMainExample client:load />
</LiveExample>

In defined, multi-step user interactions, it is useful to inform the user of the number of steps involved in the process, and the current step within that sequence. A UI 'Stepper' guides the user through the steps and provides some interaction to return to previous steps. A standard example of a Stepper would be an e-Commerce checkout process, but there are many others where the user must perform sequential steps.

## Variants

There are two different styles of stepper, depending on the amount of steps required to complete the process.

### Short Stepper

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should an example for a "short" stepper be shown here even if it's similar (if not identical) to the main example at the top of the page?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what would be best to do here, and this will likely pop up in future #961 PRs. I would like to hear @iTwin/itwinui thoughts on this.

If we don't get a clear direction from the comments, just do what you think is best and we can make sweeping changes once we make it to the end of documentation site content updates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the main example should be "the best version" of the component. The style of the stepper is defined by a prop and not automatically so I think we should have separate example of Short stepper just to say that this style is default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example for short stepper has been added

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do main and short example a bit more different? Maybe make short stepper to have only 3 steps or smth.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The short example now only has 3 steps and the step labels are different from the main example

The default "short" stepper example is suggested for processes with four (4) steps or less. Each step is named under the circle. This stepper is suggested if the step names can be summarized with very short labels. For example, instead of “Complete Billing Information”, simply use “Billing.”
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move usage guidelines to Usage section. You could also add example layout there.

Copy link
Contributor Author

@adamhock adamhock Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage guidelines have been moved to the usage section. The layout example is a WIP

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The layout example has been updated. I decided to go with a simpler layout than the screenshots provided, but there's a small bug I'm running into with inputs that I'm tackling

StepperLayoutExampleBug

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add state management for inputs.
Or leave it as is because it's not a complete example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need for state. you can fix the bug by using a different key for the different inputs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


The user may click on previous steps to go back. [Tooltips](tooltip) can also be implemented to give more information about a particular step.

Designers should confirm the display is acceptable due to the number of steps and labels at various resolutions. If text wrapping occurs or the stepper's visual quality decreases significantly when the window is re-sized, use the long stepper instead (see below).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review this paragraph - is kinda confusing to read it.
Also use links to sections and not (see below)

FlyersPh9 marked this conversation as resolved.
Show resolved Hide resolved

### Long Stepper

<LiveExample src='Stepper.long.tsx'>
gretanausedaite marked this conversation as resolved.
Show resolved Hide resolved
<AllExamples.StepperLongExample client:load />
</LiveExample>

The long stepper is suggested for processes with five or more steps or with steps that require longer labels (20 characters and over). There are no labels underneath the step indicators to save space. Instead, the label for the step currently in progress appears under the diagram along with ‘Step X of X’. This allocates more space for longer step names, as well as allowing more step indicators to be contained within the diagram.

gretanausedaite marked this conversation as resolved.
Show resolved Hide resolved
## Usage

### Tooltip

Additional (optional) information can be displayed within a tooltip when hovering over a step indicator.

<LiveExample src='Stepper.tooltip.tsx'>
<AllExamples.StepperTooltipExample client:load />
</LiveExample>

## Props

<PropsTable path={frontmatter.propsPath} />