-
Notifications
You must be signed in to change notification settings - Fork 79
[UXE-33] feat(Template) Creates DeleteWizard template package
#3291
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
Changes from all commits
2de5769
e453185
998c5af
2096173
95c816e
10532af
c6a94ec
b48488b
d8ab48d
c462dca
f1da308
1c67385
79c4d84
aab32ab
b8758f4
7757e2a
aef3a30
76920c5
674a76b
9c33bd0
84b4317
d7c0135
2879a58
954b44e
59dc8f1
1a5f046
b65d792
2100c5b
2ace0b5
3ee6b63
2be7f1d
4cbc815
b3de848
d918251
2a5fb7f
ce5d1f0
ccb74db
43ff5eb
c6c09c6
ed43e5b
c7a1cfe
2ebe1cb
d4579b1
a6a7da9
973a365
3160611
c9ba506
9f3b30d
51228b9
5f74d60
306b717
36ae864
7853e5b
8fd73fa
7bb0c88
65bb2f2
1c755b9
be041c6
2491b56
c8fced5
51ae066
c292340
4027791
9041932
dd3f071
bc1d02b
d3be0c0
08a1682
7c522e7
a0f87db
f4acd09
c36d1e7
6ea422c
7234f54
3c3abbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| --- | ||
| '@leafygreen-ui/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`, if `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. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@leafygreen-ui/wizard': patch | ||
| --- | ||
|
|
||
| Exports `WizardStepContext` & `WizardStepContextData` types |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,76 @@ | ||||||
| # Delete Wizard | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| #### [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> | ||||||
|
||||||
| <div>Step 1 contents<div> | |
| <div>Step 1 contents</div> |
| 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:^" | ||
| } | ||
| } |
| 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, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot where we landed on changeset voice. Did we want this much information in the changeset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In an initial changeset, I think this is appropriate