Skip to content

Commit 4e72a37

Browse files
committed
rm DeleteWizardStepContent
1 parent ceaed93 commit 4e72a37

File tree

4 files changed

+58
-61
lines changed

4 files changed

+58
-61
lines changed

templates/delete-wizard/src/DeleteWizard.stories.tsx

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,36 +78,32 @@ export const LiveExample: StoryObj<typeof DeleteWizard> = {
7878
margin-inline: 72px;
7979
`}
8080
/>
81-
<DeleteWizard.Step requiresAcknowledgement>
82-
<DeleteWizard.StepContent>
83-
<ExampleStepContent
84-
index={0}
85-
description={demoSteps[0].description}
86-
content={demoSteps[0].content.split('\n').map((p, i) => (
87-
<Body key={i}>{p}</Body>
88-
))}
89-
/>
90-
</DeleteWizard.StepContent>
81+
<DeleteWizard.Step>
82+
<ExampleStepContent
83+
index={0}
84+
description={demoSteps[0].description}
85+
content={demoSteps[0].content.split('\n').map((p, i) => (
86+
<Body key={i}>{p}</Body>
87+
))}
88+
/>
9189
<DeleteWizard.Footer
9290
cancelButtonText="Cancel wizard"
9391
primaryButtonText="Continue to next step"
9492
/>
9593
</DeleteWizard.Step>
9694

9795
<DeleteWizard.Step requiresAcknowledgement>
98-
<DeleteWizard.StepContent>
99-
<ExampleStepContent
100-
index={1}
101-
description={demoSteps[1].description}
102-
content={demoSteps[1].content.split('\n').map((p, i) => (
103-
<Body key={i}>{p}</Body>
104-
))}
105-
/>
106-
</DeleteWizard.StepContent>
96+
<ExampleStepContent
97+
index={1}
98+
description={demoSteps[1].description}
99+
content={demoSteps[1].content.split('\n').map((p, i) => (
100+
<Body key={i}>{p}</Body>
101+
))}
102+
/>
107103
<DeleteWizard.Footer
108104
backButtonText="Go back"
109105
cancelButtonText="Cancel wizard"
110-
primaryButtonText="Delete the prop"
106+
primaryButtonText="Delete the thing"
111107
/>
112108
</DeleteWizard.Step>
113109
</DeleteWizard>

templates/delete-wizard/src/DeleteWizard/DeleteWizard.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { DeleteWizardContextProvider } from './DeleteWizardContext';
1414
import { DeleteWizardFooter } from './DeleteWizardFooter';
1515
import { DeleteWizardHeader } from './DeleteWizardHeader';
1616
import { DeleteWizardStep } from './DeleteWizardStep';
17-
import { DeleteWizardStepContent } from './DeleteWizardStepContents';
1817

1918
/**
2019
* The parent DeleteWizard component.
@@ -54,11 +53,6 @@ export const DeleteWizard = CompoundComponent(
5453
*/
5554
Step: DeleteWizardStep,
5655

57-
/**
58-
* A styled `div` for use inside a `DeleteWizard.Step` to ensure proper page scrolling and footer positioning
59-
*/
60-
StepContent: DeleteWizardStepContent,
61-
6256
/**
6357
* A wrapper around Wizard.Footer with embedded styles for the DeleteWizard template.
6458
* Render this inside of each Step with the relevant button props for that Step.

templates/delete-wizard/src/DeleteWizard/DeleteWizardStep.tsx

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,60 @@
1-
import React from 'react';
1+
import React, { ComponentProps } from 'react';
22

3-
import { CompoundSubComponent } from '@leafygreen-ui/compound-component';
3+
import {
4+
CompoundSubComponent,
5+
filterChildren,
6+
findChild,
7+
} from '@leafygreen-ui/compound-component';
8+
import { css, cx } from '@leafygreen-ui/emotion';
49
import {
510
useWizardStepContext,
611
Wizard,
712
WizardStepProps,
13+
WizardSubComponentProperties,
814
} from '@leafygreen-ui/wizard';
915

1016
import { DeleteWizardSubComponentKeys } from './compoundComponentProperties';
1117

1218
export const useDeleteWizardStepContext = useWizardStepContext;
1319

20+
export interface DeleteWizardStepProps
21+
extends WizardStepProps,
22+
ComponentProps<'div'> {}
1423
/**
1524
* A wrapper around Wizard.Step
1625
*/
1726
export const DeleteWizardStep = CompoundSubComponent(
18-
(props: WizardStepProps) => {
19-
return <Wizard.Step {...props} />;
27+
({
28+
children,
29+
className,
30+
requiresAcknowledgement,
31+
...rest
32+
}: DeleteWizardStepProps) => {
33+
const footerChild = findChild(
34+
children,
35+
WizardSubComponentProperties.Footer,
36+
);
37+
38+
const restChildren = filterChildren(children, [
39+
WizardSubComponentProperties.Footer,
40+
]);
41+
42+
return (
43+
<Wizard.Step requiresAcknowledgement={requiresAcknowledgement} {...rest}>
44+
<div
45+
className={cx(
46+
css`
47+
flex-grow: 1;
48+
`,
49+
className,
50+
)}
51+
{...rest}
52+
>
53+
{restChildren}
54+
</div>
55+
{footerChild}
56+
</Wizard.Step>
57+
);
2058
},
2159
{
2260
displayName: 'DeleteWizardStep',

templates/delete-wizard/src/DeleteWizard/DeleteWizardStepContents.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)