From 1b2d734fd801d76ebd5a178087b5b6166d336c98 Mon Sep 17 00:00:00 2001
From: CheeseB <2489ckckck@naver.com>
Date: Thu, 28 Mar 2024 08:51:55 +0900
Subject: [PATCH 1/9] =?UTF-8?q?refactor:=20=EC=A4=91=EB=B3=B5=EB=90=9C=20a?=
=?UTF-8?q?dd=20=EC=95=84=EC=9D=B4=EC=BD=98=20=EC=82=AD=EC=A0=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/svgs/ic-add-disabled.svg | 5 -----
src/constants/images.ts | 4 ----
2 files changed, 9 deletions(-)
delete mode 100644 public/svgs/ic-add-disabled.svg
diff --git a/public/svgs/ic-add-disabled.svg b/public/svgs/ic-add-disabled.svg
deleted file mode 100644
index 260bf77e..00000000
--- a/public/svgs/ic-add-disabled.svg
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/src/constants/images.ts b/src/constants/images.ts
index 8a0b14c8..f40db581 100644
--- a/src/constants/images.ts
+++ b/src/constants/images.ts
@@ -119,10 +119,6 @@ export const SVGS = {
alt: '빼기 버튼',
},
},
- disabled: {
- url: '/svgs/ic-add-disabled.svg',
- alt: '비활성화된 버튼',
- },
more: {
url: '/svgs/ic-more.svg',
From cf14cf086c17fedb892b0a3e5a39ea436fce9bf3 Mon Sep 17 00:00:00 2001
From: CheeseB <2489ckckck@naver.com>
Date: Thu, 28 Mar 2024 08:52:27 +0900
Subject: [PATCH 2/9] =?UTF-8?q?rafactor:=20Operation=20=EB=B2=84=ED=8A=BC?=
=?UTF-8?q?=20=EC=95=84=EC=9D=B4=EC=BD=98=20=EC=88=98=EC=A0=95=20=EB=B0=8F?=
=?UTF-8?q?=20Hover=20=EC=A0=81=EC=9A=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../buttons/OperationButton.module.scss | 10 +++++--
.../commons/buttons/OperationButton.tsx | 27 ++++++++++++++-----
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/src/components/commons/buttons/OperationButton.module.scss b/src/components/commons/buttons/OperationButton.module.scss
index c48745b6..78c902ae 100644
--- a/src/components/commons/buttons/OperationButton.module.scss
+++ b/src/components/commons/buttons/OperationButton.module.scss
@@ -8,6 +8,11 @@
width: 4.8rem;
height: 4.8rem;
border-radius: 0.8rem;
+
+ &:disabled {
+ cursor: default;
+ background-color: $gray60;
+ }
}
.btn-operation {
@@ -15,9 +20,10 @@
@extend %btn-base;
background-color: $purple;
+ transition: $base-transition;
- &:disabled {
- background-color: $gray60;
+ &:hover:not(:disabled) {
+ background-color: $purple60;
}
}
diff --git a/src/components/commons/buttons/OperationButton.tsx b/src/components/commons/buttons/OperationButton.tsx
index 75035d02..c8ea08c6 100644
--- a/src/components/commons/buttons/OperationButton.tsx
+++ b/src/components/commons/buttons/OperationButton.tsx
@@ -6,6 +6,8 @@ import classNames from 'classnames/bind';
import { SVGS } from '@/constants';
+import useToggleButton from '@/hooks/useToggleButton';
+
import styles from './OperationButton.module.scss';
const cx = classNames.bind(styles);
@@ -17,17 +19,28 @@ type OperationButtonProps = {
};
export const OperationButton = ({ type, isDisabled, onClick }: OperationButtonProps) => {
- const buttonType = type === 'add' && isDisabled ? 'disabled' : type;
- let icon = SVGS.button.disabled;
+ const { isVisible: isHovering, handleToggleClick: toggleHovering } = useToggleButton();
+
+ const isButtonActive = (type === 'add' && !isDisabled) || isHovering;
+
+ const { default: defaultButton, active: activeButton } = SVGS.button[type];
+ const { url, alt } = isButtonActive ? activeButton : defaultButton;
- if (buttonType !== 'disabled') {
- icon = SVGS.button[buttonType].active;
- }
+ const handleToggleHovering = () => {
+ if (isDisabled) return;
- const { url, alt } = icon;
+ toggleHovering();
+ };
return (
-