From a097022b5fcc344eedc8b8ad31e77c6590ff999e Mon Sep 17 00:00:00 2001 From: Michal Klobukowski Date: Fri, 8 Jun 2018 13:37:14 +0200 Subject: [PATCH] Create search bar component Feature #13590 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- .../main-app-bar/search-bar/search-bar.tsx | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/components/main-app-bar/search-bar/search-bar.tsx 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 -- 2.30.2