Skip to content
Snippets Groups Projects
Select Git revision
  • 7af7208f0d511e82b6f0ac2aadc7d53810e03a70
  • mui5-annotation-on-video-stable default
  • get_setter_canvasSizeInformations
  • fix-error-div-into-p
  • annotation-on-video-v2
  • detached
  • annotation-on-video-r17
  • mui5
  • mui5-react-18
  • jacob-test
  • annotation-on-video protected
  • master
  • test-antoinev1
  • 20-fetch-thumbnail-on-annotation
  • add-research-field
  • Save
  • add-plugin
  • 14-wip-no-seek-to
  • 14-bug-on-video-time-control
  • 9_wip_videotests
  • _upgrade_material_ui
  • latest-tetras-16
  • v3.3.0
  • v3.2.0
  • v3.1.1
  • v3.1.0
  • v3.0.0
  • v3.0.0-rc.7
  • v3.0.0-rc.6
  • v3.0.0-rc.5
  • v3.0.0-rc.4
  • v3.0.0-rc.3
  • v3.0.0-rc.2
  • v3.0.0-rc.1
  • v3.0.0-beta.10
  • v3.0.0-beta.9
  • v3.0.0-beta.8
  • v3.0.0-beta.7
  • v3.0.0-beta.6
  • v3.0.0-beta.5
  • v3.0.0-beta.3
41 results

SearchResults.js

Blame
  • SearchResults.js 1.73 KiB
    import React, { Component } from 'react';
    import PropTypes from 'prop-types';
    import Button from '@material-ui/core/Button';
    import List from '@material-ui/core/List';
    import BackIcon from '@material-ui/icons/ArrowBackSharp';
    import SearchHit from '../containers/SearchHit';
    
    /** */
    export class SearchResults extends Component {
      /** */
      constructor(props) {
        super(props);
    
        this.state = { focused: false };
    
        this.toggleFocus = this.toggleFocus.bind(this);
      }
    
      /** */
      toggleFocus() {
        const {
          focused,
        } = this.state;
    
        this.setState({ focused: !focused });
      }
    
      /** */
      render() {
        const {
          classes,
          searchHits,
          startIndex,
          t,
          windowId,
        } = this.props;
    
        const {
          focused,
        } = this.state;
    
        return (
          <>
            { focused && (
              <Button onClick={this.toggleFocus} className={classes.navigation} size="small">
                <BackIcon />
                {t('backToResults')}
              </Button>
            )}
            <List>
              {
                searchHits.map((hit, index) => (
                  <SearchHit
                    key={hit.annotations[0]}
                    focused={focused}
                    hit={hit}
                    index={startIndex + index}
                    windowId={windowId}
                    showDetails={this.toggleFocus}
                  />
                ))
              }
            </List>
          </>
        );
      }
    }
    
    SearchResults.propTypes = {
      classes: PropTypes.objectOf(PropTypes.string),
      searchHits: PropTypes.arrayOf(PropTypes.object).isRequired,
      startIndex: PropTypes.number,
      t: PropTypes.func,
      windowId: PropTypes.string.isRequired, // eslint-disable-line react/no-unused-prop-types
    };
    
    SearchResults.defaultProps = {
      classes: {},
      startIndex: 0,
      t: k => k,
    };