Skip to content

Commit

Permalink
Design: framer motion 으로 plate 토글 버튼 아이콘 애니메이션 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
cdm1263 committed Jan 16, 2024
1 parent 1ff2f42 commit dd3211f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/plate/FilterPlates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const FilterPlates = () => {
</motion.div>
)}
</AnimatePresence>
<PlateHideButton setIsOpen={setIsOpen} />
<PlateHideButton isOpen={isOpen} setIsOpen={setIsOpen} />
</div>
);
};
Expand Down
13 changes: 13 additions & 0 deletions src/components/plate/Plate.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,17 @@
border-right: 15px solid transparent;
border-top: 24px solid #000;
width: 111px;

div {
position: absolute;
left: 0;
right: 0;
top: -18px;
margin: auto;
scale: 1.5;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
}
}
21 changes: 18 additions & 3 deletions src/components/plate/PlateHideButton.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
import styles from './Plate.module.scss';

import { IoChevronUp } from '@react-icons/all-files/io5/IoChevronUp';
import { motion } from 'framer-motion';
interface PlateHideButtonProp {
isOpen: boolean;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
}

const PlateHideButton = ({ setIsOpen }: PlateHideButtonProp) => {
const PlateHideButton = ({ isOpen, setIsOpen }: PlateHideButtonProp) => {
const variant = {
open: { rotate: 0 },
close: { rotate: 180 },
};

return (
<button
onClick={() => {
setIsOpen((prev) => !prev);
}}
className={styles.hide_button}
></button>
>
<motion.div
variants={variant}
animate={isOpen ? 'open' : 'close'}
transition={{ duration: 0.4 }}
>
<IoChevronUp />
</motion.div>
</button>
);
};

Expand Down

0 comments on commit dd3211f

Please sign in to comment.