Skip to content

Commit 7b87c56

Browse files
stephl3shaneezagithub-actions[bot]TheSonOfThomp
authored
refactor(vertical-stepper): move vertical stepper package from private to leafygreen-ui (#3165)
* LG-4333: VerticalStepper (#163) * wip * wip, transitions * image * break out step icon component * tabindex * line color * fix story * status to state * padding * style cleanup * style updates * consts * add tests * README * changeset * types and tests * cleanup * cleanup * lint * cleanup again * some feedback * update icon styles * inert and tabindex * use descedants * remove extra div * update package.json * pass isCompleted to StepIcon * cleanup * feedback * Version Packages (#169) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Fix naming of lg-private packages (#183) * Fix lg-private packages naming * Changeset * LG-4395: feature walls major release (#186) * LG-4395: vertical stepper design QA * LG-4395: feature walls design QA * Changeset * Version Packages (#184) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Use actions slot prop for vertical stepper and activation steps (#191) * VerticalStepper takes actions prop instead of primaryButtonProps and secondaryButtonProps * ActivationSteps uses updated VerticalStepper API * Changeset * Address feedback * Version Packages (#190) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * LG-4412: all sections render in card UI (#194) * Update Section styling and add optional renderInCard prop * FeatureOverview renders in card, handles children container, and removes custom storybook decorator * Templates always renders in card and export type Template * UseCases always renders in card * ActivationSteps type updates and remove storybook decorator * Export types for ActivationStep, Template, and UseCase * Changeset * LG-4413: vertical stepper always renders description and media (#195) * VerticalStepper always renders description and media * Changeset * Cleanup * Version Packages (#197) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * LG-4670: feature walls component resizing (#294) * Update vertical stepper button layout on smaller breakpoints * Fix resizing in AccordionPanel * Fix resizing in ExpandableGrid * Feedback * height is always available * Version Packages (#292) * Version Packages * Version next @lg-private/vertical-stepper and update changelogs --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Stephen Lee <[email protected]> * Updates Popover/Menu/Tooltip to TopLayer LG-4746 (#337) * bump other packages * major popover updates * bump provider * bump global provider * bump cli * rm popoverZIndex * Create forty-days-rest.md * Delete .eslintignore * update lg to latest major * Removes prop-types, and bump LG packages * lint * Update .eslintrc.js * update storybook @lg-tools/storybook-utils * lint * Version Packages (#343) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * PNPM + Storybook 8 (private) (#426) * pnpm import * Delete yarn.lock * workflows * yarn -> pnpm docs * workspace:^ * add missing global packages * @storybook/test * story ts fixes * Adds missing peers * rm lg.json * bump base lg * fix product icon builds * fix sb * bump peer deps * rm pnpm/action-setup@v4 * Revert "rm pnpm/action-setup@v4" This reverts commit 14198eb258e958ddaa0e480fee17cfddec5ce6fd. * Update pnpm-lock.yaml * apk * apk all * wget * restore pnpm * specific pnpm action * workspace * lint fix * tools @ latest * minor lint errors * tools build dev deps * typescript * tsconfig * package exports * ts fixes * Create rollup.config.mjs * lint * checkout main src * ts fixes * lint * isolated async tests * Update CloudNav.analytics.spec.tsx * skip mongonav tests * feature walls tests * Create rollup.config.mjs * lint fix * Update pr.yml * Update release.yml * cache/restore * chromatic + pnpm * update cache restore paths * cache save path * addon 0.5.2-next.0 * addon 0.5.2-next.2 * chore(vertical-stepper): move from @lg-private to @leafygreen-ui scope * chore(vertical-stepper): disable snapshot of LiveExample story --------- Co-authored-by: Shaneeza <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Thompson <[email protected]>
1 parent a366ec0 commit 7b87c56

32 files changed

+1444
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ import Button from '@leafygreen-ui/button';
141141
| [@leafygreen-ui/toolbar](./packages/toolbar) | [![version](https://img.shields.io/npm/v/@leafygreen-ui/toolbar)](https://www.npmjs.com/package/@leafygreen-ui/toolbar) | ![downloads](https://img.shields.io/npm/dm/@leafygreen-ui/toolbar?color=white) | [Live Example](http://mongodb.design/component/toolbar/live-example) |
142142
| [@leafygreen-ui/tooltip](./packages/tooltip) | [![version](https://img.shields.io/npm/v/@leafygreen-ui/tooltip)](https://www.npmjs.com/package/@leafygreen-ui/tooltip) | ![downloads](https://img.shields.io/npm/dm/@leafygreen-ui/tooltip?color=white) | [Live Example](http://mongodb.design/component/tooltip/live-example) |
143143
| [@leafygreen-ui/typography](./packages/typography) | [![version](https://img.shields.io/npm/v/@leafygreen-ui/typography)](https://www.npmjs.com/package/@leafygreen-ui/typography) | ![downloads](https://img.shields.io/npm/dm/@leafygreen-ui/typography?color=white) | [Live Example](http://mongodb.design/component/typography/live-example) |
144+
| [@leafygreen-ui/vertical-stepper](./packages/vertical-stepper) | [![version](https://img.shields.io/npm/v/@leafygreen-ui/vertical-stepper)](https://www.npmjs.com/package/@leafygreen-ui/vertical-stepper) | ![downloads](https://img.shields.io/npm/dm/@leafygreen-ui/vertical-stepper?color=white) | [Live Example](http://mongodb.design/component/vertical-stepper/live-example) |
144145
| [@lg-charts/chart-card](./charts/chart-card) | [![version](https://img.shields.io/npm/v/@lg-charts/chart-card)](https://www.npmjs.com/package/@lg-charts/chart-card) | ![downloads](https://img.shields.io/npm/dm/@lg-charts/chart-card?color=white) | [Live Example](http://mongodb.design/component/chart-card/live-example) |
145146
| [@lg-charts/colors](./charts/colors) | [![version](https://img.shields.io/npm/v/@lg-charts/colors)](https://www.npmjs.com/package/@lg-charts/colors) | ![downloads](https://img.shields.io/npm/dm/@lg-charts/colors?color=white) | [Live Example](http://mongodb.design/component/colors/live-example) |
146147
| [@lg-charts/core](./charts/core) | [![version](https://img.shields.io/npm/v/@lg-charts/core)](https://www.npmjs.com/package/@lg-charts/core) | ![downloads](https://img.shields.io/npm/dm/@lg-charts/core?color=white) | [Live Example](http://mongodb.design/component/core/live-example) |
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# @leafygreen-ui/vertical-stepper
2+
3+
## 3.0.0
4+
5+
### Major Changes
6+
7+
- **Package has been renamed and moved!** This package is now published under the `@leafygreen-ui` scope. All dependencies and import paths must be updated from `@lg-private/vertical-stepper` to `@leafygreen-ui/vertical-stepper`.
8+
9+
### Major Changes
10+
11+
- c9203f7: Removes `prop-types`. Updates LG core packages to latest
12+
13+
## 2.1.1
14+
15+
### Patch Changes
16+
17+
- 066c4ce: [LG-4670](https://jira.mongodb.org/browse/LG-4670): vertically stack buttons in `VerticalStepActions` on smaller breakpoints
18+
19+
## 2.1.0
20+
21+
### Minor Changes
22+
23+
- dcab77e: [LG-4413](https://jira.mongodb.org/browse/LG-4413): VerticalStepper steps always render description and media regardless of current step
24+
25+
## 2.0.0
26+
27+
### Major Changes
28+
29+
- a3f1aa9: Replaces `primaryButtonProps` and `secondaryButtonProps` with `actions` prop to enable more flexibility for CTAs in each step
30+
31+
## 1.1.0
32+
33+
### Minor Changes
34+
35+
- f78419b: [LG-4395](https://jira.mongodb.org/browse/LG-4395): Fixes buttons sizes from default to small
36+
37+
### Patch Changes
38+
39+
- 8f076fb: Fixes naming of lg private packages from `@leafygreen-ui/*` to `@lg-private/*`
40+
41+
## 1.0.0
42+
43+
### Major Changes
44+
45+
- d50a214: First major release of `VerticalStepper`. [LG-4333](https://jira.mongodb.org/browse/LG-4333)
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Vertical Stepper
2+
3+
![npm (scoped)](https://img.shields.io/npm/v/@leafygreen-ui/vertical-stepper.svg)
4+
5+
#### [View on MongoDB.design](https://www.mongodb.design/component/vertical-stepper/example/)
6+
7+
## Installation
8+
9+
### Yarn
10+
11+
```shell
12+
yarn add @leafygreen-ui/vertical-stepper
13+
```
14+
15+
### NPM
16+
17+
```shell
18+
npm install @leafygreen-ui/vertical-stepper
19+
```
20+
21+
## Example
22+
23+
```js
24+
import Button, { Size, Variant } from `@leafygreen-ui/button`;
25+
import { VerticalStepper, VerticalStep } from `@leafygreen-ui/vertical-stepper`;
26+
27+
const [currentStep, setCurrentStep] = useState(0);
28+
29+
<VerticalStepper currentStep={currentStep}>
30+
<VerticalStep
31+
title="first step"
32+
description={
33+
<>
34+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
35+
efficitur nunc mattis magna pretium, id mattis metus vestibulum. Integer
36+
cursus ex ante, ut molestie lorem vestibulum id.{' '}
37+
<Link href="https://www.mongodb.design/">Im a link</Link>
38+
</>
39+
}
40+
actions={
41+
<Button
42+
onClick={() => setCurrentStep(step => step + 1)}
43+
size={Size.Small}
44+
>
45+
primary button
46+
</Button>
47+
}
48+
/>
49+
<VerticalStep
50+
title="second step"
51+
description="In eleifend, ante eget rhoncus dignissim, ex ex interdum arcu, quis commodo erat lectus non felis. Nulla malesuada dui non consectetur placerat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos."
52+
actions={
53+
<>
54+
<Button
55+
onClick={() => setCurrentStep(step => step - 1)}
56+
size={Size.Small}
57+
>
58+
secondary button
59+
</Button>
60+
<Button
61+
onClick={() => setCurrentStep(step => step + 1)}
62+
size={Size.Small}
63+
variant={Variant.Primary}
64+
>
65+
primary button
66+
</Button>
67+
</>
68+
}
69+
media={<img alt="test" src="https://placehold.co/170x85" />}
70+
/>
71+
<VerticalStep
72+
title="third step"
73+
description="In eleifend, ante eget rhoncus dignissim, ex ex interdum arcu, quis commodo erat lectus non felis. Nulla malesuada dui non consectetur placerat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In eleifend, ante eget rhoncus dignissim, ex ex interdum arcu, quis commodo erat lectus non felis. Nulla malesuada dui non consectetur placerat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In eleifend, ante eget rhoncus dignissim, ex ex interdum arcu, quis commodo erat lectus non felis."
74+
actions={
75+
<>
76+
<Button
77+
onClick={() => setCurrentStep(step => step - 1)}
78+
size={Size.Small}
79+
>
80+
secondary button
81+
</Button>
82+
<Button
83+
onClick={() => setCurrentStep(step => step + 1)}
84+
size={Size.Small}
85+
variant={Variant.Primary}
86+
>
87+
primary button
88+
</Button>
89+
</>
90+
}
91+
media={<img alt="test" src="https://placehold.co/170x100" />}
92+
/>
93+
</VerticalStepper>;
94+
```
95+
96+
## Properties
97+
98+
### `<VerticalStepper />`
99+
100+
| Prop | Type | Description | Default |
101+
| ----------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
102+
| darkMode | `boolean` | Determines if the component renders in dark mode | `false` |
103+
| currentStep | `number` | Zero-based. The index of the current step that will appear active. All steps will be marked as completed if the currentStep equals the number of steps. | `0` |
104+
| children | `string` | Two or more `<VerticalStep/>` components | |
105+
106+
### `<VerticalStep />`
107+
108+
| Prop | Type | Description | Default |
109+
| ----------- | ----------------- | --------------------------------------------------------------- | ------- |
110+
| title | `string` | The title of the step. | |
111+
| description | `React.ReactNode` | The description of the step. This will render below the title. | |
112+
| media | `React.ReactNode` | The image to the right of the text. E.g. `<img />` or `<svg />` | |
113+
| actions | `React.ReactNode` | Optional buttons that will render below the text. | |
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "@leafygreen-ui/vertical-stepper",
3+
"version": "3.0.0",
4+
"description": "LeafyGreen UI Kit Vertical Stepper",
5+
"main": "./dist/umd/index.js",
6+
"module": "./dist/esm/index.js",
7+
"types": "./dist/types/index.d.ts",
8+
"exports": {
9+
".": {
10+
"require": "./dist/umd/index.js",
11+
"import": "./dist/esm/index.js",
12+
"types": "./dist/types/index.d.ts"
13+
}
14+
},
15+
"license": "Apache-2.0",
16+
"scripts": {
17+
"build": "lg build-package",
18+
"tsc": "lg build-ts",
19+
"docs": "lg build-tsdoc"
20+
},
21+
"publishConfig": {
22+
"access": "public"
23+
},
24+
"dependencies": {
25+
"@leafygreen-ui/button": "workspace:^",
26+
"@leafygreen-ui/descendants": "workspace:^",
27+
"@leafygreen-ui/emotion": "workspace:^",
28+
"@leafygreen-ui/icon": "workspace:^",
29+
"@leafygreen-ui/lib": "workspace:^",
30+
"@leafygreen-ui/palette": "workspace:^",
31+
"@leafygreen-ui/tokens": "workspace:^",
32+
"@leafygreen-ui/typography": "workspace:^"
33+
},
34+
"peerDependencies": {
35+
"@leafygreen-ui/leafygreen-provider": "workspace:^"
36+
},
37+
"devDependencies": {
38+
"@lg-tools/build": "workspace:^",
39+
"@lg-tools/storybook-utils": "workspace:^"
40+
},
41+
"homepage": "https://github.com/10gen/leafygreen-ui/tree/main/packages/vertical-stepper",
42+
"repository": {
43+
"type": "git",
44+
"url": "https://github.com/10gen/leafygreen-ui"
45+
},
46+
"bugs": {
47+
"url": "https://jira.mongodb.org/projects/PD/summary"
48+
}
49+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { css } from '@leafygreen-ui/emotion';
2+
import { createUniqueClassName, Theme } from '@leafygreen-ui/lib';
3+
import { palette } from '@leafygreen-ui/palette';
4+
import { transitionDuration } from '@leafygreen-ui/tokens';
5+
6+
import { State } from '../VerticalStep/VerticalStep.types';
7+
8+
export const stepIconClassName = createUniqueClassName('step');
9+
10+
const STEP_SIZE = 20;
11+
12+
export const getStepWrapperStyles = (isCompleted: boolean) => css`
13+
position: relative;
14+
15+
&::after {
16+
background: ${isCompleted ? palette.green.dark1 : palette.gray.base};
17+
position: absolute;
18+
width: 1px;
19+
height: calc(100% - ${STEP_SIZE}px);
20+
left: 50%;
21+
transition: background ${transitionDuration.default}ms ease;
22+
}
23+
`;
24+
25+
export const stepStyles = css`
26+
border-radius: 50%;
27+
display: flex;
28+
align-items: center;
29+
justify-content: center;
30+
border: 1px solid;
31+
transition: ${transitionDuration.default}ms ease;
32+
width: ${STEP_SIZE}px;
33+
height: ${STEP_SIZE}px;
34+
position: relative;
35+
font-size: 12px;
36+
font-weight: 500;
37+
`;
38+
39+
export const themedStateColor = {
40+
[Theme.Dark]: {
41+
[State.Future]: palette.gray.light1,
42+
[State.Completed]: palette.black,
43+
[State.Current]: palette.green.base,
44+
},
45+
[Theme.Light]: {
46+
[State.Future]: palette.gray.dark1,
47+
[State.Completed]: palette.white,
48+
[State.Current]: palette.green.dark2,
49+
},
50+
};
51+
52+
export const themedStateBgColor = {
53+
[Theme.Dark]: {
54+
[State.Future]: 'rgba(255, 255, 255, 0)',
55+
[State.Completed]: palette.green.base,
56+
[State.Current]: 'rgba(255, 255, 255, 0)',
57+
},
58+
[Theme.Light]: {
59+
[State.Future]: 'rgba(255, 255, 255, 0)',
60+
[State.Completed]: palette.green.dark1,
61+
[State.Current]: 'rgba(255, 255, 255, 0)',
62+
},
63+
};
64+
65+
export const themedStateBorderColor = {
66+
[Theme.Dark]: {
67+
[State.Future]: palette.gray.light1,
68+
[State.Completed]: palette.green.base,
69+
[State.Current]: palette.green.base,
70+
},
71+
[Theme.Light]: {
72+
[State.Future]: palette.gray.base,
73+
[State.Completed]: palette.green.dark1,
74+
[State.Current]: palette.green.dark1,
75+
},
76+
};
77+
78+
export const getThemedStateStyles = (theme: Theme, state: State) => css`
79+
color: ${themedStateColor[theme][state]};
80+
background-color: ${themedStateBgColor[theme][state]};
81+
border-color: ${themedStateBorderColor[theme][state]};
82+
`;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
3+
import { cx } from '@leafygreen-ui/emotion';
4+
import CheckmarkIcon from '@leafygreen-ui/icon/dist/Checkmark';
5+
import { useDarkMode } from '@leafygreen-ui/leafygreen-provider';
6+
7+
import {
8+
getStepWrapperStyles,
9+
getThemedStateStyles,
10+
stepIconClassName,
11+
stepStyles,
12+
} from './StepIcon.styles';
13+
import { StepIconProps } from './StepIcon.types';
14+
15+
/**
16+
*
17+
* @internal
18+
*/
19+
export const StepIcon = ({ isCompleted, state, index }: StepIconProps) => {
20+
const { theme } = useDarkMode();
21+
22+
return (
23+
<div className={cx(stepIconClassName, getStepWrapperStyles(isCompleted))}>
24+
<div className={cx(stepStyles, getThemedStateStyles(theme, state))}>
25+
{isCompleted ? <CheckmarkIcon /> : index + 1}
26+
</div>
27+
</div>
28+
);
29+
};
30+
31+
StepIcon.displayName = 'StepIcon';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { InternalVerticalStepProps } from '../VerticalStep';
2+
3+
export type StepIconProps = Pick<
4+
InternalVerticalStepProps,
5+
'index' | 'state'
6+
> & {
7+
/**
8+
* Whether the step is completed
9+
*/
10+
isCompleted: boolean;
11+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { StepIcon } from './StepIcon';
2+
export { stepIconClassName } from './StepIcon.styles';

0 commit comments

Comments
 (0)