Skip to content

Commit

Permalink
[FE][Fix] : ButtonState로 구체화
Browse files Browse the repository at this point in the history
  • Loading branch information
leedongyull committed Nov 13, 2024
1 parent 4a0192d commit b667d1a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ export const App = () => (
<Route path="/add-channel/:user/draw" element={<DrawRoute />} />
<Route path="/channel/:channelId/*" element={<ChannelRoutes />} />
</Routes>
);
);
14 changes: 7 additions & 7 deletions frontend/src/component/common/FloatingButton/FloatingButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import React, { useState } from 'react';
import { ButtonType } from '../enums';
import { ButtonState } from '../enums';
import { IconType, ToolCategory } from '../types';

/**
Expand All @@ -13,7 +13,7 @@ import { IconType, ToolCategory } from '../types';
* )
*/
export const FloatingButton = () => {
const [toolType, setToolType] = useState<ButtonType>(ButtonType.CLOSE);
const [toolType, setToolType] = useState<ButtonState>(ButtonState.CLOSE);
const [isMenuOpen, setIsMenuOpen] = useState<boolean>(false);

/**
Expand All @@ -23,18 +23,18 @@ export const FloatingButton = () => {
const toggleMenu = () => {
setIsMenuOpen(prev => !prev);
if (!isMenuOpen) {
setToolType(ButtonType.OPEN);
setToolType(ButtonState.OPEN);
} else {
setToolType(ButtonType.CLOSE);
setToolType(ButtonState.CLOSE);
}
};

/**
* @remarks
* 툴을 선택하고 메뉴를 닫는 함수입니다.
* @param {ButtonType} type - 선택된 툴 타입
* @param {ButtonState} type - 선택된 툴 타입
*/
const handleMenuClick = (type: ButtonType) => {
const handleMenuClick = (type: ButtonState) => {
setToolType(type);
setIsMenuOpen(!isMenuOpen);
};
Expand Down Expand Up @@ -86,7 +86,7 @@ export const FloatingButton = () => {
'shadow-none': !isMenuOpen,
},
)}
style={{ bottom: toolType === ButtonType.OPEN ? `${48 * index + 64}px` : '0px' }}
style={{ bottom: toolType === ButtonState.OPEN ? `${48 * index + 64}px` : '0px' }}
>
<div className={classNames('flex', 'items-center')}>
{React.createElement(icon, { className: 'w-5 h-5' })}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/component/common/enums.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @remarks
* ButtonType Enum은 버튼이 가질 수 있는 모든 종류를 정의합니다.
* ButtonState Enum은 버튼이 가질 수 있는 모든 종류를 정의합니다.
* @example
* const buttonType = ButtonType.OPEN;
* const buttonState = ButtonState.OPEN;
*/
export enum ButtonType {
export enum ButtonState {
CLOSE = 'CLOSE', // 메뉴 닫기 버튼
OPEN = 'OPEN', // 메뉴 열기 버튼
START_MARKER = 'START_MARKER', // 출발지 설정 버튼
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/component/common/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FaPaintBrush } from 'react-icons/fa';
import { HiLocationMarker, HiOutlineDotsHorizontal, HiOutlineLocationMarker } from 'react-icons/hi';
import { SlLayers } from 'react-icons/sl';
import { ButtonType } from './enums';
import { ButtonState } from './enums';

/**
* IconType 객체는 각 버튼 타입에 해당하는 아이콘 컴포넌트를 매핑합니다.
* @type {Record<ButtonType, React.ComponentType>}
* @type {Record<ButtonState, React.ComponentType>}
*/
export const IconType = {
CLOSE: SlLayers, // 닫기 버튼 아이콘
Expand All @@ -25,17 +25,17 @@ export const IconType = {
*/
export const ToolCategory = [
{
type: ButtonType.LINE_DRAWING, // 경로 그리기 툴
type: ButtonState.LINE_DRAWING, // 경로 그리기 툴
description: '경로 그리기', // 툴 설명
icon: IconType.LINE_DRAWING, // 툴 아이콘
},
{
type: ButtonType.START_MARKER, // 출발지 설정 툴
type: ButtonState.START_MARKER, // 출발지 설정 툴
description: '출발지 설정', // 툴 설명
icon: IconType.START_MARKER, // 툴 아이콘
},
{
type: ButtonType.DESTINATION_MARKER, // 도착지 설정 툴
type: ButtonState.DESTINATION_MARKER, // 도착지 설정 툴
description: '도착지 설정', // 툴 설명
icon: IconType.DESTINATION_MARKER, // 툴 아이콘
},
Expand Down

0 comments on commit b667d1a

Please sign in to comment.