Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docs-landing): confetti position #469

Merged
merged 4 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions apps/docs/content/landing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const MyComponent = () => {
showPassword: !values.showPassword
});
};

const handleMouseDownPassword = (event) => {
event.preventDefault();
};
Expand Down Expand Up @@ -296,7 +296,7 @@ const darkTheme = createTheme({
}
})

// 3. Apply dark theme
// 3. Apply dark theme
// Entry point of your app
const App = () => {
return (
Expand All @@ -315,12 +315,10 @@ import confetti from 'canvas-confetti';
const CustomButton = () => {
const handleConfetti = () => {
confetti({
zIndex: 999,
particleCount: 100,
spread: 70,
origin: { x: 0.75, y: 0.8 }
// confetti options...
});
};

return (
<Button
auto
Expand Down Expand Up @@ -411,6 +409,6 @@ export default CustomButton;
WebkitBackgroundClip: value,
backgroundClip: value
}),

}`
};
20 changes: 17 additions & 3 deletions apps/docs/src/components/templates/custom-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,35 @@ import { Button } from '@nextui-org/react';
import confetti from 'canvas-confetti';

const CustomButton = () => {
const handleConfetti = () => {
const handleConfetti = (
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
) => {
const { currentTarget } = event;
const { innerWidth, innerHeight } = event.view as Window;
const {
y: targetY,
x: targetX,
width: targetWidth
} = currentTarget.getBoundingClientRect();
const targetCenterX = targetX + targetWidth / 2;
confetti({
zIndex: 999,
particleCount: 100,
spread: 70,
origin: { x: 0.75, y: 0.8 }
origin: {
y: targetY / innerHeight,
x: targetCenterX / innerWidth
}
});
};

return (
<Button
auto
rounded
ripple={false}
size="xl"
onClick={handleConfetti}
onClick={(event) => handleConfetti(event)}
tianenpang marked this conversation as resolved.
Show resolved Hide resolved
css={{
background: '$white',
fontWeight: '$semibold',
Expand Down