-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: CoachMark 컴포넌트 구현 - 기존 Modal 컴포넌트와 매우 비슷함 - backdrop에 onClick 이벤트로 있던 closeModal이 없음 - Container의 backbround-color와 border 삭제 * feat: Swipe 설명을 위한 코치마크 적용 * feat: Modal 컴포넌트의 Container에 css를 추가할 수 있도록 변경 * refactor: CoachMark 컴포넌트를 Modal 컴포넌트로 대체 * fix: styled-component $ 사인 추가 * feat: useLocalStorage 훅 구현 * feat: 노래 상세페이지에 처음 접속할 때만 코치마크를 보여주도록 변경
- Loading branch information
1 parent
15c6dbd
commit 6d9d1a5
Showing
4 changed files
with
101 additions
and
25 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useState } from 'react'; | ||
|
||
const useLocalStorage = <T>( | ||
key: string, | ||
initialValue: T | ||
): [localStorageValue: T, setLocalStorageValue: (newValue: T) => void] => { | ||
const [localStorageValue, setLocalStorageValue] = useState(() => { | ||
try { | ||
const value = localStorage.getItem(key); | ||
|
||
if (value) { | ||
return JSON.parse(value); | ||
} else { | ||
localStorage.setItem(key, JSON.stringify(initialValue)); | ||
return initialValue; | ||
} | ||
} catch (error) { | ||
localStorage.setItem(key, JSON.stringify(initialValue)); | ||
return initialValue; | ||
} | ||
}); | ||
|
||
const setLocalStorageStateValue = (newValue: T) => { | ||
localStorage.setItem(key, JSON.stringify(newValue)); | ||
setLocalStorageValue(newValue); | ||
}; | ||
|
||
return [localStorageValue, setLocalStorageStateValue]; | ||
}; | ||
|
||
export default useLocalStorage; |