This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/frontend/scenes/Search/Search.js

65 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-07-18 03:59:32 +00:00
import React from 'react';
import { observer } from 'mobx-react';
2016-08-12 12:56:39 +00:00
import _ from 'lodash';
2016-07-18 03:59:32 +00:00
2016-08-05 15:44:15 +00:00
import { Flex } from 'reflexbox';
2016-08-22 05:21:13 +00:00
import Layout, { Title } from 'components/Layout';
2016-07-18 03:59:32 +00:00
import CenteredContent from 'components/CenteredContent';
2016-07-19 07:30:47 +00:00
import SearchField from './components/SearchField';
import DocumentPreview from 'components/DocumentPreview';
import styles from './Search.scss';
import SearchStore from './SearchStore';
2016-07-18 03:59:32 +00:00
@observer
class Search extends React.Component {
2016-07-19 07:30:47 +00:00
static store;
constructor(props) {
super(props);
this.store = new SearchStore();
}
2016-07-18 03:59:32 +00:00
render() {
2016-08-12 12:56:39 +00:00
const search = _.debounce((searchTerm) => {
2016-07-19 07:30:47 +00:00
this.store.search(searchTerm);
}, 250);
2016-08-22 05:21:13 +00:00
const title = (
<Title>
Search
</Title>
);
2016-07-19 07:30:47 +00:00
2016-07-18 03:59:32 +00:00
return (
<Layout
2016-08-22 05:21:13 +00:00
title={ title }
2016-07-18 03:59:32 +00:00
titleText="Search"
search={ false }
2016-07-19 07:30:47 +00:00
loading={ this.store.isFetching }
2016-07-18 03:59:32 +00:00
>
<CenteredContent>
2016-08-05 15:44:15 +00:00
<Flex column auto>
<Flex auto>
2016-07-19 07:30:47 +00:00
<img
src={ require('assets/icons/search.svg') }
className={ styles.icon }
2016-08-05 15:44:15 +00:00
alt="Search"
2016-07-19 07:30:47 +00:00
/>
<SearchField
searchTerm={ this.store.searchTerm }
onChange={ search }
/>
</Flex>
{ this.store.documents && this.store.documents.map((document) => {
2016-08-05 15:44:15 +00:00
return (<DocumentPreview key={ document.id } document={ document } />);
2016-07-19 07:30:47 +00:00
}) }
2016-07-18 03:59:32 +00:00
</Flex>
</CenteredContent>
</Layout>
);
}
}
export default Search;