summaryrefslogtreecommitdiff
path: root/src/components/top-nav/index.js
blob: 50f7e863ea9012a3a96ec446d28083c83d4b92ee (about) (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Link } from 'react-router-dom';

import './styles.css';
import Logo from '../icons/logo';

class TopNav extends React.Component {
  updateDateJump = (dateJump) => {
    if (dateJump === this.props.selectedDateJump) {
      return;
    }

    this.props.updateDateJump(dateJump);
  };

  render() {
    return (
      <div className='top-nav'>
        <div className="container clearfix">
          <Link to="/" className="logo clearfix float-left">
            <Logo/>
            <div className="logo-text">
              <h4>GitHunt</h4>
              <p className="text-muted">Most starred projects on GitHub</p>
            </div>
          </Link>
          <div className="float-right duration-btns">
            <button onClick={ () => this.updateDateJump('year') }
                    className={
                      classNames('btn', {
                        'btn-primary': this.props.selectedDateJump === 'year',
                        'btn-light': this.props.selectedDateJump !== 'year',
                      })
                    }>
              Yearly
            </button>
            <button onClick={ () => this.updateDateJump('month') }
                    className={
                      classNames('btn', {
                        'btn-primary': this.props.selectedDateJump === 'month',
                        'btn-light': this.props.selectedDateJump !== 'month',
                      })
                    }>
              Monthly
            </button>
            <button onClick={ () => this.updateDateJump('week') }
                    className={
                      classNames('btn', {
                        'btn-primary': this.props.selectedDateJump === 'week',
                        'btn-light': this.props.selectedDateJump !== 'week',
                      })
                    }>
              Weekly
            </button>
            <button onClick={ () => this.updateDateJump('day') }
                    className={
                      classNames('btn', {
                        'btn-primary': this.props.selectedDateJump === 'day',
                        'btn-light': this.props.selectedDateJump !== 'day',
                      })
                    }>
              Daily
            </button>
          </div>
        </div>
      </div>
    );
  }
}

TopNav.propTypes = {
  updateDateJump: PropTypes.func.isRequired,
  selectedDateJump: PropTypes.string
};

export default TopNav;