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

130-0feature/PaginationButton 컴포넌트 구현 #134

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
7 changes: 5 additions & 2 deletions src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import React from 'react';
import * as S from './styles';
import interparkLogo from '@/assets/imgs/interpark-logo.png';
import kopisLogo from '@/assets/imgs/kopis-logo.png';
import yes24Logo from '@/assets/imgs/yes24-logo.png';

const logoList = [
{ href: 'https://www.interpark.com', alt: 'interpark', src: interparkLogo },
{ href: 'https://www.kopis.or.kr', alt: 'KOPIS', src: kopisLogo },
{ href: 'https://www.yes24.com', alt: 'YES24', src: yes24Logo },
];

export const Footer = () => {
return (
<S.FooterContainer>
<S.StyledFooter>
{logoList.map((logo, index) => (
<>
<React.Fragment key={logo.alt}>
<a href={logo.href} target="_blank" rel="noopener noreferrer">
<S.Logo src={logo.src} alt={logo.alt} />
</a>
{index < logoList.length - 1 && <S.StyledSeperator />}
</>
</React.Fragment>
))}
</S.StyledFooter>
</S.FooterContainer>
Expand Down
20 changes: 20 additions & 0 deletions src/components/PaginationButton/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as S from './styles';

interface PaginationButtonProps {
pageNumber: number;
currentPage: number;
onClickPaginationButton: (page: number) => void;
}

export const PaginationButton = ({ pageNumber, currentPage, onClickPaginationButton }: PaginationButtonProps) => {
const isActive = pageNumber === currentPage;
const onClick = (pageNumber: number) => () => onClickPaginationButton(pageNumber);

Copy link
Collaborator

Choose a reason for hiding this comment

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

아래 함수 추가하시고, onClick 이벤트에 onClick={onClick(page)} 로 넣어주시면 될 거에요!

onClick = (page:number)=> () =>onClickPaginationButton(page)

return (
<S.PaginationButton $isActive={isActive} onClick={onClick(pageNumber)}>
{pageNumber}
</S.PaginationButton>
);
};

export default PaginationButton;
16 changes: 16 additions & 0 deletions src/components/PaginationButton/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import styled from 'styled-components';

interface StyledPaginationButtonProps {
$isActive: boolean;
}

export const PaginationButton = styled.button<StyledPaginationButtonProps>`
padding: 5px 8px;
margin: 0 4px;
border: none;
border-radius: 4px;
background-color: ${({ $isActive, theme }) => ($isActive ? theme.colors.primary : theme.colors.white)};
color: ${({ $isActive, theme }) => ($isActive ? theme.colors.white : theme.colors.black)};
cursor: pointer;
`;