-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[6주차] Reddigg 미션 제출합니다. #16
Open
leejin-rho
wants to merge
13
commits into
CEOS-Developers:master
Choose a base branch
from
team-Reddi:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
53decb6
feat: project done
dhshin98 a9080c0
feat: movie-detail page 구현
leejin-rho 8b3043d
Merge pull request #1 from team-Reddigg/feature/11-preview-page
leejin-rho f04e1db
feat: searchBar 컴포넌트
dhshin98 b4924aa
feat: search list 구현완료
dhshin98 d2d191d
feat: 검색 기능
dhshin98 c096392
feat: searchBar X 버튼 누르면 삭제
dhshin98 37d627d
Merge pull request #2 from team-Reddigg/feature/12-search-page
dhshin98 f272385
feat: 무한 스크롤
dhshin98 b2bc562
feat: search기능, 스크롤 기능 수정
leejin-rho 3b08625
fix: filter useEffect 수정
leejin-rho 311dfd8
feat: ENG 로 변경
dhshin98 86c4616
Merge pull request #3 from team-Reddigg/feature/12-search-page
dhshin98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,58 @@ | ||
const CHO_HANGUL: string[] = [ | ||
"ㄱ", | ||
"ㄲ", | ||
"ㄴ", | ||
"ㄷ", | ||
"ㄸ", | ||
"ㄹ", | ||
"ㅁ", | ||
"ㅂ", | ||
"ㅃ", | ||
"ㅅ", | ||
"ㅆ", | ||
"ㅇ", | ||
"ㅈ", | ||
"ㅉ", | ||
"ㅊ", | ||
"ㅋ", | ||
"ㅌ", | ||
"ㅍ", | ||
"ㅎ", | ||
]; | ||
|
||
const HANGUL_START_CHARCODE: number = "가".charCodeAt(0); | ||
|
||
const CHO_INTERVAL: number = Math.floor( | ||
"까".charCodeAt(0) - "가".charCodeAt(0), | ||
); | ||
const JUNG_INTERVAL: number = Math.floor( | ||
"개".charCodeAt(0) - "가".charCodeAt(0), | ||
); | ||
|
||
function combineHangul(cho: number, jung: number, jong: number): string { | ||
return String.fromCharCode( | ||
HANGUL_START_CHARCODE + cho * CHO_INTERVAL + jung * JUNG_INTERVAL + jong, | ||
); | ||
} | ||
|
||
function createChosungRegex(search: string = ""): RegExp { | ||
const regexPattern: string = CHO_HANGUL.reduce( | ||
(acc: string, cho: string, index: number) => | ||
acc.replace( | ||
new RegExp(cho, "g"), | ||
`[${combineHangul(index, 0, 0)}-${combineHangul(index + 1, 0, -1)}]`, | ||
), | ||
search, | ||
); | ||
|
||
return new RegExp(`(${regexPattern})`, "g"); | ||
} | ||
|
||
export function includesChosung(target: string, query: string): boolean { | ||
if (!query) return true; | ||
if (/[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/.test(query)) { | ||
return createChosungRegex(query).test(target); | ||
} else { | ||
return target.toLowerCase().includes(query.toLowerCase()); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수 이름이 엣지넘치네요 ㅎㅎㅋㅋㅋㅋㅋㅋㅋㅋ 완전 직관적이에요