clientjs/packages/dashboard-components/src/ui/IndexEntryItem.jsx
changeset 0 5f4fcbc80b37
equal deleted inserted replaced
-1:000000000000 0:5f4fcbc80b37
       
     1 import React, { Component } from 'react';
       
     2 import PropTypes from 'prop-types';
       
     3 import md5 from 'md5';
       
     4 
       
     5 import './IndexEntryItem.scss';
       
     6 
       
     7 export default class IndexEntryItem extends Component {
       
     8   static propTypes = {
       
     9     term: PropTypes.string,
       
    10   };
       
    11 
       
    12   static defaultProps = {
       
    13     term: '',
       
    14   };
       
    15 
       
    16   constructor(props) {
       
    17     super(props);
       
    18     this.linkClick = this.linkClick.bind(this);
       
    19   }
       
    20 
       
    21   linkClick(e) {
       
    22     const { term } = this.props;
       
    23     document.getElementById(`${md5(term)}-term-entry`).scrollIntoView();
       
    24     e.preventDefault();
       
    25   }
       
    26 
       
    27   render() {
       
    28     const { term } = this.props;
       
    29     return <li><button onClick={this.linkClick} type="button" className="btn btn-link index-entry-item__btn">{ term }</button></li>;
       
    30   }
       
    31 }