Skip to content

Instantly share code, notes, and snippets.

@olamothe
Last active October 28, 2020 10:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save olamothe/71077a9695025edc3d712f093db61243 to your computer and use it in GitHub Desktop.
Save olamothe/71077a9695025edc3d712f093db61243 to your computer and use it in GitHub Desktop.
Sample React App using Coveo UI
import React, { Component } from 'react';
import './App.css';
import { SearchUI } from './SearchUIWrapper';
class App extends Component {
getTemplateContent() {
return `
<div class="coveo-result-frame">
<div class='coveo-result-row'>
<a class='CoveoResultLink'></a>
</div>
<div class='coveo-result-row'>
<div class='CoveoExcerpt'></div>
</div>
</div>
`
}
render() {
return (
<div>
<SearchUI>
<div className="CoveoSearchbox"></div>
<div className="CoveoFacet" data-field="@objecttype"></div>
<div className="CoveoResultList" data-layout="list" data-wait-animation="fade" data-auto-select-fields-to-include="true" ref="resultList">
<script className='result-template' type='text/underscore' dangerouslySetInnerHTML={{ __html: this.getTemplateContent() }}></script>
</div>
</SearchUI>
</div>
);
}
}
export default App;
import React, { Component } from 'react';
import * as Coveo from 'coveo-search-ui';
import 'coveo-search-ui/bin/css/CoveoFullSearch.css';
export class SearchUI extends Component {
componentDidMount() {
Coveo.SearchEndpoint.configureSampleEndpointV2();
Coveo.init(this.refs.searchInterface);
}
render() {
return (
<div id="search" className='CoveoSearchInterface' data-enable-history="true" ref='searchInterface'>
{this.props.children}
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment