From: Michal Klobukowski Date: Fri, 8 Jun 2018 11:37:14 +0000 (+0200) Subject: Create search bar component X-Git-Tag: 1.2.0~78^2~27 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/a097022b5fcc344eedc8b8ad31e77c6590ff999e Create search bar component Feature #13590 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- diff --git a/src/components/main-app-bar/search-bar/search-bar.tsx b/src/components/main-app-bar/search-bar/search-bar.tsx new file mode 100644 index 00000000..95b28602 --- /dev/null +++ b/src/components/main-app-bar/search-bar/search-bar.tsx @@ -0,0 +1,77 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import * as React from 'react'; +import { AppBar, Toolbar, Typography, Grid, IconButton, Badge, Paper, Input, StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core'; +import NotificationsIcon from '@material-ui/icons/Notifications'; +import PersonIcon from '@material-ui/icons/Person'; +import HelpIcon from '@material-ui/icons/Help'; +import SearchIcon from '@material-ui/icons/Search'; +import { AppBarProps } from '@material-ui/core/AppBar'; + +interface SearchBarDataProps { + value: string; +} + +interface SearchBarActionProps { + onChange: (value: string) => any; + onSubmit: () => any; +} + +type SearchBarProps = SearchBarDataProps & SearchBarActionProps & WithStyles + +class SearchBar extends React.Component { + render() { + const { classes } = this.props + return +
+ + + + +
+
+ } + + handleSubmit = (event: React.FormEvent) => { + event.preventDefault(); + this.props.onSubmit(); + } + + handleChange = (event: React.ChangeEvent) => { + this.props.onChange(event.target.value); + } + +} + +type CssRules = 'container' | 'input' | 'button' + +const styles: StyleRulesCallback = theme => { + const { unit } = theme.spacing + return { + container: { + position: 'relative' + }, + input: { + border: 'none', + padding: unit, + paddingRight: unit * 4, + borderRadius: unit / 4 + }, + button: { + position: 'absolute', + top: unit / 2, + right: unit / 2, + width: unit * 3, + height: unit * 3 + } + } +} + +export default withStyles(styles)(SearchBar) \ No newline at end of file