Skip to content

Commit

Permalink
feat: ChakraMotion 컴포넌트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
kangju2000 committed Oct 17, 2023
1 parent c3d6efb commit f625a7a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/components/ChakraMotion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { type ChakraProps, chakra, shouldForwardProp } from '@chakra-ui/react'
import { isValidMotionProp, motion, type MotionProps } from 'framer-motion'

import type { ComponentPropsWithoutRef } from 'react'

const ChakraMotion = <C extends React.ElementType>({
as,
children,
...props
}: ComponentPropsWithoutRef<C> & { as?: C } & MotionProps & Omit<ChakraProps, 'transition'>) => {
const Component = as || 'div'

const MotionComponent = chakra(motion(Component), {
shouldForwardProp: prop => isValidMotionProp(prop) || shouldForwardProp(prop),
})

return <MotionComponent {...props}>{children}</MotionComponent>
}

export default ChakraMotion

0 comments on commit f625a7a

Please sign in to comment.