Skip to content

Commit

Permalink
Refactor: onTouchEnd => onClick
Browse files Browse the repository at this point in the history
  • Loading branch information
cuconveniencestore authored and hookor committed Jun 1, 2024
1 parent b65024f commit 00b6f0b
Show file tree
Hide file tree
Showing 52 changed files with 106 additions and 125 deletions.
2 changes: 1 addition & 1 deletion src/components/coffee/LogInCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const LogInCTA = () => {
<Text className={Regular}>{logInCTA.text}</Text>
<Button
text={logInCTA.btn}
onTouchEnd={handleSignInBtn}
onClick={handleSignInBtn}
className={DefaultBtn}
/>
</Container>
Expand Down
9 changes: 1 addition & 8 deletions src/components/common/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { ButtonProps } from '@/types/types';

const Button = ({
value,
text,
onTouchEnd,
onClick,
className
}: ButtonProps) => {
const Button = ({ value, text, onClick, className }: ButtonProps) => {
return (
<button
value={value}
onTouchEnd={onTouchEnd}
onClick={onClick}
className={className}>
{text}
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/CTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const CTA = ({ text, actionText = '', btn = true, fn }: CTA) => {
<Button
className={cx(LoginBtn, BTN)}
text={actionText}
onTouchEnd={handleActions}
onClick={handleActions}
/>
)}
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/components/common/CoffeeOptionSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const CoffeeOptionSelection = () => {
};

// set coffee size info
const selectSize = (e: React.TouchEvent<HTMLButtonElement>) => {
const selectSize = (e: React.MouseEvent<HTMLButtonElement>) => {
setRegisterData('size', e.currentTarget.value);

const size =
Expand Down Expand Up @@ -85,7 +85,7 @@ const CoffeeOptionSelection = () => {
key={item}
value={item}
text={item}
onTouchEnd={selectSize}
onClick={selectSize}
className={cx(
registInfo.size === item ? SelectSizeBtn : BtnColorWhite,
SizeBtn,
Expand All @@ -109,7 +109,7 @@ const CoffeeOptionSelection = () => {
{...iconPropsGenerator(
!registInfo.shot ? 'input-minus' : 'input-minus:active'
)}
onTouchEnd={selectMinusBtn}
onClick={selectMinusBtn}
/>
<ShotOptionInput
type="number"
Expand All @@ -121,7 +121,7 @@ const CoffeeOptionSelection = () => {
{...iconPropsGenerator(
registInfo.shot >= 5 ? 'input-plus' : 'input-plus:active'
)}
onTouchEnd={selectPlusBtn}
onClick={selectPlusBtn}
/>
</div>
</ShotOptionInputContainer>
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/FooterIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const FooterIcon = ({ icon }: { icon: string }) => {
{icon && (
<div
className={cx(Column, Center)}
onTouchEnd={handleTouch}>
onClick={handleTouch}>
<Icon
{...iconPropsGenerator(active === icon ? `${icon}-active` : icon)}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Header = () => {

return (
<Container className={cx(Between, Align)}>
<Left onTouchEnd={useNavigateTo('/')}>
<Left onClick={useNavigateTo('/')}>
{logo && (
<svg
width={'80'}
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/HeaderCloseIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const HeaderCloseIcon = () => {
<>
<Icon
{...iconPropsGenerator('close')}
onTouchEnd={handleTouch}></Icon>
onClick={handleTouch}></Icon>
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/HeaderIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const HeaderIcon = ({ icon }: { icon: string }) => {
{icon && (
<Icon
{...iconPropsGenerator(icon)}
onTouchEnd={handleTouch}
onClick={handleTouch}
/>
)}
</>
Expand Down
3 changes: 0 additions & 3 deletions src/components/common/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
const Icon = ({
id,
size,
onTouchEnd,
onClick
}: {
id: string;
size: string;
onTouchEnd?: any;
onClick?: any;
}) => {
return (
<svg
width={size}
height={size}
onTouchEnd={onTouchEnd}
onClick={onClick}>
<use href={`/sprite.svg#${id}`} />
</svg>
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/ImgRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ImgRegister = ({
<Img
src={imageUrl}
alt="posted coffee"
onTouchEnd={resetImage}
onClick={resetImage}
/>
</PostImgContainer>
)}
Expand Down
6 changes: 2 additions & 4 deletions src/components/common/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export const Input = ({
<button
className={cx(nicknameBtn, InputFontSm)}
type="button"
onClick={handleEvent}
onTouchEnd={handleEvent}>
onClick={handleEvent}>
{nickname.btnText}
</button>
);
Expand All @@ -43,8 +42,7 @@ export const Input = ({
submitBtn = (
<button
type="button"
// onClick={handleEvent}
onTouchEnd={handleEvent}>
onClick={handleEvent}>
<Icon {...iconPropsGenerator('upload')} />
</button>
);
Expand Down
12 changes: 5 additions & 7 deletions src/components/common/ModalCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const ModalCTA = ({
text: string;
subBtnText?: string;
isConfirm?: boolean;
fn: React.TouchEventHandler<HTMLButtonElement>;
fn: React.MouseEventHandler<HTMLButtonElement>;
}) => {
const [isModal, setIsModal] = useRecoilState(isModalState);

Expand All @@ -38,12 +38,12 @@ const ModalCTA = ({
<ConfirmContainer className={cx(Flex, Between)}>
<Button
text={'돌아가기'}
onTouchEnd={HandleOnclick}
onClick={HandleOnclick}
className={cx(RegistBtn, BackBtn)}
/>
<Button
text={'탈퇴하기'}
onTouchEnd={handleActions}
onClick={handleActions}
className={RegistBtn}
/>
</ConfirmContainer>
Expand All @@ -52,7 +52,7 @@ const ModalCTA = ({
const DefalutBtn = (
<Button
text={actionText}
onTouchEnd={handleActions}
onClick={handleActions}
className={RegistBtn}
/>
);
Expand All @@ -73,9 +73,7 @@ const ModalCTA = ({
</TextContainer>
{!isConfirm ? DefalutBtn : confirmDeleteAuth}
</Container>
<SubBtn onTouchEnd={HandleOnclick}>
{subBtnText || signIn.subBtn}
</SubBtn>
<SubBtn onClick={HandleOnclick}>{subBtnText || signIn.subBtn}</SubBtn>
</ModalContainer>
</BackgroundLayer>
)
Expand Down
10 changes: 5 additions & 5 deletions src/components/common/SelectBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const SelectBox = ({
value: selectedValue,
defaultValue,
data,
onTouchEnd: handleTouch
onClick: handleClick
}: {
value?: string;
defaultValue: string;
data: string[];
onTouchEnd: React.TouchEventHandler<HTMLElement>;
onClick: React.MouseEventHandler<HTMLElement>;
}) => {
const selectRef = useRef<HTMLButtonElement>(null);
const { isSelect, handleSelectTouch } = useSelectBox(selectRef);
const { isSelect, handleSelectClick } = useSelectBox(selectRef);
const disabled = data === undefined && true;

return (
Expand All @@ -26,13 +26,13 @@ const SelectBox = ({
selectedValue={selectedValue}
defalutValue={defaultValue}
isSelect={isSelect}
onTouchEnd={handleSelectTouch}
onClick={handleSelectClick}
disabled={disabled}
/>
<SelectOption
data={data}
isSelect={isSelect}
onTouchEnd={handleTouch}
onClick={handleClick}
/>
</SelectBoxContainer>
);
Expand Down
6 changes: 3 additions & 3 deletions src/components/common/SelectBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ const SelectBtn = ({
selectedValue,
isSelect,
selectRef,
onTouchEnd: handleTouch,
onClick: handleTouch,
disabled
}: {
defalutValue: string;
selectedValue?: string;
isSelect: boolean;
selectRef: React.RefObject<HTMLButtonElement>;
onTouchEnd: React.TouchEventHandler<HTMLButtonElement>;
onClick: React.MouseEventHandler<HTMLButtonElement>;
disabled: boolean;
}) => {
return (
Expand All @@ -32,7 +32,7 @@ const SelectBtn = ({
? OnSelectBorder
: DefaultBorder
)}
onTouchEnd={handleTouch}
onClick={handleTouch}
ref={selectRef}>
<DefalutOption className={cx(Flex, SelectInput, SmStyle)}>
{convertBrandName(selectedValue || defalutValue)}
Expand Down
11 changes: 3 additions & 8 deletions src/components/common/SelectOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ import { Column } from '@/styles/layout';
const SelectOption = ({
data,
isSelect,
onTouchEnd
onClick: handleCilck
}: {
data: string[];
isSelect: boolean;

onTouchEnd: React.TouchEventHandler<HTMLElement>;
onClick: React.MouseEventHandler<HTMLButtonElement>;
}) => {
const handleTouch = (e: React.TouchEvent<HTMLButtonElement>) => {
onTouchEnd(e);
};

return (
<div>
{isSelect && (
Expand All @@ -26,7 +21,7 @@ const SelectOption = ({
data.map(item => (
<SelectOptionItem
key={item}
onTouchEnd={handleTouch}
onClick={handleCilck}
value={item}>
{convertBrandName(item)}
</SelectOptionItem>
Expand Down
6 changes: 3 additions & 3 deletions src/components/common/Taps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import { SelectedTap, DefaultTap } from '@/styles/styles';
const Taps = ({
taps,
selectedTab,
handleButtonTouch
handleButtonClick
}: {
taps: Array<string>;
selectedTab: string;
handleButtonTouch: (e: React.TouchEvent<HTMLButtonElement>) => void;
handleButtonClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
}) => {
return (
<TabContainer className={cx(Flex, Between)}>
{taps.map(item => (
<TapItem
className={cx(selectedTab === item ? SelectedTap : DefaultTap)}
onTouchEnd={handleButtonTouch}
onClick={handleButtonClick}
value={item}
key={item}>
<TapTitle>{item}</TapTitle>
Expand Down
2 changes: 1 addition & 1 deletion src/components/follow/FollowBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const FollowBtn = ({ userId }: { userId: string | undefined }) => {
<>
<Button
text={isFollowing && isFollowing.data ? following : follow2}
onTouchEnd={handleFollowUser}
onClick={handleFollowUser}
className={cx(
FollowBtnCommon,
isFollowing && isFollowing.data ? FollowingBtnStyle : FollowBtnStyle
Expand Down
2 changes: 1 addition & 1 deletion src/components/home/CaffeineFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CaffeineFilter = () => {
{signedIn && (
<Button
text={BUTTON_TEXTS.regist}
onTouchEnd={registPage}
onClick={registPage}
className={cx(RegistBtn, MarginBottom)}
/>
)}
Expand Down
8 changes: 4 additions & 4 deletions src/components/home/CoffeeMenuSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const CoffeeMenuSelection = () => {
const menuList = coffeeData && getMenuList(registInfo.brand);

// 커피 브랜드 선택
const selectBrand = (e: React.TouchEvent<HTMLButtonElement>) => {
const selectBrand = (e: React.MouseEvent<HTMLButtonElement>) => {
getMenuList(e.currentTarget.value);
setRegisterData('brand', e.currentTarget.value);
setCaffeineInfo(0);
Expand All @@ -80,7 +80,7 @@ const CoffeeMenuSelection = () => {
};

// 커피 메뉴 선택
const selectMenu = (e: React.TouchEvent<HTMLButtonElement>) => {
const selectMenu = (e: React.MouseEvent<HTMLButtonElement>) => {
getMenuInfo(e.currentTarget.value);
setRegisterData('menu', e.currentTarget.value);
};
Expand All @@ -99,13 +99,13 @@ const CoffeeMenuSelection = () => {
value={registInfo.brand}
defaultValue={registInfo.brand || coffeeMenu.brand}
data={brandList}
onTouchEnd={selectBrand}
onClick={selectBrand}
/>
<SelectBox
value={registInfo.menu}
defaultValue={coffeeMenu.menu}
data={menuList}
onTouchEnd={selectMenu}
onClick={selectMenu}
/>
</CoffeeSelectContainer>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/home/CoffeeSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const CoffeeSelection = () => {
<span>{title.title}</span>
<ResetBtn
className={cx(Align, SumBoardTitle)}
onTouchEnd={touchResetBtn}>
onClick={touchResetBtn}>
<Icon {...iconPropsGenerator('reset', '14')} />
{title.resetBtn}
</ResetBtn>
Expand Down
2 changes: 1 addition & 1 deletion src/components/home/WaterIntake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const WaterIntake = ({ coffeeCount }: { coffeeCount: number | undefined }) => {
src="/png/waterCup.png"
alt="water"
/>
<IconContainer onTouchEnd={touchPlusIcon}>
<IconContainer onClick={touchPlusIcon}>
<Icon {...iconPropsGenerator('plus')} />
</IconContainer>
</CircularProgressbarWithChildren>
Expand Down
2 changes: 1 addition & 1 deletion src/components/home/WaterPerCoffee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const WaterPerCoffee = () => {
<span className={AlertMessage}>{signedIn.card.notConsumed}</span>
<Button
text={signedIn.btn}
onTouchEnd={useNavigateTo('/post/register')}
onClick={useNavigateTo('/post/register')}
className={RegistCoffeeBtn}
/>
</div>
Expand Down
Loading

0 comments on commit 00b6f0b

Please sign in to comment.