-
Notifications
You must be signed in to change notification settings - Fork 4
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
이벤트 코드 삭제 및 UI 버그 수정 #817
이벤트 코드 삭제 및 UI 버그 수정 #817
Changes from all commits
b96c1ec
f18141b
6c45d8b
6a18de3
2be9587
07fc08f
dcee6b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,15 @@ | ||
import React, { useState } from 'react'; | ||
import React from 'react'; | ||
|
||
import chevronUp from '@assets/chevron_up_primary.svg'; | ||
import mascotYo from '@assets/dangseon-yo.png'; | ||
|
||
import * as S from './style'; | ||
|
||
interface UpButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {} | ||
|
||
export default function UpButton({ ...rest }: UpButtonProps) { | ||
const [count, setCount] = useState(0); | ||
|
||
//이벤트를 위한 코드 | ||
const handleLogoClick = () => { | ||
if (count > 5) return; | ||
|
||
setCount(count + 1); | ||
}; | ||
const handleClick = () => { | ||
setCount(0); | ||
}; | ||
|
||
return ( | ||
<> | ||
<S.Button {...rest}> | ||
<img src={chevronUp} alt="페이지 최상단으로 스크롤 올리기" onClick={handleLogoClick} /> | ||
</S.Button> | ||
<S.Image src={mascotYo} onClick={handleClick} $isMoving={count > 5} /> | ||
</> | ||
<S.Button {...rest}> | ||
<img src={chevronUp} alt="페이지 최상단으로 스크롤 올리기" /> | ||
</S.Button> | ||
); | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ button, | |
input, | ||
select { | ||
margin: 0; | ||
color: black; | ||
} | ||
html { | ||
box-sizing: border-box; | ||
|
@@ -80,7 +81,7 @@ button{ | |
} | ||
|
||
a{ | ||
color: inherit; | ||
color: black; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 파랑색 글씨가 사라지겠네요 👍👍👍 |
||
text-decoration: none; | ||
} | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,18 @@ | ||
/** | ||
* https://abc.co.kr/@abc/4 | ||
* https://votogether.com/ | ||
* http://localhost:3000/posts/100035 | ||
* http://votogether.com/ | ||
* (?<!\[\[) 는 앞에 [[로 시작하는 지 여부를 확인한다 | ||
* https?:\/\/는 http:// 혹은 https:// 로 시작하는 지 여부를 확인한다. | ||
* (?!\]\]) 는 뒤에 ]]로 끝나는 지 여부를 확인한다. | ||
* [^\s] 는 공백이 아닌 문자인지 여부를 확인한다. | ||
*/ | ||
const httpsOrHttpRegex = /(?<!\[\[)(https?:\/\/[^\s]+)(?!\]\])/g; | ||
|
||
/** | ||
* www.naver.com | ||
* www.tistory.com | ||
* (?<!\[\[) 는 앞에 [[로 시작하는 지 여부를 확인한다 | ||
* (?<!\/)는 앞에 /로 시작하는 지 여부를 확인한다. https://www 에서 www 앞에 /가 있기에 중복되어 확인하는 것을 방지하기 위함 | ||
* \b(w{3})\b 는 www로 시작하는 지 여부를 정확히 확인한다. w가 4개인 경우 판별하지 않음 | ||
* [^\s] 는 공백이 아닌 문자인지 여부를 확인한다. | ||
* (?!\]\]) 는 뒤에 ]]로 끝나는 지 여부를 확인한다. | ||
*/ | ||
const wwwRegex = /(?<!\[\[)(?<!\/)\b(w{3})\b[^\s]+(?!\]\])/g; | ||
// linkRegex: https:// | http:// | www. 뒤에 문자+숫자+특수기호가 이어져있는 정규표현식 | ||
const linkRegex = /(?:https?:\/\/|w{3}\.)+[a-z0-9-+&@#/%?=~_|!:,.;]*[a-z0-9-+&@#/%=~_|]/g; | ||
// [[ ]]를 표현하는 정규표현식 | ||
const customLinkPattern = /\[\[([^[\]]+)\]\]/g; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 주석 덕분에 바로 이해했어요👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 주석 설명이 너무 좋아요 222 |
||
export const convertTextToUrl = (text: string) => { | ||
const httpOrHttpsConvertedText = text.replace(httpsOrHttpRegex, url => `[[${url}]]`); | ||
const wwwConvertedText = httpOrHttpsConvertedText.replace(wwwRegex, url => `[[${url}]]`); | ||
//아아[[링크]]다다 = [아아, 링크, 다다]; | ||
const parts = text.split(customLinkPattern); | ||
|
||
return parts | ||
.map(part => { | ||
//linkRegex를 포함하지 않는다면 그대로 return | ||
if (!linkRegex.test(part)) return part; | ||
|
||
return wwwConvertedText; | ||
return part.replace(linkRegex, url => `[[${url}]]`); | ||
}) | ||
.join(''); | ||
}; |
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.
오 이렇게 테스트 케이스를 바꾸신 이유가 궁금해요!
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.
앞에 [[가 아니라면 자르고 하는게 맞다고 생각했어요!
예로, wowwww.---이런식으로 진짜 쓰진 않겠지만 쓸 수도 있을 수 있지 않을까요?