Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2015104215
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
jaehyuk-jang
2021-06-11 01:09:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
aac57ef9041b6cc86ecc4f5b45b76dfae5e0a266
aac57ef9
1 parent
d696aacc
Apply componenets for header loader
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
0 deletions
project/packages/web/src/components/Header/index.tsx
project/packages/web/src/components/Loader/index.tsx
project/packages/web/src/components/Header/index.tsx
0 → 100644
View file @
aac57ef
import { useEffect, useState } from 'react';
import Link from 'next/link';
import { useRouter } from 'next/dist/client/router';
import { Layout, Menu } from 'antd';
import { MenuOutlined } from '@ant-design/icons';
import { useQuery } from '@apollo/client';
import { GET_ALL_POSTS } from '@src/gql/get-all-posts';
const { Header: HeaderContainer } = Layout;
export default function Header() {
const [selected, setSelected] = useState(null);
const { query } = useRouter();
const { error, data } = useQuery(GET_ALL_POSTS);
if (error) console.log(JSON.stringify(error, null, 2));
let list = [];
let getAllPosts = data?.getAllPosts || [];
getAllPosts.forEach((post) => {
if (!list.find((category) => post.category === category)) {
list.push(post.category);
}
});
useEffect(() => {
setSelected(query.name || '/');
}, [query]);
return (
<HeaderContainer className={'app-header'}>
<Menu
overflowedIndicator={<MenuOutlined className={'header-hbg-menu'} />}
theme={'dark'}
mode={'horizontal'}
selectedKeys={[selected]}
>
{/* logo */}
<Menu.Item key={'/'}>
<Link href={'/'}>
<a
style={{
float: 'left',
width: '120px',
height: '31px',
margin: '16px 24px 16px 0',
background: 'rgba(255, 255, 255, 0.3)',
}}
/>
</Link>
</Menu.Item>
{list.map((item) => (
<Menu.Item key={item} className={'header-item'}>
<Link href={`/category/${item}`}>
<a>{item}</a>
</Link>
</Menu.Item>
))}
</Menu>
</HeaderContainer>
);
}
project/packages/web/src/components/Loader/index.tsx
0 → 100644
View file @
aac57ef
import { Spin, Space } from 'antd';
export const startLoading = () => {
const element = document.getElementById('app-loader');
element.style.display = 'flex';
};
export const finishLoading = () => {
const element = document.getElementById('app-loader');
element.style.display = 'none';
};
export default function Loader() {
return (
<Space
id={'app-loader'}
size="middle"
style={{
position: 'fixed',
top: 0,
left: 0,
width: '100vw',
height: '100vh',
display: 'none',
alignItems: 'center',
justifyContent: 'center',
zIndex: 2,
}}
>
<Spin size="large" />
</Space>
);
}
Please
register
or
login
to post a comment