Skip to content

Commit

Permalink
refactor: Header 컴포넌트 수정
Browse files Browse the repository at this point in the history
login 페이지에 적용해 두었던 AppBar를 공통 컴포넌트로 분리함
- DefaultLayout.tsx 파일은 필요없을 것 같아 제거
- _app.tsx 에 Header컴포넌트 공통으로 적용

ref #38
  • Loading branch information
ppark2ya committed Feb 9, 2022
1 parent 8686a45 commit 7912866
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 51 deletions.
20 changes: 0 additions & 20 deletions components/layout/DefaultLayout.tsx

This file was deleted.

80 changes: 55 additions & 25 deletions components/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,59 @@
import Link from 'next/link';
import { Text, Button, AppBar, styled } from '@nolmungshemung/ui-kits';
import { AppBar, Text, Button, Box, styled } from '@nolmungshemung/ui-kits';
import Router from 'next/router';

const StyledAppBar = styled(AppBar, {
gridArea: 'header',
display: 'flex',
alignItems: 'center',
borderBottom: 'solid 1px $gray',
':nth-child(1)': {
marginLeft: '22.5rem',
},
':nth-child(2)': {
marginLeft: '68.75rem',
},
const HeaderButton = styled(Button, {
width: '5rem',
padding: '0 $sp-20',
height: '$height-md !important',
cursor: 'pointer',
marginRight: '$sp-12',
});

const Header = () => (
<StyledAppBar>
{/* passHref: href 속성을 Link의 children에게 전달 */}
<Link href="/main" passHref>
<Text>Writing Hub</Text>
</Link>
<Button outline="black" size="md">
로그인
</Button>
</StyledAppBar>
);
export function Header() {
const handleRouting = (path: string) => {
Router.push(path);
};

export default Header;
return (
<AppBar
sticky={true}
css={{
paddingTop: '$sp-16',
justifyContent: 'space-around',
borderBottom: '1px solid $gray',
height: '4rem',
}}
>
<Text
weight="bold"
css={{
color: '#333333',
cursor: 'pointer',
}}
onClick={() => handleRouting('/')}
>
Writing Hub
</Text>
<Box>
{/* TODO: 로그인 세션에 따라서 다르게 처리하도록 수정 필요 */}
{/* <HeaderButton size="lg" color="white" outline="black">
필명등록
</HeaderButton>
<HeaderButton size="lg" color="white" outline="black">
로그아웃
</HeaderButton>
<HeaderButton size="lg" color="white" outline="black">
내피드
</HeaderButton> */}
<HeaderButton
size="lg"
color="white"
outline="black"
onClick={() => handleRouting('/login')}
>
로그인
</HeaderButton>
</Box>
</AppBar>
);
}
1 change: 1 addition & 0 deletions components/layout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Header';
18 changes: 12 additions & 6 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { ReactQueryDevtools } from 'react-query/devtools';
import { APP_STAGE } from '~/shared/constants/environments';
import { globalCss } from '@nolmungshemung/ui-kits';
import { reset } from 'stitches-reset';
import { DefaultSeo } from 'next-seo';
import { Header } from '~/components/layout';

globalCss({
...reset,
Expand Down Expand Up @@ -33,12 +35,16 @@ queryClient.setDefaultOptions({

function MyApp({ Component, pageProps }: AppProps) {
return (
<QueryClientProvider client={queryClient}>
<Hydrate state={pageProps.dehydratedState}>
<Component {...pageProps} />
<ReactQueryDevtools initialIsOpen={false} />
</Hydrate>
</QueryClientProvider>
<>
<DefaultSeo />
<QueryClientProvider client={queryClient}>
<Hydrate state={pageProps.dehydratedState}>
<Header />
<Component {...pageProps} />
<ReactQueryDevtools initialIsOpen={false} />
</Hydrate>
</QueryClientProvider>
</>
);
}

Expand Down
4 changes: 4 additions & 0 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export default class MyDocument extends Document {
return (
<Html>
<Head>
<meta
name="viewport"
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no"
/>
<style
id={'stitches'}
dangerouslySetInnerHTML={{ __html: getCssText() }}
Expand Down

0 comments on commit 7912866

Please sign in to comment.