Skip to content

Commit 17f470b

Browse files
committed
chore: add custom step index in playground
1 parent 3879949 commit 17f470b

File tree

5 files changed

+83
-9
lines changed

5 files changed

+83
-9
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { styled } from 'goober';
22
import * as React from 'react';
33

4-
import { useWizard } from '../../dist';
5-
import { Button } from '../modules/common';
4+
import { useWizard } from '../../../dist';
5+
import { Button } from '../../modules/common';
66

7-
const Actions = styled('div')`
7+
export const Actions = styled('div')`
88
display: flex;
99
justify-content: center;
1010
margin: 1rem 0;
1111
gap: 1rem;
1212
flex-direction: row;
1313
`;
1414

15-
const Info = styled('div')`
15+
export const Info = styled('div')`
1616
display: flex;
1717
justify-content: center;
1818
flex-direction: column;
@@ -32,7 +32,7 @@ const Info = styled('div')`
3232
}
3333
`;
3434

35-
const Footer: React.FC = React.memo(() => {
35+
const Footer: React.FC = () => {
3636
const {
3737
nextStep,
3838
previousStep,
@@ -57,20 +57,20 @@ const Footer: React.FC = React.memo(() => {
5757
<Actions>
5858
<Button
5959
label="Previous"
60-
onClick={previousStep}
60+
onClick={() => previousStep()}
6161
disabled={isLoading || isFirstStep}
6262
>
6363
Previous
6464
</Button>
6565
<Button
6666
label="Next"
67-
onClick={nextStep}
67+
onClick={() => nextStep()}
6868
disabled={isLoading || isLastStep}
6969
/>
7070
</Actions>
7171
</code>
7272
</>
7373
);
74-
});
74+
};
7575

7676
export default Footer;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import * as React from 'react';
2+
3+
import { useWizard } from '../../../dist';
4+
import { Button } from '../../modules/common';
5+
import { Actions, Info } from './footer';
6+
7+
const FooterCustomStepIndex: React.FC = () => {
8+
const {
9+
nextStep,
10+
previousStep,
11+
isLoading,
12+
activeStep,
13+
isLastStep,
14+
isFirstStep,
15+
} = useWizard();
16+
17+
return (
18+
<>
19+
<code>
20+
<Info>
21+
<p>Has previous step: {!isFirstStep ? '✅' : '⛔'}</p>
22+
<br />
23+
<p>Has next step: {!isLastStep ? '✅' : '⛔'} </p>
24+
<br />
25+
<p>
26+
Active step: {activeStep + 1} <br />
27+
</p>
28+
</Info>
29+
<Actions>
30+
<Button
31+
label="Previous"
32+
onClick={() => previousStep()}
33+
disabled={isLoading || isFirstStep}
34+
>
35+
Previous
36+
</Button>
37+
<Button
38+
label="Next"
39+
onClick={() => nextStep(2)}
40+
disabled={isLoading || isLastStep}
41+
/>
42+
</Actions>
43+
</code>
44+
</>
45+
);
46+
};
47+
48+
export default FooterCustomStepIndex;

playground/components/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export { default as Step } from './step';
22
export { default as AsyncStep } from './asyncStep';
3-
export { default as Footer } from './footer';
3+
export { default as Footer } from './footer/footer';
4+
export { default as FooterStepIndex } from './footer/footerStepIndex';
45
export { default as AnimatedStep } from './animatedStep';
56
export { default as Tooltip } from './tooltip';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as React from 'react';
2+
3+
import { Wizard } from '../../../../dist';
4+
import { AsyncStep, FooterStepIndex, Step } from '../../../components';
5+
import Section from '../../common/section';
6+
7+
const CustomNextStepIndex: React.FC = () => {
8+
return (
9+
<Section
10+
title="Custom step index"
11+
description="With custom step index on next step"
12+
>
13+
<Wizard footer={<FooterStepIndex />}>
14+
<AsyncStep number={1} />
15+
<Step number={2} />
16+
<AsyncStep number={3} />
17+
<Step number={4} />
18+
</Wizard>
19+
</Section>
20+
);
21+
};
22+
23+
export default CustomNextStepIndex;

playground/modules/wizard/wizard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { styled } from 'goober';
22
import * as React from 'react';
33

44
import AnimatedSection from './animated';
5+
import CustomNextStepIndex from './customNextStepIndex';
56
import ReactQuerySection from './reactQuery';
67
import SimpleSection from './simple';
78

@@ -17,6 +18,7 @@ const WizardModule = () => {
1718
<SimpleSection />
1819
<AnimatedSection />
1920
<ReactQuerySection />
21+
<CustomNextStepIndex />
2022
</Container>
2123
);
2224
};

0 commit comments

Comments
 (0)