-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeader.jsx
38 lines (33 loc) · 1.15 KB
/
Header.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Link from 'next/link';
import React, { useState, useEffect } from 'react';
import { getCategories } from '../services';
const Header = () => {
const [categories, setCategories] = useState([]);
useEffect(() => {
getCategories()
.then((newCategories) => setCategories(newCategories))
}, []);
return (
<div className='container mx-auto px-10 mb-8'>
<div className='border-b w-full inline-block border-blue-400 py-8 '>
<div className='md:float-left block'>
<Link href="/">
<span className='cursor-pointer font-bold text-4xl text-white'>
GraphBlog
</span>
</Link>
</div>
<div className='hidden md:float-left md:contents'>
{categories.map((category) => (
<Link key={category.slug} href={`/category/${category.slug}`}>
<span className='md:float-right mt-2 align-middle text-white ml-4 font-semibold cursor-pointer transition duration-500 transform hover:-translate-y-1'>
{category.name}
</span>
</Link>
))}
</div>
</div>
</div>
)
}
export default Header