mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 20:42:34 +10:00
add reducedMotion check, center menu items
This commit is contained in:
@ -4,7 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "PORT=3001 next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint"
|
"lint": "next lint"
|
||||||
@ -36,4 +36,4 @@
|
|||||||
"@types/react": "18.2.18",
|
"@types/react": "18.2.18",
|
||||||
"@types/react-dom": "18.2.7"
|
"@types/react-dom": "18.2.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,3 +1,7 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
import { Menu, X } from 'lucide-react';
|
import { Menu, X } from 'lucide-react';
|
||||||
|
|
||||||
import { Button } from '@documenso/ui/primitives/button';
|
import { Button } from '@documenso/ui/primitives/button';
|
||||||
@ -8,6 +12,14 @@ export interface HamburgerMenuProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const HamburgerMenu = ({ isMenuOpen, menuToggle }: HamburgerMenuProps) => {
|
export const HamburgerMenu = ({ isMenuOpen, menuToggle }: HamburgerMenuProps) => {
|
||||||
|
useEffect(() => {
|
||||||
|
// Update document.body.style.overflow based on the menu state
|
||||||
|
// and check that the window width is less than 768px
|
||||||
|
// if (window.innerWidth < 768) {
|
||||||
|
// document.body.style.overflow = isMenuOpen ? 'hidden' : 'auto';
|
||||||
|
// }
|
||||||
|
}, [isMenuOpen]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex md:hidden">
|
<div className="flex md:hidden">
|
||||||
<Button variant="default" className="z-20 w-10 p-0" onClick={menuToggle}>
|
<Button variant="default" className="z-20 w-10 p-0" onClick={menuToggle}>
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
|
|
||||||
import { Variants, motion } from 'framer-motion';
|
import { Variants, motion, useReducedMotion } from 'framer-motion';
|
||||||
import { Github, Slack, Twitter } from 'lucide-react';
|
import { Github, Slack, Twitter } from 'lucide-react';
|
||||||
|
|
||||||
import { cn } from '@documenso/ui/lib/utils';
|
import { cn } from '@documenso/ui/lib/utils';
|
||||||
@ -15,23 +15,25 @@ export type MobileNavigationProps = {
|
|||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const itemVariants: Variants = {
|
|
||||||
open: {
|
|
||||||
opacity: 1,
|
|
||||||
y: 0,
|
|
||||||
x: 0,
|
|
||||||
transition: { type: 'spring', stiffness: 300, damping: 24 },
|
|
||||||
},
|
|
||||||
closed: { opacity: 0, y: 0, x: 60, transition: { duration: 0.2 } },
|
|
||||||
exit: {
|
|
||||||
opacity: 0,
|
|
||||||
y: 0,
|
|
||||||
x: 60,
|
|
||||||
transition: { duration: 0.2 },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export const MobileNavigation = ({ isMenuOpen }: MobileNavigationProps) => {
|
export const MobileNavigation = ({ isMenuOpen }: MobileNavigationProps) => {
|
||||||
|
const shouldReduceMotion = useReducedMotion();
|
||||||
|
|
||||||
|
const itemVariants: Variants = {
|
||||||
|
open: {
|
||||||
|
opacity: 1,
|
||||||
|
y: 0,
|
||||||
|
x: 0,
|
||||||
|
transition: { type: 'spring', stiffness: 300, damping: 24 },
|
||||||
|
},
|
||||||
|
closed: { opacity: 0, y: 0, x: shouldReduceMotion ? 0 : 60, transition: { duration: 0.2 } },
|
||||||
|
exit: {
|
||||||
|
opacity: 0,
|
||||||
|
y: 0,
|
||||||
|
x: shouldReduceMotion ? 0 : 60,
|
||||||
|
transition: { duration: 0.2 },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
// used for testing alternate animations
|
// used for testing alternate animations
|
||||||
// const vertical = `${!isMenuOpen ? '-translate-y-full' : 'translate-y-0'}`;
|
// const vertical = `${!isMenuOpen ? '-translate-y-full' : 'translate-y-0'}`;
|
||||||
const horizontal = `${!isMenuOpen ? 'translate-x-full' : 'translate-x-0'}`;
|
const horizontal = `${!isMenuOpen ? 'translate-x-full' : 'translate-x-0'}`;
|
||||||
@ -41,46 +43,46 @@ export const MobileNavigation = ({ isMenuOpen }: MobileNavigationProps) => {
|
|||||||
animate={isMenuOpen ? 'open' : 'closed'}
|
animate={isMenuOpen ? 'open' : 'closed'}
|
||||||
className={cn(
|
className={cn(
|
||||||
horizontal,
|
horizontal,
|
||||||
'bg-secondary fixed left-0 right-0 top-16 z-10 flex h-[94dvh] w-full transform flex-col items-start justify-start gap-4 shadow-md backdrop-blur-lg transition duration-500 ease-in-out md:hidden',
|
'bg-secondary fixed left-0 right-0 top-16 z-10 flex h-[94dvh] w-full transform flex-col items-center justify-start gap-4 shadow-md backdrop-blur-lg transition duration-500 ease-in-out md:hidden',
|
||||||
)}
|
)}
|
||||||
variants={{
|
variants={{
|
||||||
open: {
|
open: {
|
||||||
transition: {
|
transition: {
|
||||||
type: 'spring',
|
type: 'spring',
|
||||||
bounce: 0,
|
bounce: 0,
|
||||||
duration: 0.7,
|
duration: shouldReduceMotion ? 0 : 0.7,
|
||||||
delayChildren: 0.3,
|
delayChildren: shouldReduceMotion ? 0 : 0.3,
|
||||||
staggerChildren: 0.05,
|
staggerChildren: shouldReduceMotion ? 0 : 0.05,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
closed: {
|
closed: {
|
||||||
transition: {
|
transition: {
|
||||||
type: 'spring',
|
type: 'spring',
|
||||||
bounce: 0,
|
bounce: 0,
|
||||||
duration: 0.3,
|
duration: shouldReduceMotion ? 0 : 0.3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
exit: {
|
exit: {
|
||||||
transition: {
|
transition: {
|
||||||
type: 'spring',
|
type: 'spring',
|
||||||
bounce: 0,
|
bounce: 0,
|
||||||
duration: 0.3,
|
duration: shouldReduceMotion ? 0 : 0.3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<motion.div className="flex w-full flex-col items-start gap-y-2 px-8 pt-12">
|
<motion.div className="flex w-full flex-col items-center gap-y-2 px-8 pt-12">
|
||||||
<Link
|
<Link
|
||||||
passHref
|
passHref
|
||||||
href="/blog"
|
href="/blog"
|
||||||
className="text-4xl font-semibold text-[#8D8D8D] hover:text-[#6D6D6D]"
|
className="text-4xl font-semibold text-[#6D6D6D] hover:text-[#6D6D6D]"
|
||||||
>
|
>
|
||||||
<motion.p variants={itemVariants}>Blog</motion.p>
|
<motion.p variants={itemVariants}>Blog</motion.p>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
href="/pricing"
|
href="/pricing"
|
||||||
className="text-4xl font-semibold text-[#8D8D8D] hover:text-[#6D6D6D]"
|
className="text-4xl font-semibold text-[#6D6D6D] hover:text-[#6D6D6D]"
|
||||||
>
|
>
|
||||||
<motion.p variants={itemVariants}>Pricing</motion.p>
|
<motion.p variants={itemVariants}>Pricing</motion.p>
|
||||||
</Link>
|
</Link>
|
||||||
@ -88,21 +90,21 @@ export const MobileNavigation = ({ isMenuOpen }: MobileNavigationProps) => {
|
|||||||
<Link
|
<Link
|
||||||
href="https://status.documenso.com"
|
href="https://status.documenso.com"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
className="text-4xl font-semibold text-[#8D8D8D] hover:text-[#6D6D6D]"
|
className="text-4xl font-semibold text-[#6D6D6D] hover:text-[#6D6D6D]"
|
||||||
>
|
>
|
||||||
<motion.p variants={itemVariants}>Status</motion.p>
|
<motion.p variants={itemVariants}>Status</motion.p>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
href="mailto:support@documenso.com"
|
href="mailto:support@documenso.com"
|
||||||
className="text-4xl font-semibold text-[#8D8D8D] hover:text-[#6D6D6D]"
|
className="text-4xl font-semibold text-[#6D6D6D] hover:text-[#6D6D6D]"
|
||||||
>
|
>
|
||||||
<motion.p variants={itemVariants}>Support</motion.p>
|
<motion.p variants={itemVariants}>Support</motion.p>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
href="/privacy"
|
href="/privacy"
|
||||||
className="text-4xl font-semibold text-[#8D8D8D] hover:text-[#6D6D6D]"
|
className="text-4xl font-semibold text-[#6D6D6D] hover:text-[#6D6D6D]"
|
||||||
>
|
>
|
||||||
<motion.p variants={itemVariants}>Privacy</motion.p>
|
<motion.p variants={itemVariants}>Privacy</motion.p>
|
||||||
</Link>
|
</Link>
|
||||||
@ -110,7 +112,7 @@ export const MobileNavigation = ({ isMenuOpen }: MobileNavigationProps) => {
|
|||||||
<Link
|
<Link
|
||||||
href="https://app.documenso.com/login"
|
href="https://app.documenso.com/login"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
className="text-4xl font-semibold text-[#8D8D8D] hover:text-[#6D6D6D]"
|
className="text-4xl font-semibold text-[#6D6D6D] hover:text-[#6D6D6D]"
|
||||||
>
|
>
|
||||||
<motion.p variants={itemVariants}>Sign in</motion.p>
|
<motion.p variants={itemVariants}>Sign in</motion.p>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
Reference in New Issue
Block a user