Skip to content

Commit

Permalink
feat: tooltip 하루마다 생성 & 파비콘 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
gogumalatte committed Nov 26, 2024
1 parent a06ce7d commit 0057d32
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="tapLogo.svg" />
<link rel="icon" href="tapLogo.ico" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
Expand Down
Binary file added public/tapLogo.ico
Binary file not shown.
9 changes: 0 additions & 9 deletions public/tapLogo.svg

This file was deleted.

14 changes: 10 additions & 4 deletions src/pages/MainPage/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ interface SidebarProps {
toggleSidebar: () => void;
}

const ONE_DAY_MS = 24 * 60 * 60 * 1000; // 하루를 밀리초로 계산

export const Sidebar: React.FC<SidebarProps> = ({ isOpen, toggleSidebar }) => {
const [showTooltip, setShowTooltip] = useState(false);
const navigate = useNavigate();

useEffect(() => {
const tooltipDismissed = localStorage.getItem("tooltipDismissed");
let timer: NodeJS.Timeout;
const tooltipDismissedTime = localStorage.getItem("tooltipDismissedTime");
const now = Date.now();
let timer: ReturnType<typeof setTimeout>;

const isTooltipExpired =
!tooltipDismissedTime || now - Number(tooltipDismissedTime) > ONE_DAY_MS;

if (tooltipDismissed !== "true" && !isOpen) {
if (isTooltipExpired && !isOpen) {
timer = setTimeout(() => {
setShowTooltip(true);
}, 500);
Expand All @@ -50,7 +56,7 @@ export const Sidebar: React.FC<SidebarProps> = ({ isOpen, toggleSidebar }) => {
};

const handleTooltipClose = () => {
localStorage.setItem("tooltipDismissed", "true");
localStorage.setItem("tooltipDismissedTime", String(Date.now())); // 현재 시간 저장
setShowTooltip(false);
};

Expand Down

0 comments on commit 0057d32

Please sign in to comment.