Skip to content

Commit

Permalink
Merge pull request #262 from boostcampwm-2024/front/main
Browse files Browse the repository at this point in the history
[FE] 브랜치 병합
  • Loading branch information
dongree authored Dec 5, 2024
2 parents 466556f + 25b5651 commit 36715ef
Show file tree
Hide file tree
Showing 18 changed files with 249 additions and 64 deletions.
7 changes: 7 additions & 0 deletions FE/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions FE/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@heroicons/react": "^2.1.5",
"@tanstack/react-query": "^4.36.1",
"hangul-js": "^0.2.6",
"lottie-react": "^2.4.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
103 changes: 88 additions & 15 deletions FE/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import useSearchInputStore from 'store/useSearchInputStore.ts';
import logoPng from 'assets/logo.png';
import logoWebp from 'assets/logo.webp';
import { checkAuth, logout } from 'service/auth.ts';
import { useEffect } from 'react';
import { useEffect, useState } from 'react';
import Toast from './Toast';
import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline';

export default function Header() {
const { toggleModal } = useLoginModalStore();
Expand All @@ -16,6 +17,7 @@ export default function Header() {
const { searchInput } = useSearchInputStore();
const location = useLocation();
const navigate = useNavigate();
const [isMenuOpen, setIsMenuOpen] = useState(false);

useEffect(() => {
const check = async () => {
Expand All @@ -42,24 +44,24 @@ export default function Header() {
return;
}
navigate(to);
setIsMenuOpen(false);
};

return (
<header className='fixed left-0 top-0 z-20 h-[60px] w-full bg-white'>
<div className='mx-auto flex h-full max-w-[1280px] items-center justify-between px-8'>
<div className='mx-auto flex h-full max-w-[1280px] items-center justify-between px-4 md:px-8'>
<Link to={'/'} className='flex items-center gap-2'>
<picture>
<source
srcSet={logoWebp}
type='image/webp'
className={'h-[32px]'}
/>
<img src={logoPng} alt={'Logo'} className={'h-[32px]'} />
<source srcSet={logoWebp} type='image/webp' className='h-[32px]' />
<img src={logoPng} alt='Logo' className='h-[32px]' />
</picture>
<h1 className='text-xl font-bold text-juga-grayscale-black'>JuGa</h1>
<h1 className='hidden text-xl font-bold text-juga-grayscale-black md:block'>
JuGa
</h1>
</Link>

<div className='flex items-center gap-8'>
{/* Desktop Navigation */}
<div className='hidden items-center gap-8 md:flex'>
<nav className='flex items-center gap-6 text-sm font-bold text-juga-grayscale-500'>
<div
onClick={() => handleLink('/')}
Expand Down Expand Up @@ -88,13 +90,15 @@ export default function Header() {
className='flex h-[36px] w-[280px] items-center rounded-lg bg-juga-grayscale-50 px-4 py-2'
onClick={toggleSearchModal}
>
<div className={'text-juga-grayscale-200'}>
<div className='text-juga-grayscale-200'>
{searchInput ? searchInput : 'Search...'}
</div>
</button>
</div>
</div>
<div className='flex items-center gap-4'>

{/* Desktop Auth Buttons */}
<div className='hidden items-center gap-4 md:flex'>
{isLogin ? (
<button
className='px-4 py-2 text-sm text-juga-grayscale-500'
Expand All @@ -110,12 +114,81 @@ export default function Header() {
>
로그인
</button>
{/* <button className='px-4 py-2 text-sm text-white rounded-lg bg-juga-grayscale-black'>
회원가입
</button> */}
</>
)}
</div>

{/* Mobile Menu Button */}
<div className='flex w-3/4 items-center justify-center md:hidden'>
<button
defaultValue={searchInput}
className='flex h-[36px] w-full items-center rounded-lg bg-juga-grayscale-50 px-4 py-2'
onClick={toggleSearchModal}
>
<div className='text-juga-grayscale-200'>
{searchInput ? searchInput : 'Search...'}
</div>
</button>
</div>

<button
className='p-2 md:hidden'
onClick={() => setIsMenuOpen(!isMenuOpen)}
>
{isMenuOpen ? (
<XMarkIcon className='h-6 w-6 text-juga-grayscale-500' />
) : (
<Bars3Icon className='h-6 w-6 text-juga-grayscale-500' />
)}
</button>

{/* Mobile Menu */}
{isMenuOpen && (
<div className='absolute left-0 top-[60px] w-full bg-white shadow-lg md:hidden'>
<div className='flex flex-col p-4'>
<nav className='flex flex-col gap-4 text-sm font-bold text-juga-grayscale-500'>
<div
onClick={() => handleLink('/')}
className='cursor-pointer px-1 py-2'
>
</div>
<div
onClick={() => handleLink('/rank')}
className='cursor-pointer px-1 py-2'
>
랭킹
</div>
{isLogin && (
<div
onClick={() => handleLink('/mypage')}
className='cursor-pointer px-1 py-2'
>
마이페이지
</div>
)}
</nav>

<div className='mt-4 flex flex-col gap-2'>
{isLogin ? (
<button
className='w-full px-4 py-2 text-sm text-juga-grayscale-500'
onClick={handleLogout}
>
로그아웃
</button>
) : (
<button
className='w-full px-4 py-2 text-sm text-juga-grayscale-500'
onClick={toggleModal}
>
로그인
</button>
)}
</div>
</div>
</div>
)}
</div>
</header>
);
Expand Down
26 changes: 26 additions & 0 deletions FE/src/components/Loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export default function Loading() {
return (
<div
role='status'
className='flex items-center justify-center w-full h-full'
>
<svg
aria-hidden='true'
className='w-8 h-8 text-gray-200 animate-spin fill-blue-600 dark:text-gray-600'
viewBox='0 0 100 101'
fill='none'
xmlns='http://www.w3.org/2000/svg'
>
<path
d='M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z'
fill='currentColor'
/>
<path
d='M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z'
fill='currentFill'
/>
</svg>
<span className='sr-only'>Loading...</span>
</div>
);
}
10 changes: 8 additions & 2 deletions FE/src/components/Mypage/Order.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import useOrderCancelAlertModalStore from 'store/useOrderCancleAlertModalStore';
import CancelAlertModal from './CancelAlertModal.tsx';
import { formatTimestamp } from 'utils/format';
import { useNavigate } from 'react-router-dom';
import { useQuery } from '@tanstack/react-query';
import { getOrders } from 'service/orders.ts';

export default function Order() {
const { orderQuery, removeOrder } = useOrders();
const { removeOrder } = useOrders();

const { data } = useQuery(['account', 'order'], () => getOrders(), {
staleTime: 1000,
suspense: true,
});

const { data } = orderQuery;
const { isOpen, open } = useOrderCancelAlertModalStore();

const navigation = useNavigate();
Expand Down
16 changes: 9 additions & 7 deletions FE/src/components/News/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,28 @@ type CardWithImageProps = {
export default function Card({ data }: CardWithImageProps) {
return (
<a
className='flex flex-col p-4 transition-all border rounded-lg cursor-pointer hover:bg-juga-grayscale-50'
className='flex cursor-pointer flex-col rounded-lg border p-4 transition-all hover:bg-juga-grayscale-50'
href={data.originallink}
target='_blank'
rel='noopener noreferrer'
>
<div className={'mb-2 flex w-full flex-row items-center justify-between'}>
<div className={'flex flex-row items-center gap-3'}>
<h3 className='w-[320px] truncate text-left text-base font-medium'>
<div className={'flex w-full flex-row items-center gap-3'}>
<h3 className='w-fit truncate text-left text-base font-medium lg:w-[320px]'>
{data.title}
</h3>
</div>
<span className={'w-fit text-sm text-gray-500'}>
<span
className={'hidden w-full text-end text-sm text-gray-500 lg:block'}
>
{formatDate(data.pubDate)}
</span>
</div>
<div className='flex items-center justify-between w-full gap-4'>
<p className='text-sm text-left truncate w-96 text-juga-grayscale-500'>
<div className='flex w-full items-center justify-between gap-4'>
<p className='w-96 truncate text-left text-sm text-juga-grayscale-500'>
{data.description}
</p>
<span className='rounded-full bg-juga-blue-10 px-2 py-0.5 text-xs text-juga-blue-50'>
<span className='hidden rounded-full bg-juga-blue-10 px-2 py-0.5 text-xs text-juga-blue-50 lg:block'>
{data.query}
</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion FE/src/components/News/News.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function News() {
<h2 className='text-xl font-bold'>주요 뉴스</h2>
</div>

<div className='grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-2'>
<div className='grid grid-cols-1 gap-4 md:grid-cols-2'>
{data.news
.slice(randomNewsIndex, randomNewsIndex + 4)
.map((news: NewsDataType, index: number) => (
Expand Down
50 changes: 50 additions & 0 deletions FE/src/components/Search/KoreanMapping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
type CharacterMap = {
[key: string]: string;
};

export class SimpleKoreanConverter {
private charMap: CharacterMap;

constructor() {
this.charMap = {
r: 'ㄱ',
R: 'ㄲ',
s: 'ㄴ',
e: 'ㄷ',
E: 'ㄸ',
f: 'ㄹ',
a: 'ㅁ',
q: 'ㅂ',
Q: 'ㅃ',
t: 'ㅅ',
T: 'ㅆ',
d: 'ㅇ',
w: 'ㅈ',
W: 'ㅉ',
c: 'ㅊ',
z: 'ㅋ',
x: 'ㅌ',
v: 'ㅍ',
g: 'ㅎ',

k: 'ㅏ',
o: 'ㅐ',
i: 'ㅑ',
O: 'ㅒ',
j: 'ㅓ',
p: 'ㅔ',
u: 'ㅕ',
P: 'ㅖ',
h: 'ㅗ',
y: 'ㅛ',
n: 'ㅜ',
b: 'ㅠ',
m: 'ㅡ',
l: 'ㅣ',
};
}

public convert(input: string): string[] {
return Array.from(input).map((char) => this.charMap[char] || char);
}
}
2 changes: 1 addition & 1 deletion FE/src/components/Search/SearchCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function SearchCard({ data }: SearchCardProps) {
className={
'h-[52px] w-full rounded-xl hover:cursor-pointer hover:bg-gray-100'
}
onClick={handleClick}
onMouseDown={handleClick}
>
<div className={'my-2 flex w-full items-center justify-between px-4'}>
<div className={'flex-1 flex-col'}>
Expand Down
Loading

0 comments on commit 36715ef

Please sign in to comment.