Skip to content

Commit

Permalink
Merge pull request #41 from mash-up-kr/feature/header
Browse files Browse the repository at this point in the history
Header, Layout 컴포넌트 추가
  • Loading branch information
mango906 authored Feb 14, 2022
2 parents ae03ad5 + ab2cd54 commit afe2dca
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import { Routes, Route } from 'react-router-dom';
import { Global, ThemeProvider } from '@emotion/react';
import { theme, globalStyles } from '@/styles';

import { Layout } from '@/components';
import Count from '@/components/Count';

const App = () => (
<>
<Global styles={globalStyles} />
<ThemeProvider theme={theme}>
<Routes>
<Route path="/" element={<Count />} />
<Route path="/" element={<Layout />}>
<Route path="/" element={<Count />} />
</Route>
</Routes>
</ThemeProvider>
</>
Expand Down
5 changes: 5 additions & 0 deletions src/assets/svg/logo-admin-272.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions src/components/common/Header/Header.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';
import { Link } from 'react-router-dom';
import * as Styled from './Header.styled';

import Logo from '@/assets/svg/logo-admin-272.svg';
import {
NavigationItem,
NavigationSize,
} from '@/components/common/Navigation/Navigation.component';
import { Team, Role } from '@/components/common/UserProfile/UserProfile.component';

import { colors } from '@/styles';

import { Navigation, UserProfile } from '@/components';

// TODO: (@mango90): router 변경해주기
const navigationItems: NavigationItem[] = [
{
label: '지원서 내역',
to: window.location.pathname,
},
{
label: 'SMS 발송 내역',
to: '/1',
},
{
label: '지원서 설문지 내역',
to: '/2',
},
];

const Header = () => {
return (
<Styled.HeaderContainer>
<Styled.HeaderContainerInner>
<Link to="/">
<Logo />
<Styled.VisuallyHiddenLogo>Mash-Up Adminsoo</Styled.VisuallyHiddenLogo>
</Link>
<Navigation
size={NavigationSize.md}
items={navigationItems}
inActiveColor={colors.gray70}
showBottomBorder={false}
/>
<UserProfile team={Team.branding} role={Role.subLeader} />
</Styled.HeaderContainerInner>
</Styled.HeaderContainer>
);
};

export default Header;
12 changes: 12 additions & 0 deletions src/components/common/Header/Header.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';
import Header from './Header.component';

export default {
title: 'Header',
component: Header,
} as ComponentMeta<typeof Header>;

const Template: ComponentStory<typeof Header> = () => <Header />;

export const header = Template.bind({});
24 changes: 24 additions & 0 deletions src/components/common/Header/Header.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { HEADER_HEIGHT } from '@/constants';

export const HeaderContainer = styled.header`
${({ theme }) => css`
height: ${HEADER_HEIGHT};
border-bottom: 0.1rem solid ${theme.colors.gray30};
`}
`;

export const HeaderContainerInner = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
max-width: 120rem;
margin: 0 auto;
`;

export const VisuallyHiddenLogo = styled.h2`
${({ theme }) => css`
${theme.a11y.visuallyHidden};
`}
`;
17 changes: 17 additions & 0 deletions src/components/common/Layout/Layout.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { Outlet } from 'react-router-dom';
import { Header } from '@/components';
import * as Styled from './Layout.styled';

const Layout = () => {
return (
<>
<Header />
<Styled.Main>
<Outlet />
</Styled.Main>
</>
);
};

export default Layout;
8 changes: 8 additions & 0 deletions src/components/common/Layout/Layout.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import styled from '@emotion/styled';
import { HEADER_HEIGHT } from '@/constants';

export const Main = styled.main`
max-width: 120rem;
min-height: calc(100vh - ${HEADER_HEIGHT});
margin: 0 auto;
`;
9 changes: 9 additions & 0 deletions src/components/common/Link/Link.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

import { LinkProps as ReactRouterDomLinkProps, Link as ReactRouterDomLink } from 'react-router-dom';

const Link = ({ children, ...restProps }: ReactRouterDomLinkProps) => {
return <ReactRouterDomLink {...restProps}>{children}</ReactRouterDomLink>;
};

export default Link;
3 changes: 2 additions & 1 deletion src/components/common/Navigation/Navigation.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ export const NavigationItem = styled(Link)<StyledNavigationItemProps>`
align-items: center;
justify-content: center;
color: ${active ? theme.colors.purple70 : inActiveColor};
letter-spacing: -0.08rem;
${active
? css`
border-bottom: 0.2rem solid ${theme.colors.purple70};
`
: ''}
: ''};
`}
`;
4 changes: 4 additions & 0 deletions src/components/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export { default as Checkbox } from './Checkbox/Checkbox.component';
export { default as ModalWrapper } from './ModalWrapper/ModalWrapper.component';
export { default as RadioButton } from './RadioButton/RadioButton.component';
export { default as ToggleButton } from './ToggleButton/ToggleButton.component';
export { default as UserProfile } from './UserProfile/UserProfile.component';
export { default as Header } from './Header/Header.component';
export { default as Layout } from './Layout/Layout.component';
export { default as Link } from './Link/Link.component';
1 change: 1 addition & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ui';
1 change: 1 addition & 0 deletions src/constants/ui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const HEADER_HEIGHT = '7rem';

0 comments on commit afe2dca

Please sign in to comment.