Skip to content
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

Merged
merged 7 commits into from
Oct 25, 2023
3 changes: 2 additions & 1 deletion frontend/__test__/convertTextToUrl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ test.each([
'반갑다 https://github.com/woowacourse-teams/2023-votogether/issues/703 임',
'반갑다 [[https://github.com/woowacourse-teams/2023-votogether/issues/703]] 임',
],
['안녕 wwwww.naver.com', '안녕 wwwww.naver.com'],
['안녕 wwwww.naver.com', '안녕 ww[[www.naver.com]]'],
['하하 [www.naver.com]', '하하 [[[www.naver.com]]]'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 이렇게 테스트 케이스를 바꾸신 이유가 궁금해요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앞에 [[가 아니라면 자르고 하는게 맞다고 생각했어요!
예로, wowwww.---이런식으로 진짜 쓰진 않겠지만 쓸 수도 있을 수 있지 않을까요?

['http://localhost:3000/ 피카츄', '[[http://localhost:3000/]] 피카츄'],
[
'http://localhost:3000/http://localhost:3000/ 피카츄',
Expand Down
Binary file removed frontend/src/assets/dangseon-yo.png
Binary file not shown.
Binary file removed frontend/src/assets/dangseon.png
Binary file not shown.
1 change: 0 additions & 1 deletion frontend/src/components/AlarmContainer/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export const Container = styled.div`
grid-template-rows: 40px auto;
gap: 10px;

height: 100%;
padding: 10px;
`;

Expand Down
18 changes: 3 additions & 15 deletions frontend/src/components/common/LogoButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ButtonHTMLAttributes, useState } from 'react';

import EventMascot from '@pages/EventMascot';
import { ButtonHTMLAttributes } from 'react';

import logo from '@assets/logo.svg';
import votogether from '@assets/projectName.svg';
Expand Down Expand Up @@ -31,29 +29,19 @@ interface LogoButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
export default function LogoButton({ content, ...rest }: LogoButtonProps) {
const src = contentCategory[content].url;
const ariaLabelText = contentCategory[content].name;
const [count, setCount] = useState(0);

//이벤트를 위한 코드
const handleLogoClick = () => {
if (count > 5) return;

setCount(count + 1);
};

if (content === 'full') {
return (
<S.Button content={content} aria-label={ariaLabelText} {...rest}>
<img src={logo} alt="로고 아이콘" onClick={handleLogoClick} />
{count > 5 && <EventMascot type={'ma'} />}
<img src={logo} alt="로고 아이콘" />
<img src={votogether} alt="보투게더 아이콘" />
</S.Button>
);
}

return (
<S.Button content={content} aria-label={ariaLabelText} {...rest}>
<img src={src} alt="보투게더 아이콘" onClick={handleLogoClick} />
{count > 5 && <EventMascot type={'ma'} />}
<img src={src} alt="보투게더 아이콘" />
</S.Button>
);
}
2 changes: 1 addition & 1 deletion frontend/src/components/common/ToolTip/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const SIZE = {
sm: { height: '300px', width: '250px' },
md: { height: '460px', width: '315px' },
lg: { height: '740px', width: '420px' },
free: { height: '100%', width: '100%' },
free: { height: 'fit-content', width: '100%' },
};

export const Container = styled.div`
Expand Down
24 changes: 4 additions & 20 deletions frontend/src/components/common/UpButton/index.tsx
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>
);
}
28 changes: 0 additions & 28 deletions frontend/src/components/common/UpButton/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,3 @@ export const Button = styled.button`

cursor: pointer;
`;

//이벤트를 위한 코드
export const Image = styled.img<{ $isMoving: boolean }>`
width: 50px;
height: 50px;

position: absolute;
right: 13px;
bottom: 83px;
z-index: -1;

${props =>
props.$isMoving
? `animation: move 1s linear infinite;

@keyframes move {
0% {
right: 13px;
}
50% {
right: 200px;
}
100% {
right: 13px;
}
}`
: ''};
`;
1 change: 1 addition & 0 deletions frontend/src/components/post/Post/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const Content = styled.div<{ $isPreview: boolean }>`
export const DetailLink = styled.button<{ $isPreview: boolean }>`
display: flex;
flex-direction: column;
text-align: left;
gap: 10px;

width: 100%;
Expand Down
21 changes: 0 additions & 21 deletions frontend/src/pages/EventMascot/index.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions frontend/src/pages/EventMascot/style.ts

This file was deleted.

3 changes: 2 additions & 1 deletion frontend/src/styles/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ button,
input,
select {
margin: 0;
color: black;
}
html {
box-sizing: border-box;
Expand Down Expand Up @@ -80,7 +81,7 @@ button{
}

a{
color: inherit;
color: black;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파랑색 글씨가 사라지겠네요 👍👍👍

text-decoration: none;
}
`;
39 changes: 14 additions & 25 deletions frontend/src/utils/post/convertTextToUrl.ts
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;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주석 덕분에 바로 이해했어요👍

Copy link
Collaborator

Choose a reason for hiding this comment

The 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('');
};
Loading