Skip to content

Commit c720769

Browse files
authored
Merge pull request #236 from dnd-side-project/feat/235
[FEAT] 버튼, 모달 애니메이션 추가
2 parents 798f59a + 026196b commit c720769

File tree

4 files changed

+52
-31
lines changed

4 files changed

+52
-31
lines changed

packages/ui/src/components/Button/Button.tsx

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,36 @@ export type ButtonProps = {
2121
variant?: ButtonVariant;
2222
} & ComponentProps<'button'>;
2323

24-
const buttonVariantMap = cva('relative flex justify-center items-center rounded-lg gap-1', {
25-
variants: {
26-
size: {
27-
sm: 'w-[101px] h-[38px]',
28-
md: 'w-[132px] h-11',
29-
lg: 'w-[343px] h-[52px]',
24+
const buttonVariantMap = cva(
25+
'relative flex justify-center items-center rounded-lg gap-1 active:scale-[0.97] transition-transform',
26+
{
27+
variants: {
28+
size: {
29+
sm: 'w-[101px] h-[38px]',
30+
md: 'w-[132px] h-11',
31+
lg: 'w-[343px] h-[52px]',
32+
},
33+
variant: {
34+
primary50:
35+
'bg-primary-50 text-primary-600 hover:bg-primary-100 disabled:bg-gray-400 disabled:text-gray-500',
36+
black: 'bg-gray-800 text-white hover:bg-black disabled:bg-gray-600 disabled:text-gray-400',
37+
gray100:
38+
'bg-gray-100 text-gray-600 hover:bg-gray-200 disabled:bg-gray-400 disabled:text-gray-500',
39+
primary500:
40+
'bg-primary-500 text-primary-50 hover:bg-primary-700 disabled:bg-gray-600 disabled:text-gray-400',
41+
gray200:
42+
'bg-gray-200 text-gray-600 hover:bg-gray-700 disabled:bg-gray-400 disabled:text-gray-500',
43+
},
3044
},
31-
variant: {
32-
primary50:
33-
'bg-primary-50 text-primary-600 hover:bg-primary-100 disabled:bg-gray-400 disabled:text-gray-500',
34-
black: 'bg-gray-800 text-white hover:bg-black disabled:bg-gray-600 disabled:text-gray-400',
35-
gray100:
36-
'bg-gray-100 text-gray-600 hover:bg-gray-200 disabled:bg-gray-400 disabled:text-gray-500',
37-
primary500:
38-
'bg-primary-500 text-primary-50 hover:bg-primary-700 disabled:bg-gray-600 disabled:text-gray-400',
39-
gray200:
40-
'bg-gray-200 text-gray-600 hover:bg-gray-700 disabled:bg-gray-400 disabled:text-gray-500',
41-
},
42-
},
43-
compoundVariants: [
44-
{
45-
variant: ['primary50', 'primary500'],
46-
size: 'lg',
47-
className: 'text-white',
48-
},
49-
],
50-
});
45+
compoundVariants: [
46+
{
47+
variant: ['primary50', 'primary500'],
48+
size: 'lg',
49+
className: 'text-white',
50+
},
51+
],
52+
}
53+
);
5154

5255
const buttonTextVariantMap = {
5356
sm: {

packages/ui/src/components/IconButton/IconButton.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ export const IconButton = ({
1010
...restProps
1111
}: PropsWithChildren<IconButtonProps>) => {
1212
return (
13-
<button className={cn('flex items-center justify-center', className)} {...restProps}>
13+
<button
14+
className={cn(
15+
'flex items-center justify-center transition-transform active:scale-[0.97]',
16+
className
17+
)}
18+
{...restProps}
19+
>
1420
{children}
1521
</button>
1622
);

packages/ui/src/components/Modal/Modal.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ComponentProps } from 'react';
33
import { motion } from 'motion/react';
44

55
import { cn } from '../../lib/core';
6-
import { FADE_IN_ANIMATION } from '../../lib/motions';
6+
import { FADE_IN_ANIMATION, SCALE_IN_ANIMATION } from '../../lib/motions';
77
import { Portal } from '../Portal';
88

99
import { Content } from './ModalContent';
@@ -66,9 +66,11 @@ export function Modal({
6666
className
6767
)}
6868
>
69-
<Content graphic={graphic} contentClassName={contentClassName}>
70-
{children}
71-
</Content>
69+
<motion.div variants={SCALE_IN_ANIMATION}>
70+
<Content graphic={graphic} contentClassName={contentClassName}>
71+
{children}
72+
</Content>
73+
</motion.div>
7274
</motion.div>
7375
</Portal>
7476
);

packages/ui/src/lib/motions.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,13 @@ export const SLIDE_IN_ANIMATION = {
1010
exit: { translateX: '100%' },
1111
transition: { type: 'tween', damping: 50 },
1212
};
13+
14+
export const SCALE_IN_ANIMATION = {
15+
initial: { scale: 0.95, opacity: 0 },
16+
animate: { scale: 1, opacity: 1 },
17+
exit: { scale: 0.95, opacity: 0 },
18+
transition: {
19+
duration: 0.2,
20+
ease: [0.39, 0.57, 0.56, 1],
21+
},
22+
};

0 commit comments

Comments
 (0)