fix: eye toggle dark theme

This commit is contained in:
Mahyar Khanbolooki
2025-08-21 17:24:49 +03:30
parent 1bc9bc1a68
commit d11c11b3b6
+58 -42
View File
@@ -1,11 +1,14 @@
import { motion, Variants } from "framer-motion"; import { motion, Variants } from 'framer-motion'
import React from "react"; import React from 'react'
type EyeToggleIconProps = { type EyeToggleIconProps = {
slash: boolean; slash: boolean
} & React.SVGProps<SVGSVGElement>; } & React.SVGProps<SVGSVGElement>
export const EyeToggleIcon: React.FC<EyeToggleIconProps> = ({ slash, ...props }) => { export const EyeToggleIcon: React.FC<EyeToggleIconProps> = ({
slash,
...props
}) => {
const slashVariants: Variants = { const slashVariants: Variants = {
enter: { enter: {
pathLength: 1, pathLength: 1,
@@ -13,8 +16,8 @@ export const EyeToggleIcon: React.FC<EyeToggleIconProps> = ({ slash, ...props })
pathOffset: 0, pathOffset: 0,
transition: { transition: {
pathOffset: { duration: 0 }, pathOffset: { duration: 0 },
pathLength: { duration: 0.3, ease: "easeInOut" }, pathLength: { duration: 0.3, ease: 'easeInOut' },
opacity: { duration: 0.2, ease: "easeInOut", delay: 0 } opacity: { duration: 0.2, ease: 'easeInOut', delay: 0 }
} }
}, },
exit: { exit: {
@@ -23,69 +26,82 @@ export const EyeToggleIcon: React.FC<EyeToggleIconProps> = ({ slash, ...props })
pathOffset: 2, pathOffset: 2,
transition: { transition: {
pathOffset: { duration: 0 }, pathOffset: { duration: 0 },
pathLength: { duration: 0.3, ease: "easeInOut" }, pathLength: { duration: 0.3, ease: 'easeInOut' },
opacity: { duration: 0.2, ease: "easeInOut", delay: .1 } opacity: { duration: 0.2, ease: 'easeInOut', delay: 0.1 }
}
} }
},
} }
return ( return (
<svg <svg
width="20" width='20'
height="20" height='20'
viewBox="0 0 20 20" viewBox='0 0 20 20'
fill="none" fill='none'
xmlns="http://www.w3.org/2000/svg" xmlns='http://www.w3.org/2000/svg'
{...props} {...props}
> >
<defs> <defs>
<filter id="whiteShadow" x="-50%" y="-50%" width="200%" height="200%" colorInterpolationFilters="sRGB" > <filter
<feDropShadow dx="1.5" dy="0" stdDeviation="0" floodColor="white" floodOpacity="1" /> id='whiteShadow'
x='-50%'
y='-50%'
width='200%'
height='200%'
colorInterpolationFilters='sRGB'
>
<feDropShadow
dx='1.5'
dy='0'
stdDeviation='0'
floodColor='white'
floodOpacity='1'
/>
</filter> </filter>
</defs> </defs>
{/* Eye Circle */} {/* Eye Circle */}
<path <path
d="M12.9833 9.99994C12.9833 11.6499 11.6499 12.9833 9.99994 12.9833C8.34993 12.9833 7.0166 11.6499 7.0166 9.99994C7.0166 8.34993 8.34993 7.0166 9.99994 7.0166C11.6499 7.0166 12.9833 8.34993 12.9833 9.99994Z" d='M12.9833 9.99994C12.9833 11.6499 11.6499 12.9833 9.99994 12.9833C8.34993 12.9833 7.0166 11.6499 7.0166 9.99994C7.0166 8.34993 8.34993 7.0166 9.99994 7.0166C11.6499 7.0166 12.9833 8.34993 12.9833 9.99994Z'
stroke="currentColor" stroke='currentColor'
strokeWidth="1.2" strokeWidth='1.2'
strokeLinecap="round" strokeLinecap='round'
strokeLinejoin="round" strokeLinejoin='round'
/> />
{/* Eye Outline */} {/* Eye Outline */}
<path <path
d="M10.0001 16.8918C12.9418 16.8918 15.6834 15.1584 17.5918 12.1584C18.3418 10.9834 18.3418 9.00843 17.5918 7.83343C15.6834 4.83343 12.9418 3.1001 10.0001 3.1001C7.05845 3.1001 4.31678 4.83343 2.40845 7.83343C1.65845 9.00843 1.65845 10.9834 2.40845 12.1584C4.31678 15.1584 7.05845 16.8918 10.0001 16.8918Z" d='M10.0001 16.8918C12.9418 16.8918 15.6834 15.1584 17.5918 12.1584C18.3418 10.9834 18.3418 9.00843 17.5918 7.83343C15.6834 4.83343 12.9418 3.1001 10.0001 3.1001C7.05845 3.1001 4.31678 4.83343 2.40845 7.83343C1.65845 9.00843 1.65845 10.9834 2.40845 12.1584C4.31678 15.1584 7.05845 16.8918 10.0001 16.8918Z'
stroke="currentColor" stroke='currentColor'
strokeWidth="1.2" strokeWidth='1.2'
strokeLinecap="round" strokeLinecap='round'
strokeLinejoin="round" strokeLinejoin='round'
/> />
{/* Slash Line - Animate with Framer Motion */} {/* Slash Line - Animate with Framer Motion */}
<motion.path <motion.path
d="M19.6 1.66675L1.66699 19.6" d='M19.6 1.66675L1.66699 19.6'
stroke="currentColor" stroke='currentColor'
className='dark:stroke-container' className='stroke-container'
strokeWidth="1.2" strokeWidth='1.2'
strokeLinecap="round" strokeLinecap='round'
strokeLinejoin="round" strokeLinejoin='round'
initial={false} initial={false}
animate={{ strokeWidth: slash ? 0 : 2, opacity: slash ? 0 : 1 }} animate={{ strokeWidth: slash ? 0 : 2, opacity: slash ? 0 : 1 }}
transition={{ transition={{
strokeWidth: { duration: 0.2, ease: "easeInOut" }, strokeWidth: { duration: 0.2, ease: 'easeInOut' },
opacity: { duration: 0.1, ease: "easeInOut", delay: slash ? 0.1 : 0 } opacity: { duration: 0.1, ease: 'easeInOut', delay: slash ? 0.1 : 0 }
}} }}
/> />
<motion.path <motion.path
d="M18.3332 1.66675L1.66699 18.3334" d='M18.3332 1.66675L1.66699 18.3334'
stroke="currentColor" stroke='currentColor'
strokeWidth="1.2" strokeWidth='1.2'
strokeLinecap="round" strokeLinecap='round'
strokeLinejoin="round" strokeLinejoin='round'
initial={false} initial={false}
variants={slashVariants} variants={slashVariants}
animate={slash ? 'exit' : 'enter'} animate={slash ? 'exit' : 'enter'}
/> />
</svg> </svg>
); )
}; }