/
githubmirror
/
hyper
Обзор
Документация
Войти
/
githubmirror
/
hyper
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
3.1.0-canary.3
lib/components/searchBox.js
77 строк
2 KB
Labhansh Agrawal
convert manual bind to arrow
27 ноя 2019, 15:49
27 ноя 2019, 15:49
4e0fc48
Код
Авторство
О чём код?
import React from 'react'; const searchBoxStyling = { float: 'right', height: '28px', backgroundColor: 'white', position: 'absolute', right: '10px', top: '25px', width: '224px', zIndex: '9999' }; const enterKey = 13; export default class SearchBox extends React.PureComponent { constructor(props) { super(props); this.searchTerm = ''; } handleChange = event => { this.searchTerm = event.target.value; if (event.keyCode === enterKey) { this.props.search(event.target.value); } }; render() { return ( <div style={searchBoxStyling}> <input type="text" className="search-box" onKeyUp={this.handleChange} ref={input => input && input.focus()} /> <span className="search-button" onClick={() => this.props.prev(this.searchTerm)}> {' '} ←{' '} </span> <span className="search-button" onClick={() => this.props.next(this.searchTerm)}> {' '} →{' '} </span> <span className="search-button" onClick={() => this.props.close()}> {' '} x{' '} </span> <style jsx> {` .search-box { font-size: 18px; padding: 6px; width: 145px; border: none; } .search-box:focus { outline: none; } .search-button { background-color: #ffffff; color: black; padding: 7px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; transition-duration: 0.4s; cursor: pointer; } .search-button:hover { background-color: #e7e7e7; } `} </style> </div> ); } }