Skip to content

Commit

Permalink
Merge pull request #469 from tianenpang/fix/confetti-position
Browse files Browse the repository at this point in the history
fix(docs-landing): confetti position
  • Loading branch information
jrgarciadev committed May 13, 2022
2 parents 014e36e + 47fc75e commit 669e185
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
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

1 comment on commit 669e185

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for nextui-docs ready!

✅ Preview
https://nextui-docs-85qsllguz-nextui-org.vercel.app

Built with commit 669e185.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.