Skip to content

Commit

Permalink
feat(docs): UI Kit Docs 페이지 와꾸 추가 (#62)
Browse files Browse the repository at this point in the history
* feat(docs): 대략적인 레이아웃 추가

* feat(docs): BasicLayout 추가

* Docs Ui Kit 버전 업

* feat(docs): 사이드 메뉴 대충 와꾸 잡음

* feat(docs): Getting Started 추가
  • Loading branch information
evan-moon authored Mar 26, 2021
1 parent cbeaf23 commit 2b81488
Show file tree
Hide file tree
Showing 25 changed files with 420 additions and 252 deletions.
2 changes: 2 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
},
"dependencies": {
"@emotion/react": "^11.1.5",
"@emotion/styled": "^11.1.5",
"@lubycon/ui-kit": "^1.1.0-alpha.30",
"gh-pages": "^3.1.0",
"next": "latest",
"normalize.css": "^8.0.1",
Expand Down
22 changes: 20 additions & 2 deletions docs/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
import App from 'next/app';
import React from 'react';
import { AppProps } from 'next/app';
import { LubyconUIKitProvider } from '@lubycon/ui-kit';

import 'normalize.css';
import '@lubycon/ui-kit/css/lubycon-ui-kit.min.css';
import Head from 'next/head';

export default App;
export default function LubyconUIKitDocsApp({ Component, pageProps }: AppProps) {
return (
<>
<Head>
<title>Lubycon UI Kit</title>
<meta charSet="utf-8" />
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
</Head>
<LubyconUIKitProvider>
<Component {...pageProps} />
</LubyconUIKitProvider>
</>
);
}
23 changes: 23 additions & 0 deletions docs/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import Document, { Html, Head, Main, NextScript, DocumentContext } from 'next/document';

class LubyconUIKitDocsDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx);
return { ...initialProps };
}

render() {
return (
<Html lang="ko">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}

export default LubyconUIKitDocsDocument;
17 changes: 0 additions & 17 deletions docs/pages/about.tsx

This file was deleted.

Empty file added docs/pages/api/.gitkeep
Empty file.
16 changes: 0 additions & 16 deletions docs/pages/api/users/index.ts

This file was deleted.

1 change: 1 addition & 0 deletions docs/pages/getting-started.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'pages/GettingStartedPage';
1 change: 1 addition & 0 deletions docs/pages/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'pages/HomePage';
1 change: 0 additions & 1 deletion docs/pages/index.tsx

This file was deleted.

57 changes: 0 additions & 57 deletions docs/pages/users/[id].tsx

This file was deleted.

37 changes: 0 additions & 37 deletions docs/pages/users/index.tsx

This file was deleted.

66 changes: 66 additions & 0 deletions docs/src/components/BasicLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Row, Column, Container } from '@lubycon/ui-kit';
import GlobalHeader from 'components/GlobalHeader';
import GlobalSidebar from 'components/GlobalSidebar';
import React, { PropsWithChildren, useState, useEffect, useRef } from 'react';

const BasicLayout = ({ children }: PropsWithChildren<unknown>) => {
const headerRef = useRef<HTMLElement>(null);
const [headerHeight, setHeaderHeight] = useState(0);

const contentsHeight = `calc(100vh - ${headerHeight}px)`;

useEffect(() => {
if (headerRef.current != null) {
const rect = headerRef.current.getBoundingClientRect();
setHeaderHeight(rect.height);
}
}, [headerRef.current]);

return (
<div>
<header
ref={headerRef}
css={{
position: 'fixed',
top: 0,
left: 0,
width: '100%',
zIndex: 100,
}}
>
<GlobalHeader />
</header>
<div
css={{
paddingTop: headerHeight,
}}
>
<Container>
<Row css={{ height: contentsHeight }}>
<Column
as="aside"
xs="auto"
css={{
width: 300,
overflowY: 'scroll',
height: '100%',
}}
>
<GlobalSidebar />
</Column>
<Column
css={{
overflowY: 'scroll',
height: '100%',
}}
>
{children}
</Column>
</Row>
</Container>
</div>
</div>
);
};

export default BasicLayout;
40 changes: 17 additions & 23 deletions docs/src/components/GlobalHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
import React from 'react';
import { useRouter } from 'next/router';
import { Row, Column, Container } from '@lubycon/ui-kit';
import Link from 'next/link';
import { logoSrc } from 'constants/resources';

const GlobalHeader = () => {
const router = useRouter();
const handleLogoClick = (e: MouseEvent) => {
e.preventDefault();
router.push('/');
};

return (
<nav
css={{
display: 'flex',
width: '100%',
justifyContent: 'center',
padding: '12px 0',
boxShadow: '0px 3px 5px rgba(0, 0, 0, 0.1)',
backgroundColor: '#ffffff',
}}
>
<div
css={{
display: 'flex',
width: 1200,
justifyContent: 'space-between',
alignItems: 'center',
padding: '12px 0',
}}
>
<a href="/" onClick={handleLogoClick}>
<img
css={{ width: 100 }}
src="https://d2x9jxyr47nlkc.cloudfront.net/logo/logo-color.svg"
/>
</a>
</div>
<Container>
<Row css={{ width: '100%' }}>
<Column>
<Link href="/">
<a>
<img css={{ width: 100 }} src={logoSrc} />
</a>
</Link>
</Column>
</Row>
</Container>
</nav>
);
};
Expand Down
60 changes: 60 additions & 0 deletions docs/src/components/GlobalSidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';
import { Menu, menu } from 'constants/menu';
import Link from 'next/link';
import { isLinkMenu } from 'utils/menu';
import { colors, Text } from '@lubycon/ui-kit';
import styled from '@emotion/styled';

const StyledList = styled.ul`
margin: 0;
padding: 0;
`;
const StyledListItem = styled.li`
list-style: none;
margin: 0;
padding: 0;
`;

const Item = ({ menu }: { menu: Menu }) => {
return isLinkMenu(menu) ? (
<Link href={menu.link}>
<Text as="a" css={{ cursor: 'pointer' }}>
{menu.title}
</Text>
</Link>
) : (
<div>
<Text>{menu.title}</Text>
<StyledList>
{menu.children.map((childrenMenu, index) => (
<StyledListItem
key={index}
css={{
paddingLeft: 16,
borderLeft: `1px solid ${colors.gray20}`,
color: colors.gray70,
}}
>
<Item menu={childrenMenu} />
</StyledListItem>
))}
</StyledList>
</div>
);
};

const GlobalSidebar = () => {
return (
<div css={{ boxShadow: '0px 3px 5px rgba(0, 0, 0, 0.1)', height: '100%', padding: 16 }}>
<StyledList>
{menu.map((item, index) => (
<StyledListItem key={index} css={{ marginBottom: 8 }}>
<Item menu={item} />
</StyledListItem>
))}
</StyledList>
</div>
);
};

export default GlobalSidebar;
Loading

0 comments on commit 2b81488

Please sign in to comment.