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

LNB 컴포넌트 구현 #128

Merged
merged 1 commit into from
Oct 18, 2024
Merged
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: 28 additions & 0 deletions src/components/Post/LNB/LNB.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import styled from 'styled-components';
import theme from '@styles/theme';

export const LNBContainer = styled.nav`
display: flex;
width: 680px;
height: ${theme.units.spacing.space48};
cursor: pointer;
`;

export const LNBItemContainer = styled.div<{ active?: boolean }>`
display: flex;
justify-content: center;
align-items: center;
width: 170px;
border-bottom: 2px solid
${({ active }) =>
active ? theme.color.border.iPrimary : theme.color.border.tertiary};
font-weight: ${({ active }) =>
active
? theme.typography.fontWeight.semiBold
: theme.typography.fontWeight.regular};

&:hover {
background-color: ${theme.color.bg.iSecondaryHover};
transition: background-color 0.2s ease-in-out;
}
`;
52 changes: 52 additions & 0 deletions src/components/Post/LNB/LNB.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useNavigate } from 'react-router-dom';
import { PATH } from '@constants/path';
import type { FeedMenuType } from '@type/feed';
import * as S from './LNB.styled';

interface LNBItemProps {
label: string;
active?: boolean;
onClick: () => void;
}

interface LNBProps {
selected: FeedMenuType;
}

type LNBItem = { label: string; type: FeedMenuType }[];

const LNB_ITEMS: LNBItem = [
{ label: '일반 게시글', type: 'normal' },
{ label: '일정 조율', type: 'scheduling' },
{ label: '투표', type: 'vote' },
{ label: '자료 수집', type: 'collect' },
];

const LNBItem = ({ label, active, onClick }: LNBItemProps) => (
<S.LNBItemContainer active={active} onClick={onClick}>
{label}
</S.LNBItemContainer>
);

const LNB = ({ selected }: LNBProps) => {
const navigate = useNavigate();

const handleItemClick = (type: FeedMenuType) => {
navigate(`${PATH.POST}?type=${type}`);
};

return (
<S.LNBContainer>
{LNB_ITEMS.map(({ label, type }) => (
<LNBItem
key={type}
label={label}
onClick={() => handleItemClick(type)}
active={selected === type}
/>
))}
</S.LNBContainer>
);
};

export default LNB;
12 changes: 12 additions & 0 deletions src/pages/PostPage/PostPage.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { styled } from 'styled-components';
import theme from '@styles/theme';

export const Container = styled.div`
display: flex;
flex-direction: column;
align-items: center;
gap: ${theme.units.spacing.space32};
width: 100%;
height: 100%;
padding-top: ${theme.units.spacing.space24};
`;
15 changes: 11 additions & 4 deletions src/pages/PostPage/PostPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { useLocation } from 'react-router-dom';
import LNB from '@components/Post/LNB/LNB';
import type { FeedMenuType } from '@type/feed';
import * as S from './PostPage.styled';

const PostPage = () => {
const location = useLocation();
const queryParams = new URLSearchParams(location.search);
const feedType = queryParams.get('type');
const { search } = useLocation();
const feedType = new URLSearchParams(search).get('type') as FeedMenuType;

return <div>{feedType}</div>;
return (
<S.Container>
<LNB selected={feedType} />
</S.Container>
);
};

export default PostPage;