Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f1da308
rm step wrapper
TheSonOfThomp Oct 22, 2025
1c67385
rm descendants dep
TheSonOfThomp Oct 22, 2025
79c4d84
export WizardProvider
TheSonOfThomp Oct 22, 2025
aab32ab
delete-wizard-demo
TheSonOfThomp Nov 4, 2025
b8758f4
Update pnpm
TheSonOfThomp Nov 7, 2025
7757e2a
fix wizard changes
TheSonOfThomp Nov 14, 2025
aef3a30
Adds `requiresAcknowledgement` prop to Wizard.Step
TheSonOfThomp Nov 21, 2025
76920c5
Implements `isAcknowledged` state inside provider
TheSonOfThomp Nov 21, 2025
674a76b
rm delete demo
TheSonOfThomp Nov 21, 2025
9c33bd0
rm temp changesets
TheSonOfThomp Nov 21, 2025
84b4317
footer tests
TheSonOfThomp Nov 21, 2025
d7c0135
revert toast changes?
TheSonOfThomp Nov 21, 2025
2879a58
Update .npmrc
TheSonOfThomp Nov 21, 2025
954b44e
adds `totalSteps` to wizard context
TheSonOfThomp Nov 24, 2025
59dc8f1
fix bad merge
TheSonOfThomp Nov 24, 2025
1a5f046
adds LGIDs
TheSonOfThomp Nov 21, 2025
b65d792
lint
TheSonOfThomp Nov 21, 2025
2100c5b
fix bad merge
TheSonOfThomp Nov 24, 2025
2ace0b5
removes Step test utils
TheSonOfThomp Nov 24, 2025
3ee6b63
add layout comments
TheSonOfThomp Nov 24, 2025
2be7f1d
Squashed commit of the following:
TheSonOfThomp Nov 25, 2025
4cbc815
update provider props
TheSonOfThomp Nov 21, 2025
b3de848
add templates scope
TheSonOfThomp Nov 20, 2025
d918251
init delete wizard
TheSonOfThomp Nov 19, 2025
2a5fb7f
initial port of delete wizard
TheSonOfThomp Nov 20, 2025
ce5d1f0
adds DeleteWizardStepContents
TheSonOfThomp Nov 20, 2025
ccb74db
Exports DeleteWizard . Header and Step wrappers
TheSonOfThomp Nov 21, 2025
43ff5eb
Create delete-wizard-3.md
TheSonOfThomp Nov 21, 2025
c6c09c6
updates delete-wizard changeset
TheSonOfThomp Nov 21, 2025
ed43e5b
rm temp changesets
TheSonOfThomp Nov 21, 2025
c7a1cfe
build
TheSonOfThomp Nov 21, 2025
2ebe1cb
Update README.md
TheSonOfThomp Nov 21, 2025
d4579b1
lint
TheSonOfThomp Nov 21, 2025
a6a7da9
Adds onCancel/onDelete handlers
TheSonOfThomp Nov 24, 2025
973a365
rm DeleteWizardStepContent
TheSonOfThomp Nov 24, 2025
3160611
fixes dependencies
TheSonOfThomp Nov 25, 2025
c9ba506
fixes dependencies
TheSonOfThomp Nov 26, 2025
9f3b30d
adds lgids and test utils
TheSonOfThomp Nov 26, 2025
51228b9
creates delete wizard tests
TheSonOfThomp Nov 26, 2025
5f74d60
add stories
TheSonOfThomp Nov 26, 2025
306b717
Squashed commit of the following:
TheSonOfThomp Nov 26, 2025
36ae864
reset versions
TheSonOfThomp Nov 26, 2025
7853e5b
mv to @lg-ui
TheSonOfThomp Dec 1, 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
64 changes: 64 additions & 0 deletions .changeset/delete-wizard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
'@lg-templates/delete-wizard': minor
---

Initial release of `DeleteWizard`.

```tsx
<DeleteWizard
onStepChange={...}
onCancel={...}
onDelete={...}
>
<DeleteWizard.Header
pageTitle="Demo Delete Wizard"
/>
<DeleteWizard.Step requiresAcknowledgement>
<DeleteWizard.StepContent>
<div>Step 1 contents<div>
</DeleteWizard.StepContent>
<DeleteWizard.Footer
backButtonText="Go back"
cancelButtonText="Cancel flow"
primaryButtonText='Continue to next step'
/>
</DeleteWizard.Step>

<DeleteWizard.Step requiresAcknowledgement>
<DeleteWizard.StepContent>
<div>Step 2 contents<div>
</DeleteWizard.StepContent>
<DeleteWizard.Footer
backButtonText="Go back"
cancelButtonText="Cancel flow"
primaryButtonText='Delete my thing'
/>
</DeleteWizard.Step>
</DeleteWizard>
```

### DeleteWizard
Establishes a context, and only renders the `activeStep` (managed internally, or provided with the `activeStep` prop). Accepts a `DeleteWizard.Header` and any number of `DeleteWizard.Step`s as children.

`DeleteWizard` and all sub-components include template styling.

### DeleteWizard.Header
A convenience wrapper around `CanvasHeader`

### DeleteWizard.Step
A convenience wrapper around `Wizard.Step` to ensure the correct context.
Like the basic `Wizard.Step`, of `requiresAcknowledgement` is true, the step must have `isAcknowledged` set in context, (or passed in as a controlled prop) for the Footer's primary button to be enabled. (see the Wizard and DeleteWizard demos in Storybook)


### DeleteWizard.StepContent
A styled `div` for use inside a `DeleteWizard.Step` to ensure proper page scrolling and footer positioning

### DeleteWizard.Footer
A wrapper around `Wizard.Footer` with embedded styles and convenience props for the DeleteWizard template.
`DeleteWizard.Footer` accepts optional `backButtonText`, `cancelButtonText` and `primaryButtonText` props for simpler wizard creation.
The primary button variant is defined based on the `activeStep`— `"danger"` for the final steps, and `"primary"` for all preceding steps.
Also defines the `leftGlyph` to <TrashIcon /> for the final step.

You can override this behavior by providing the button props object (see FormFooter).

Use the top level `onDelete`, `onCancel` and `onStepChange` callbacks to handle footer button clicks.
2 changes: 1 addition & 1 deletion .changeset/wizard.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

Initial Wizard package release.

See [README.md](./README.md) for usage guidelines
See [README.md](./README.md) for usage guidelines
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"link": "lg link",
"lint": "lg lint",
"prepublishOnly": "pnpm run build && pnpm build:ts-downlevel && pnpm build:docs",
"publish": "pnpm changeset publish --public",
"publish": "pnpm publish -r",
"reset:react17": "npx node ./scripts/react17/reset.mjs; pnpm run init",
"slackbot": "lg slackbot",
"start": "npx storybook dev -p 9001 --no-version-updates --no-open",
Expand Down
80 changes: 80 additions & 0 deletions packages/delete-wizard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Delete Wizard

![npm (scoped)](https://img.shields.io/npm/v/@leafygreen-ui/delete-wizard.svg)

#### [View on MongoDB.design](https://www.mongodb.design/component/delete-wizard/live-example/)

## Installation

### PNPM

```shell
pnpm add @leafygreen-ui/delete-wizard
```

### Yarn

```shell
yarn add @leafygreen-ui/delete-wizard
```

### NPM

```shell
npm install @leafygreen-ui/delete-wizard
```

```tsx
<DeleteWizard>
<DeleteWizard.Header
pageTitle="Demo Delete Wizard"
/>
<DeleteWizard.Step requiresAcknowledgement>
<DeleteWizard.StepContent>
<div>Step 1 contents<div>
</DeleteWizard.StepContent>
<DeleteWizard.Footer
primaryButtonProps={{
children: 'Continue to next step',
}}
/>
</DeleteWizard.Step>

<DeleteWizard.Step requiresAcknowledgement>
<DeleteWizard.StepContent>
<div>Step 2 contents<div>
</DeleteWizard.StepContent>
<DeleteWizard.Footer
primaryButtonProps={{
leftGlyph: <TrashIcon />,
variant: 'danger',
children: 'Delete my thing',
onClick: handleDelete,
}}
/>
</DeleteWizard.Step>
</DeleteWizard>
```

### DeleteWizard

Establishes a context, and only renders the `activeStep` (managed internally, or provided with the `activeStep` prop). Accepts a `DeleteWizard.Header` and any number of `DeleteWizard.Step`s as children.

`DeleteWizard` and all sub-components include template styling.

### DeleteWizard.Header

A convenience wrapper around `CanvasHeader`

### DeleteWizard.Step

A convenience wrapper around `Wizard.Step` to ensure the correct context.
Like the basic `Wizard.Step`, of `requiresAcknowledgement` is true, the step must have `isAcknowledged` set in context, (or passed in as a controlled prop) for the Footer's primary button to be enabled. (see the Wizard and DeleteWizard demos in Storybook)

### DeleteWizard.StepContent

A styled `div` for use inside a `DeleteWizard.Step` to ensure proper page scrolling and footer positioning

### DeleteWizard.Footer

A wrapper around Wizard.Footer with embedded styles for the DeleteWizard template
52 changes: 52 additions & 0 deletions packages/delete-wizard/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "@leafygreen-ui/delete-wizard",
"version": "0.0.1",
"description": "LeafyGreen UI Kit Delete Wizard",
"main": "./dist/umd/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"license": "Apache-2.0",
"exports": {
".": {
"require": "./dist/umd/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts"
},
"./testing": {
"require": "./dist/umd/testing/index.js",
"import": "./dist/esm/testing/index.js",
"types": "./dist/types/testing/index.d.ts"
}
},
"scripts": {
"build": "lg-build bundle",
"tsc": "lg-build tsc",
"docs": "lg-build docs"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@leafygreen-ui/canvas-header": "workspace:^",
"@leafygreen-ui/compound-component": "workspace:^",
"@leafygreen-ui/emotion": "workspace:^",
"@leafygreen-ui/form-footer": "workspace:^",
"@leafygreen-ui/icon": "workspace:^",
"@leafygreen-ui/lib": "workspace:^",
"@leafygreen-ui/tokens": "workspace:^",
"@leafygreen-ui/wizard": "workspace:^",
"@lg-tools/test-harnesses": "workspace:^"
},
"homepage": "https://github.com/mongodb/leafygreen-ui/tree/main/packages/delete-wizard",
"repository": {
"type": "git",
"url": "https://github.com/mongodb/leafygreen-ui"
},
"bugs": {
"url": "https://jira.mongodb.org/projects/LG/summary"
},
"devDependencies": {
"@faker-js/faker": "^10.1.0",
"@leafygreen-ui/typography": "workspace:^"
}
}
144 changes: 144 additions & 0 deletions packages/delete-wizard/src/DeleteWizard.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/* eslint-disable no-console */
import React from 'react';
import { faker } from '@faker-js/faker';
import { StoryObj } from '@storybook/react';
import { userEvent, within } from '@storybook/test';

import { css } from '@leafygreen-ui/emotion';
import BeakerIcon from '@leafygreen-ui/icon/Beaker';
import { BackLink, Body } from '@leafygreen-ui/typography';

import { ExampleStepContent } from './testUtils/ExampleStepContent';
import { DeleteWizard } from '.';

faker.seed(0);
const demoResourceName = faker.database.mongodbObjectId();
const demoSteps = [
{
description: faker.lorem.paragraph(),
content: faker.lorem.paragraphs(24),
},
{
description: faker.lorem.paragraph(),
content: faker.lorem.paragraphs(24),
},
];

export default {
title: 'Templates/DeleteWizard',
component: DeleteWizard,
};

export const LiveExample: StoryObj<typeof DeleteWizard> = {
parameters: {
controls: {
exclude: ['children', 'onStepChange'],
},
chromatic: {
disableSnapshot: true,
},
},
args: {
activeStep: undefined,
},
render: args => {
const handleCancel = () => {
console.log('[STORYBOOK]: Cancelling wizard. Reloading iFrame');
window.location.reload();
};

const handleDelete = () => {
alert('[STORYBOOK]: Deleting thing!');
console.log('[STORYBOOK]: Deleting thing! Reloading iFrame');
window.location.reload();
};

const handleStepChange = step => {
console.log('[STORYBOOK] step changed to ', step);
};

return (
<div
className={css`
margin: -100px;
`}
>
<DeleteWizard
activeStep={args.activeStep}
onStepChange={handleStepChange}
onCancel={handleCancel}
onDelete={handleDelete}
className={css`
height: 100vh;
width: 100vw;
`}
>
<DeleteWizard.Header
pageTitle="Demo Delete Wizard"
resourceName={demoResourceName}
resourceIcon={<BeakerIcon />}
backLink={<BackLink href="#">Back</BackLink>}
className={css`
margin-inline: 72px;
`}
/>
<DeleteWizard.Step>
<ExampleStepContent
index={0}
description={demoSteps[0].description}
content={demoSteps[0].content.split('\n').map((p, i) => (
<Body key={i}>{p}</Body>
))}
/>
<DeleteWizard.Footer
cancelButtonText="Cancel wizard"
primaryButtonText="Continue to next step"
/>
</DeleteWizard.Step>

<DeleteWizard.Step requiresAcknowledgement>
<ExampleStepContent
index={1}
description={demoSteps[1].description}
content={demoSteps[1].content.split('\n').map((p, i) => (
<Body key={i}>{p}</Body>
))}
/>
<DeleteWizard.Footer
backButtonText="Go back"
cancelButtonText="Cancel wizard"
primaryButtonText="Delete the thing"
/>
</DeleteWizard.Step>
</DeleteWizard>
</div>
);
},
};

export const Step1: StoryObj<typeof DeleteWizard> = {
args: {
activeStep: 0,
},
render: LiveExample.render,
};

export const Step2Default: StoryObj<typeof DeleteWizard> = {
args: {
activeStep: 1,
},
render: LiveExample.render,
};

export const Step2Acknowledged: StoryObj<typeof DeleteWizard> = {
args: {
activeStep: 1,
},
play: ({ canvasElement }) => {
const checkbox = within(canvasElement).getByTestId(
'acknowledgement-checkbox',
);
userEvent.click(checkbox);
},
render: LiveExample.render,
};
Loading
Loading