Skip to content

Commit

Permalink
Merge pull request #130 from Team-Lecue/Common/#129-Header-EventHandler
Browse files Browse the repository at this point in the history
[ Common ] Header 버튼 클릭 Event 바인딩
  • Loading branch information
jungwoo3490 authored Jan 16, 2024
2 parents 45835aa + 5734c86 commit dfd87f6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/components/common/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useNavigate } from 'react-router-dom';

import {
IcArrowLeftBlack,
IcArrowLeftWhite,
Expand Down Expand Up @@ -31,8 +33,9 @@ function Header({ headerTitle, isDarkMode, isDetailPage }: HeaderProps) {
}

export function HomeButton() {
const navigate = useNavigate();
const handleClickHomeButton = () => {
// 홈으로 이동하는 로직 추후 구현 필요
navigate('/');
};

return (
Expand All @@ -43,8 +46,19 @@ export function HomeButton() {
}

export function ShareButton() {
const handleClickShareButton = () => {
// 공유(?) 페이지로 이동하는 로직 추후 구현 필요
const handleClickShareButton = async () => {
try {
if (navigator.share) {
await navigator.share({
title: 'Lecue',
url: window.location.href,
});
} else {
alert('이 브라우저에서는 내장 공유 기능을 지원하지 않습니다.');
}
} catch (error) {
console.error('내장 공유 기능을 실행하는 중 에러가 발생했습니다:', error);
}
};

return (
Expand All @@ -55,8 +69,9 @@ export function ShareButton() {
}

export function BackButton({ isDarkMode }: HeaderButtonProps) {
const navigate = useNavigate();
const handleClickBackButton = () => {
// 뒤로 이동하는 로직 추후 구현 필요
navigate(-1);
};

return (
Expand Down

0 comments on commit dfd87f6

Please sign in to comment.