import * as React from 'react' import * as q from '../../../backend/src/Model' import { AppBar, Button, IconButton, InputBase, Toolbar, Typography } from '@material-ui/core' import { StyleRulesCallback, withStyles } from '@material-ui/core/styles' import CloudOff from '@material-ui/icons/CloudOff' import Menu from '@material-ui/icons/Menu' import Search from '@material-ui/icons/Search' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { fade } from '@material-ui/core/styles/colorManipulator' import { settingsActions, connectionActions } from '../actions' import { AppState } from '../reducers' import ClearAdornment from './helper/ClearAdornment'; const styles: StyleRulesCallback = theme => ({ title: { display: 'none', [theme.breakpoints.up('sm')]: { display: 'block', }, }, search: { position: 'relative', borderRadius: theme.shape.borderRadius, backgroundColor: fade(theme.palette.common.white, 0.15), '&:hover': { backgroundColor: fade(theme.palette.common.white, 0.25), }, marginRight: theme.spacing.unit * 2, marginLeft: 0, width: '100%', [theme.breakpoints.up('sm')]: { marginLeft: theme.spacing.unit * 3, width: 'auto', }, }, searchIcon: { width: theme.spacing.unit * 8, height: '100%', position: 'absolute', pointerEvents: 'none', display: 'flex', alignItems: 'center', justifyContent: 'center', }, inputRoot: { color: 'inherit', width: '100%', }, inputInput: { paddingTop: theme.spacing.unit, paddingRight: theme.spacing.unit, paddingBottom: theme.spacing.unit, paddingLeft: theme.spacing.unit * 10, transition: theme.transitions.create('width'), width: '100%', [theme.breakpoints.up('md')]: { width: 200, }, }, menuButton: { marginLeft: -12, marginRight: 20, }, }) interface Props { classes: any actions: { settings: typeof settingsActions, connection: typeof connectionActions, } topicFilter?: string } class TitleBar extends React.Component { constructor(props: any) { super(props) this.state = { } } public render() { const { actions, classes } = this.props return ( MQTT-Explorer {this.renderSearch()} ) } private renderSearch() { const { classes, topicFilter } = this.props return (
} classes={{ root: classes.inputRoot, input: classes.inputInput }} /> ) } private clearFilter = () => { this.props.actions.settings.filterTopics('') } private onFilterChange = (event: React.ChangeEvent) => { this.props.actions.settings.filterTopics(event.target.value) } } const mapStateToProps = (state: AppState) => { return { topicFilter: state.settings.topicFilter, } } const mapDispatchToProps = (dispatch: any) => { return { actions: { settings: bindActionCreators(settingsActions, dispatch), connection: bindActionCreators(connectionActions, dispatch), }, } } export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(TitleBar))