Skip to content

Commit f202d2a

Browse files
authored
Merge pull request #30100 from storybookjs/norbert/fix-confetti-bundling-alternative
Addon Onboarding: Use @neoconfetti/react as alternative
2 parents 441ad86 + 717e256 commit f202d2a

File tree

3 files changed

+21
-36
lines changed

3 files changed

+21
-36
lines changed

code/addons/onboarding/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
"prep": "jiti ../../../scripts/prepare/addon-bundle.ts"
4646
},
4747
"devDependencies": {
48+
"@neoconfetti/react": "^1.0.0",
4849
"@radix-ui/react-dialog": "^1.0.5",
4950
"@storybook/icons": "^1.2.12",
5051
"@storybook/react": "workspace:*",
5152
"framer-motion": "^11.0.3",
5253
"react": "^18.2.0",
53-
"react-confetti-boom": "^1.1.0",
5454
"react-dom": "^18.2.0",
5555
"react-joyride": "^2.8.2",
5656
"react-use-measure": "^2.1.1",
Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,34 @@
1-
import React, { type ComponentProps, useEffect } from 'react';
2-
import { useState } from 'react';
1+
import React, { type ComponentProps } from 'react';
32

43
import { styled } from 'storybook/internal/theming';
54

6-
import ReactConfetti from 'react-confetti-boom';
5+
import { Confetti as ReactConfetti } from '@neoconfetti/react';
76

87
const Wrapper = styled.div({
98
zIndex: 9999,
109
position: 'fixed',
1110
top: 0,
12-
left: 0,
13-
bottom: 0,
14-
right: 0,
11+
left: '50%',
12+
width: '50%',
13+
height: '100%',
1514
});
1615

17-
export function Confetti({
16+
export const Confetti = React.memo(function Confetti({
1817
timeToFade = 5000,
1918
colors = ['#CA90FF', '#FC521F', '#66BF3C', '#FF4785', '#FFAE00', '#1EA7FD'],
2019
...confettiProps
2120
}: ComponentProps<typeof ReactConfetti> & { timeToFade?: number }) {
22-
const [particleCount, setParticleCount] = useState(42);
23-
24-
useEffect(() => {
25-
const timeout = setTimeout(() => {
26-
setParticleCount(0);
27-
}, timeToFade);
28-
29-
return () => {
30-
clearTimeout(timeout);
31-
};
32-
}, [timeToFade]);
33-
3421
return (
3522
<Wrapper>
3623
<ReactConfetti
37-
mode="fall"
3824
colors={colors}
39-
shapeSize={14}
40-
particleCount={particleCount}
41-
fadeOutHeight={10}
25+
particleCount={200}
26+
duration={5000}
27+
stageHeight={window.innerHeight}
28+
stageWidth={window.innerWidth}
29+
destroyAfterDone
4230
{...confettiProps}
4331
/>
4432
</Wrapper>
4533
);
46-
}
34+
});

code/yarn.lock

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4118,6 +4118,13 @@ __metadata:
41184118
languageName: node
41194119
linkType: hard
41204120

4121+
"@neoconfetti/react@npm:^1.0.0":
4122+
version: 1.0.0
4123+
resolution: "@neoconfetti/react@npm:1.0.0"
4124+
checksum: 10c0/dfa487965b69f88b39562ccd910114cd68b00a90c7eb79cfb1a483c7ac717b720f9f095e5aea13cef8a9b9bea05533d380ddff5e44d3bc3f7dc4d5c66716765c
4125+
languageName: node
4126+
linkType: hard
4127+
41214128
"@next/env@npm:15.0.3, @next/env@npm:^15.0.3":
41224129
version: 15.0.3
41234130
resolution: "@next/env@npm:15.0.3"
@@ -5749,12 +5756,12 @@ __metadata:
57495756
version: 0.0.0-use.local
57505757
resolution: "@storybook/addon-onboarding@workspace:addons/onboarding"
57515758
dependencies:
5759+
"@neoconfetti/react": "npm:^1.0.0"
57525760
"@radix-ui/react-dialog": "npm:^1.0.5"
57535761
"@storybook/icons": "npm:^1.2.12"
57545762
"@storybook/react": "workspace:*"
57555763
framer-motion: "npm:^11.0.3"
57565764
react: "npm:^18.2.0"
5757-
react-confetti-boom: "npm:^1.1.0"
57585765
react-dom: "npm:^18.2.0"
57595766
react-joyride: "npm:^2.8.2"
57605767
react-use-measure: "npm:^2.1.1"
@@ -24227,16 +24234,6 @@ __metadata:
2422724234
languageName: node
2422824235
linkType: hard
2422924236

24230-
"react-confetti-boom@npm:^1.1.0":
24231-
version: 1.1.0
24232-
resolution: "react-confetti-boom@npm:1.1.0"
24233-
peerDependencies:
24234-
react: ">=16.8.0"
24235-
react-dom: ">=16.8.0"
24236-
checksum: 10c0/76faf3e5cc3284b7dc0297ab7189ff92bbf74379a9478096bc8c8d7b16a82badea74c2e57f7313cd2a55ccf3c8dc50d51165fbf00c9fee5b9ed241369812d686
24237-
languageName: node
24238-
linkType: hard
24239-
2424024237
"react-confetti@npm:^6.1.0":
2424124238
version: 6.1.0
2424224239
resolution: "react-confetti@npm:6.1.0"

0 commit comments

Comments
 (0)