summaryrefslogtreecommitdiff
path: root/src/components/nav.js
blob: 72d1a06609dbae35a9d3646459c65cf645afb093 (plain)
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
39
40
41
import React from 'react'
import { css } from 'emotion'
import { Link } from 'gatsby'
import { margins } from './globals'

const navStyle = css(`
  display: flex;
  align-items: center;
  margin: 0 0 ${margins.md}px 0;
`)

export const Nav = p => {
  const linkStyle = css(`
    padding: 0 ${margins.md}px ${margins.md}px ${margins.md}px;
    &:not(:last-child) {
      margin: 0 ${margins.sm}px 0 0
    }
    text-decoration: none;
    border: ${p.hoverBorder};
    border-color: rgba(0, 0, 0, 0);
    &:hover {
      border-color: initial;
    }
  `)
  return (
    <nav className={navStyle}>
      {p.links
        ? p.links.map(({ name, link }) => (
            <Link
              className={linkStyle}
              to={link}
              key={link}
              activeStyle={{ borderColor: 'initial' }}
            >
              {name}
            </Link>
          ))
        : null}
    </nav>
  )
}