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

[김민찬] Sprint9 #296

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions apis/getArticles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,32 @@ interface ArticlesResponse {
totalCount: number;
}

export interface GetArticlesProps {
page?: string;
export interface GetArticlesParams {
page?: number;
size?: number;
order?: orderType;
keyword?: string;
size?: string;
}

const getArticles = async ({
page = '1',
page = 1,
order = 'recent',
size = '10',
size = 10,
keyword = '',
}: GetArticlesProps): Promise<ArticlesResponse> => {
const { data } = await axiosInstance.get(
`/${ARTICLES_QUERY_KEY}?page=${page}&pageSize=${size}&orderBy=${order}&keyword=${keyword}`
);
}: GetArticlesParams): Promise<ArticlesResponse> => {
const params = new URLSearchParams({
page: page.toString(),
pageSize: size.toString(),
orderBy: order,
keyword,
});

return data;
try {
const { data } = await axiosInstance.get(`/${ARTICLES_QUERY_KEY}?${params.toString()}`);
return data;
} catch {
return { list: [], totalCount: 0 };
}
};

export default getArticles;
10 changes: 2 additions & 8 deletions components/@shared/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ interface ButtonProps {
type?: 'submit' | 'button' | 'reset';
}

function Button({
children,
category = 'medium',
onClick,
type,
disabled = false,
}: ButtonProps) {
function Button({ children, category = 'medium', onClick, type, disabled = false }: ButtonProps) {
return (
<button
className={classNames(styles.button, styles[category], {
[styles.disabled]: disabled
[styles.disabled]: disabled,
})}
type={type}
onClick={onClick}
Expand Down
46 changes: 0 additions & 46 deletions components/@shared/CustomImage.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions components/@shared/Header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
background-color: var(--white);
border-bottom: 1px solid var(--border-gray);

@media #{$tabletSize} {
@include tablet {
Copy link
Collaborator

Choose a reason for hiding this comment

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

오호 좋아요~~! 이제 scss 간지나게 사용하시겠군요 :)

padding: 0 24px;
}

@media #{$mobileSize} {
@include mobile {
padding: 0 16px;
}

button {
width: 128px;
height: 48px;

@media #{$mobileSize} {
@include mobile {
width: 60px;
}
}
Expand Down
13 changes: 7 additions & 6 deletions components/@shared/HeaderLinkSection.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
cursor: pointer;
}

@media #{$mobileSize} {
@include mobile {
gap: 15px;
}
}
Expand All @@ -21,16 +21,17 @@
line-height: 26px;
color: var(--cool-gray-600);

@include mobile {
font-size: 16px;
}

&:not(:last-child) {
margin-right: 32px;
@media #{$mobileSize} {

@include mobile {
margin-right: 8px;
}
}

@media #{$mobileSize} {
font-size: 16px;
}
}

.matched {
Expand Down
15 changes: 5 additions & 10 deletions components/@shared/HeaderLinkSection.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import logoImg from '@/public/images/home/logoAndTypo.png';
import typoImg from '@/public/images/home/typo.png';
import Link from 'next/link';
import CustomImage from './CustomImage';
import { useRouter } from 'next/router';
import useWindowSize from '@/hooks/useWindowSize';
import {
PATH_ADD_ITEM,
PATH_BOARDS,
PATH_HOME,
PATH_ITEMS,
} from '@/constants/paths';
import { PATH_ADD_ITEM, PATH_BOARDS, PATH_HOME, PATH_ITEMS } from '@/constants/paths';
import classNames from 'classnames';
import styles from './HeaderLinkSection.module.scss';
import { DEVICE_MAX_WIDTH } from '@/constants/mediaQuerySize';
import Image from 'next/image';
import useInnerWidth from '@/hooks/customs/useInnerWidth';

function HeaderLinkSection() {
const { innerWidth } = useWindowSize();
const innerWidth = useInnerWidth();
const { pathname } = useRouter();
const needLinkHeaderPaths = [PATH_BOARDS, PATH_ITEMS, PATH_ADD_ITEM];
const isWiderMobileSize = innerWidth > DEVICE_MAX_WIDTH.mobile;

return (
<section className={classNames(styles.linkSection)}>
<Link href={PATH_HOME}>
<CustomImage
<Image
src={isWiderMobileSize ? logoImg : typoImg}
alt={'로고 이미지'}
height={isWiderMobileSize ? 51 : 40}
Expand Down
3 changes: 2 additions & 1 deletion components/@shared/Layout.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
margin: 0 auto;

padding: calc(var(--header-height) + 24px) 24px 24px 24px;
@media #{$mobileSize} {

@include mobile {
padding: calc(var(--header-height) + 16px) 16px 16px 16px;
}
}
5 changes: 4 additions & 1 deletion components/@shared/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import styles from './Layout.module.scss';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

function Layout({ children }: { children: React.ReactNode }) {
const queryClient = new QueryClient();
return (
<>
<Header />
<main className={classNames(styles.mainContainer)}>{children}</main>
<QueryClientProvider client={queryClient}>
<main className={classNames(styles.mainContainer)}>{children}</main>
</QueryClientProvider>
</>
);
}
Expand Down
68 changes: 68 additions & 0 deletions components/@shared/OrderByDropdown.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@import '/styles/variables';

.dropdownWrapper {
display: flex;
justify-content: center;
align-items: center;
flex-shrink: 0;

position: relative;
height: 42px;
width: 130px;

font-size: 16px;
font-weight: 400;
line-height: 24px;
border-radius: 12px;

color: var(--cool-gray-800);
background-color: var(--white);
border: 1px solid var(--cool-gray-200);

cursor: pointer;

@include underTablet {
width: 120px;
}

@include mobile {
width: 42px;
border-radius: 12px;
}
}

.dropdownTrigger {
display: flex;
justify-content: center;
align-items: center;

& span {
width: 66px;
}
}

.dropdownMenu {
position: absolute;
display: flex;
flex-direction: column;

width: 130px;
height: 84px;
top: 46px;
right: 0;
border-radius: 12px;

background-color: var(--white);
border: 1px solid var(--cool-gray-200);

& li {
display: flex;
justify-content: center;
align-items: center;
height: 100%;

&:not(:last-child) {
border-bottom: 1px solid var(--cool-gray-200);
}
}
}
58 changes: 58 additions & 0 deletions components/@shared/OrderByDropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import styles from './OrderByDropdown.module.scss';
import sortIcon from '@/public/images/market/sort-icon.png';
import dropDownIcon from '@/public/images/market/order-dropdown.png';
import { DEVICE_MAX_WIDTH } from '@/constants/mediaQuerySize';
import Image from 'next/image';

import useToggle from '@/hooks/customs/useToggle';
import { useState } from 'react';
import useInnerWidth from '@/hooks/customs/useInnerWidth';

interface OrderByDropdownProps {
onMenuClick: (orderBy: string) => void;
}

const orderByList = [
{ name: '최신순', value: 'recent' },
{ name: '좋아요순', value: 'like' },
];

function OrderByDropdown({ onMenuClick }: OrderByDropdownProps) {
const innerWidth = useInnerWidth();
const [isDropdownOpen, toggleDropdown] = useToggle();
const [selectedItem, setSelectedItem] = useState(orderByList[0]);

const handleMenuClick = (event: React.MouseEvent<HTMLUListElement>) => {
const { name, value } = (event.target as HTMLUListElement).dataset;
if (name && value) {
onMenuClick(value);
setSelectedItem({ name, value });
}
toggleDropdown();
};

return (
<div className={styles.dropdownWrapper}>
<div className={styles.dropdownTrigger} onClick={toggleDropdown}>
{innerWidth > DEVICE_MAX_WIDTH.mobile && <span>{selectedItem.name}</span>}
<Image
src={innerWidth > DEVICE_MAX_WIDTH.mobile ? dropDownIcon : sortIcon}
alt={'드롭다운 열기 아이콘'}
height={24}
width={24}
/>
</div>
{isDropdownOpen && (
<ul className={styles.dropdownMenu} onClick={handleMenuClick}>
{orderByList.map((item) => (
<li key={item.value} data-name={item.name} data-value={item.value}>
{item.name}
</li>
))}
</ul>
)}
</div>
);
}

export default OrderByDropdown;
Loading
Loading