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 all commits
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
14 changes: 5 additions & 9 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 @@ -314,13 +314,9 @@ import confetti from 'canvas-confetti';

const CustomButton = () => {
const handleConfetti = () => {
confetti({
zIndex: 999,
particleCount: 100,
spread: 70,
origin: { x: 0.75, y: 0.8 }
});
confetti({...});
};

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

}`
};
18 changes: 16 additions & 2 deletions apps/docs/src/components/templates/custom-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ 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 { clientWidth, clientHeight } = document.documentElement;
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 / clientHeight,
x: targetCenterX / clientWidth
}
});
};

return (
<Button
auto
Expand Down
7 changes: 1 addition & 6 deletions apps/docs/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ class MyDocument extends Document {

return {
...initialProps,
styles: [
<>
{initialProps.styles}
{styledJSXStyles}
</>
]
styles: React.Children.toArray([initialProps.styles, styledJSXStyles])
};
}
render() {
Expand Down