diff --git a/packages/cra-template-coveo/README.md b/packages/cra-template-coveo/README.md
new file mode 100644
index 0000000000..f38ac7d60b
--- /dev/null
+++ b/packages/cra-template-coveo/README.md
@@ -0,0 +1,20 @@
+# cra-template-coveo
+
+This is the coveo template for [Create React App](https://github.com/facebook/create-react-app).
+
+To use this template, add `--template coveo` when creating a new app.
+
+For example:
+
+```sh
+npx create-react-app my-app --template coveo
+
+# or
+
+yarn create react-app my-app --template coveo
+```
+
+For more information, please refer to:
+
+- [Getting Started](https://create-react-app.dev/docs/getting-started) – How to create a new app.
+- [User Guide](https://create-react-app.dev) – How to develop apps bootstrapped with Create React App.
diff --git a/packages/cra-template-coveo/package.json b/packages/cra-template-coveo/package.json
new file mode 100644
index 0000000000..5425ebdee6
--- /dev/null
+++ b/packages/cra-template-coveo/package.json
@@ -0,0 +1,27 @@
+{
+ "name": "cra-template-typescript",
+ "version": "1.1.1",
+ "keywords": [
+ "react",
+ "create-react-app",
+ "template",
+ "typescript"
+ ],
+ "description": "The base TypeScript template for Create React App.",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/facebook/create-react-app.git",
+ "directory": "packages/cra-template-typescript"
+ },
+ "license": "MIT",
+ "engines": {
+ "node": ">=10"
+ },
+ "bugs": {
+ "url": "https://github.com/facebook/create-react-app/issues"
+ },
+ "files": [
+ "template",
+ "template.json"
+ ]
+}
diff --git a/packages/cra-template-coveo/template.json b/packages/cra-template-coveo/template.json
new file mode 100644
index 0000000000..11e6cce83a
--- /dev/null
+++ b/packages/cra-template-coveo/template.json
@@ -0,0 +1,24 @@
+{
+ "package": {
+ "dependencies": {
+ "@coveo/headless": "^0.1.0",
+ "@material-ui/core": "^4.11.3",
+ "@material-ui/lab": "^4.0.0-alpha.57",
+ "@testing-library/jest-dom": "^5.11.4",
+ "@testing-library/react": "^11.1.0",
+ "@testing-library/user-event": "^12.1.10",
+ "@types/node": "^12.0.0",
+ "@types/react": "^17.0.0",
+ "@types/react-dom": "^17.0.0",
+ "@types/jest": "^26.0.15",
+ "typescript": "^4.1.2",
+ "web-vitals": "^1.0.1"
+ },
+ "eslintConfig": {
+ "extends": [
+ "react-app",
+ "react-app/jest"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/cra-template-coveo/template/README.md b/packages/cra-template-coveo/template/README.md
new file mode 100644
index 0000000000..b87cb00449
--- /dev/null
+++ b/packages/cra-template-coveo/template/README.md
@@ -0,0 +1,46 @@
+# Getting Started with Create React App
+
+This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
+
+## Available Scripts
+
+In the project directory, you can run:
+
+### `npm start`
+
+Runs the app in the development mode.\
+Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
+
+The page will reload if you make edits.\
+You will also see any lint errors in the console.
+
+### `npm test`
+
+Launches the test runner in the interactive watch mode.\
+See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
+
+### `npm run build`
+
+Builds the app for production to the `build` folder.\
+It correctly bundles React in production mode and optimizes the build for the best performance.
+
+The build is minified and the filenames include the hashes.\
+Your app is ready to be deployed!
+
+See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
+
+### `npm run eject`
+
+**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
+
+If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
+
+Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
+
+You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
+
+## Learn More
+
+You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
+
+To learn React, check out the [React documentation](https://reactjs.org/).
diff --git a/packages/cra-template-coveo/template/gitignore b/packages/cra-template-coveo/template/gitignore
new file mode 100644
index 0000000000..4d29575de8
--- /dev/null
+++ b/packages/cra-template-coveo/template/gitignore
@@ -0,0 +1,23 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# production
+/build
+
+# misc
+.DS_Store
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
diff --git a/packages/cra-template-coveo/template/public/favicon.ico b/packages/cra-template-coveo/template/public/favicon.ico
new file mode 100644
index 0000000000..a11777cc47
Binary files /dev/null and b/packages/cra-template-coveo/template/public/favicon.ico differ
diff --git a/packages/cra-template-coveo/template/public/index.html b/packages/cra-template-coveo/template/public/index.html
new file mode 100644
index 0000000000..aa069f27cb
--- /dev/null
+++ b/packages/cra-template-coveo/template/public/index.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ React App
+
+
+ You need to enable JavaScript to run this app.
+
+
+
+
diff --git a/packages/cra-template-coveo/template/public/logo192.png b/packages/cra-template-coveo/template/public/logo192.png
new file mode 100644
index 0000000000..fc44b0a379
Binary files /dev/null and b/packages/cra-template-coveo/template/public/logo192.png differ
diff --git a/packages/cra-template-coveo/template/public/logo512.png b/packages/cra-template-coveo/template/public/logo512.png
new file mode 100644
index 0000000000..a4e47a6545
Binary files /dev/null and b/packages/cra-template-coveo/template/public/logo512.png differ
diff --git a/packages/cra-template-coveo/template/public/manifest.json b/packages/cra-template-coveo/template/public/manifest.json
new file mode 100644
index 0000000000..080d6c77ac
--- /dev/null
+++ b/packages/cra-template-coveo/template/public/manifest.json
@@ -0,0 +1,25 @@
+{
+ "short_name": "React App",
+ "name": "Create React App Sample",
+ "icons": [
+ {
+ "src": "favicon.ico",
+ "sizes": "64x64 32x32 24x24 16x16",
+ "type": "image/x-icon"
+ },
+ {
+ "src": "logo192.png",
+ "type": "image/png",
+ "sizes": "192x192"
+ },
+ {
+ "src": "logo512.png",
+ "type": "image/png",
+ "sizes": "512x512"
+ }
+ ],
+ "start_url": ".",
+ "display": "standalone",
+ "theme_color": "#000000",
+ "background_color": "#ffffff"
+}
diff --git a/packages/cra-template-coveo/template/public/robots.txt b/packages/cra-template-coveo/template/public/robots.txt
new file mode 100644
index 0000000000..e9e57dc4d4
--- /dev/null
+++ b/packages/cra-template-coveo/template/public/robots.txt
@@ -0,0 +1,3 @@
+# https://www.robotstxt.org/robotstxt.html
+User-agent: *
+Disallow:
diff --git a/packages/cra-template-coveo/template/src/App.css b/packages/cra-template-coveo/template/src/App.css
new file mode 100644
index 0000000000..74b5e05345
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/App.css
@@ -0,0 +1,38 @@
+.App {
+ text-align: center;
+}
+
+.App-logo {
+ height: 40vmin;
+ pointer-events: none;
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ .App-logo {
+ animation: App-logo-spin infinite 20s linear;
+ }
+}
+
+.App-header {
+ background-color: #282c34;
+ min-height: 100vh;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ font-size: calc(10px + 2vmin);
+ color: white;
+}
+
+.App-link {
+ color: #61dafb;
+}
+
+@keyframes App-logo-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/App.test.tsx b/packages/cra-template-coveo/template/src/App.test.tsx
new file mode 100644
index 0000000000..14b01402ba
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/App.test.tsx
@@ -0,0 +1,9 @@
+import React from 'react';
+import {render, screen} from '@testing-library/react';
+import App from './App';
+
+test('renders learn react link', () => {
+ render( );
+ const linkElement = screen.getByText(/learn react/i);
+ expect(linkElement).toBeInTheDocument();
+});
diff --git a/packages/cra-template-coveo/template/src/App.tsx b/packages/cra-template-coveo/template/src/App.tsx
new file mode 100644
index 0000000000..279536081b
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/App.tsx
@@ -0,0 +1,14 @@
+import SearchPage from './Components/SearchPage';
+import Hero from './Components/Hero';
+import logo from './logo.svg';
+
+function App() {
+ return (
+
+
+
+
+ );
+}
+
+export default App;
diff --git a/packages/cra-template-coveo/template/src/Components/Facet.css b/packages/cra-template-coveo/template/src/Components/Facet.css
new file mode 100644
index 0000000000..be84d696ae
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/Facet.css
@@ -0,0 +1,15 @@
+.truncate {
+ width: 100%;
+ position: relative;
+}
+
+.inline {
+ display: flex;
+}
+
+.truncate span {
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ width: 100%;
+}
diff --git a/packages/cra-template-coveo/template/src/Components/Facet.tsx b/packages/cra-template-coveo/template/src/Components/Facet.tsx
new file mode 100644
index 0000000000..dd6f97d7e3
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/Facet.tsx
@@ -0,0 +1,113 @@
+import React from 'react';
+import {
+ Facet as FacetType,
+ FacetState,
+ buildFacet,
+ FacetValue,
+} from '@coveo/headless';
+import {headlessEngine} from '../Engine';
+import Button from '@material-ui/core/Button';
+import Checkbox from '@material-ui/core/Checkbox';
+import Box from '@material-ui/core/Box';
+import List from '@material-ui/core/List';
+import './Facet.css';
+import {Divider, ListItem, ListItemText, Typography} from '@material-ui/core';
+
+interface IFacetProps {
+ title: string;
+ field: string;
+}
+
+export default class Facet extends React.Component {
+ private headlessFacet: FacetType;
+ state: FacetState;
+
+ constructor(props: any) {
+ super(props);
+
+ this.headlessFacet = buildFacet(headlessEngine, {
+ options: {
+ numberOfValues: 5,
+ field: this.props.field,
+ },
+ });
+
+ this.state = this.headlessFacet.state;
+ }
+
+ componentDidMount() {
+ this.headlessFacet.subscribe(() => this.updateState());
+ }
+
+ componentWillUnmount() {
+ this.headlessFacet.subscribe(() => {});
+ }
+
+ updateState() {
+ this.setState(this.headlessFacet.state);
+ }
+
+ toggleSelect(value: FacetValue) {
+ this.headlessFacet.toggleSelect(value);
+ }
+
+ showMore() {
+ this.headlessFacet.showMoreValues();
+ }
+
+ showLess() {
+ this.headlessFacet.showLessValues();
+ }
+
+ render() {
+ return (
+
+
+
+ {this.props.title}
+
+
+
+
+ {this.state.values.map((value: FacetValue) => {
+ const labelId = `checkbox-list-label-${value}`;
+
+ return (
+ this.toggleSelect(value)}
+ >
+
+
+
+ );
+ })}
+
+ {this.state.canShowLessValues && (
+ this.showLess()}>
+ Show Less
+
+ )}
+ {this.state.canShowMoreValues && (
+ this.showMore()}>
+ Show More
+
+ )}
+
+ );
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/Components/FacetList.tsx b/packages/cra-template-coveo/template/src/Components/FacetList.tsx
new file mode 100644
index 0000000000..67a28d6727
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/FacetList.tsx
@@ -0,0 +1,19 @@
+import React from 'react';
+import Typography from '@material-ui/core/Typography';
+import Box from '@material-ui/core/Box';
+import Facet from './Facet';
+
+export default class FacetList extends React.Component {
+ render() {
+ return (
+
+
+ Refine By
+
+
+
+
+
+ );
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/Components/Hero.css b/packages/cra-template-coveo/template/src/Components/Hero.css
new file mode 100644
index 0000000000..9adce291ad
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/Hero.css
@@ -0,0 +1,34 @@
+.App-logo {
+ height: 40vmin;
+ pointer-events: none;
+}
+
+.App-header {
+ background-color: #333357;
+ min-height: 30vh;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ color: #e5e8e8;
+ font-family: Avenir, Helvetica, Arial, sans-serif;
+ margin-bottom: 4rem;
+}
+
+.App-header ul {
+ list-style-type: none;
+ padding: 0;
+ margin-top: 0;
+}
+.App-header li {
+ display: inline-block;
+ margin: 0 10px;
+}
+
+.App-header h6 {
+ padding-top: 2rem;
+}
+
+.App-header a {
+ color: #1cebcf;
+}
diff --git a/packages/cra-template-coveo/template/src/Components/Hero.tsx b/packages/cra-template-coveo/template/src/Components/Hero.tsx
new file mode 100644
index 0000000000..c4caf695d5
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/Hero.tsx
@@ -0,0 +1,83 @@
+import {Typography} from '@material-ui/core';
+import React from 'react';
+import './Hero.css';
+
+function Anchor(props: any) {
+ return {props.value} ;
+}
+
+export default class Hero extends React.Component<
+ {logo: string; welcome: string},
+ {}
+> {
+ render() {
+ return (
+
+
+ {this.props.welcome}
+
+ This sample search page was built with{' '}
+ {' '}
+ and the{' '}
+
+ .
+
+
+ Edit{' '}
+
+ src/App.tsx
+ {' '}
+ and save to reload.
+
+
+
+ Customize your search page theme
+
+
+ You can customize your theme by modifying the{' '}
+
+ src/theme.tsx
+
+ . For more information about theme customization, visit{' '}
+
+ .
+
+
+
+ Essential Links
+
+
+
+
+ .
+
+
+
+ .
+
+
+ .
+
+
+ .
+
+
+
+ );
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/Components/Pager.tsx b/packages/cra-template-coveo/template/src/Components/Pager.tsx
new file mode 100644
index 0000000000..521b5e424c
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/Pager.tsx
@@ -0,0 +1,57 @@
+import React from 'react';
+import {Pagination} from '@material-ui/lab';
+import Box from '@material-ui/core/Box';
+import Typography from '@material-ui/core/Typography';
+import {buildPager, PagerState, Pager as PagerType} from '@coveo/headless';
+import {headlessEngine} from '../Engine';
+
+export default class Pager extends React.Component {
+ private headlessPager: PagerType;
+ state: PagerState;
+
+ constructor(props: any) {
+ super(props);
+
+ this.headlessPager = buildPager(headlessEngine, {
+ options: {numberOfPages: 3},
+ });
+
+ this.state = this.headlessPager.state;
+ }
+
+ componentDidMount() {
+ this.headlessPager.subscribe(() => this.updateState());
+ }
+
+ updateState() {
+ this.setState(this.headlessPager.state);
+ }
+
+ setPage(pageNumber: number) {
+ this.headlessPager.selectPage(pageNumber);
+ }
+
+ get page() {
+ return this.headlessPager.state.currentPage;
+ }
+
+ get count() {
+ return this.headlessPager.state.maxPage;
+ }
+
+ render() {
+ return (
+
+ Current page
+ this.setPage(page)}
+ variant="outlined"
+ shape="rounded"
+ size="small"
+ />
+
+ );
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/Components/QuerySummary.tsx b/packages/cra-template-coveo/template/src/Components/QuerySummary.tsx
new file mode 100644
index 0000000000..74b5b5d67e
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/QuerySummary.tsx
@@ -0,0 +1,89 @@
+import React from 'react';
+import {
+ buildQuerySummary,
+ QuerySummaryState,
+ QuerySummary as QuerySummaryType,
+} from '@coveo/headless';
+import {headlessEngine} from '../Engine';
+import {Box, Divider} from '@material-ui/core';
+
+export default class QuerySummary extends React.Component {
+ private headlessQuerySummary: QuerySummaryType;
+ state: QuerySummaryState;
+
+ constructor(props: any) {
+ super(props);
+
+ this.headlessQuerySummary = buildQuerySummary(headlessEngine);
+
+ this.state = this.headlessQuerySummary.state;
+ }
+
+ componentDidMount() {
+ this.headlessQuerySummary.subscribe(() => this.updateState());
+ }
+
+ updateState() {
+ this.setState(this.headlessQuerySummary.state);
+ }
+
+ renderNoResults() {
+ return No results ;
+ }
+
+ renderBold(input: string) {
+ return (
+
+ {input}
+
+ );
+ }
+
+ renderRange() {
+ return this.renderBold(
+ ` ${this.state.firstResult}-${this.state.lastResult}`
+ );
+ }
+
+ renderTotal() {
+ return (
+
+ {' '}
+ of {this.renderBold(this.state.total.toString())}
+
+ );
+ }
+
+ renderQuery() {
+ if (this.state.hasQuery) {
+ return (
+ for {this.renderBold(this.state.query)}
+ );
+ }
+ }
+
+ renderDuration() {
+ return ` in ${this.state.durationInSeconds} seconds`;
+ }
+
+ renderHasResults() {
+ return (
+
+
+ Results{this.renderRange()}
+ {this.renderTotal()}
+ {this.renderQuery()}
+ {this.renderDuration()}
+
+
+
+ );
+ }
+
+ render() {
+ if (!this.state.hasResults) {
+ return this.renderNoResults();
+ }
+ return this.renderHasResults();
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/Components/ResultList.tsx b/packages/cra-template-coveo/template/src/Components/ResultList.tsx
new file mode 100644
index 0000000000..fd4baf2006
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/ResultList.tsx
@@ -0,0 +1,116 @@
+import React from 'react';
+import List from '@material-ui/core/List';
+import {ListItem, Box, Typography} from '@material-ui/core';
+import {
+ buildResultList,
+ ResultTemplatesManager,
+ Result,
+ ResultListState,
+ ResultList as ResultListType,
+ buildResultTemplatesManager,
+} from '@coveo/headless';
+import {headlessEngine} from '../Engine';
+
+type Template = (result: Result) => any;
+
+interface FieldValueInterface {
+ value: string;
+ caption: string;
+}
+
+function ListItemLink(props: any) {
+ return (
+
+
+ {props.title}
+
+
+ );
+}
+
+function FieldValue(props: FieldValueInterface) {
+ return (
+
+
+ {props.caption}:
+
+
+ {props.value}
+
+
+ );
+}
+
+export default class ResultList extends React.Component {
+ private headlessResultList: ResultListType;
+ private headlessResultTemplateManager: ResultTemplatesManager;
+ state: ResultListState;
+
+ constructor(props: any) {
+ super(props);
+
+ this.headlessResultList = buildResultList(headlessEngine);
+
+ this.state = this.headlessResultList.state;
+
+ this.headlessResultTemplateManager = buildResultTemplatesManager(
+ headlessEngine
+ );
+ this.headlessResultTemplateManager.registerTemplates({
+ conditions: [],
+ content: (result: Result) => (
+
+
+
+
+
+
+ {result.excerpt && (
+
+
+ {result.excerpt}
+
+
+ )}
+
+ {result.raw.source && (
+
+ )}
+ {result.raw.objecttype && (
+
+ )}
+
+
+ ),
+ });
+ }
+
+ componentDidMount() {
+ this.headlessResultList.subscribe(() => this.updateState());
+ }
+
+ updateState() {
+ this.setState(this.headlessResultList.state);
+ }
+
+ render() {
+ return (
+
+ {this.state.results.map((result: Result) => {
+ const template = this.headlessResultTemplateManager.selectTemplate(
+ result
+ );
+ return template ? template(result) : null;
+ })}
+
+ );
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/Components/ResultsPerPage.tsx b/packages/cra-template-coveo/template/src/Components/ResultsPerPage.tsx
new file mode 100644
index 0000000000..a51da2a1ff
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/ResultsPerPage.tsx
@@ -0,0 +1,55 @@
+import React from 'react';
+import Radio from '@material-ui/core/Radio';
+import RadioGroup from '@material-ui/core/RadioGroup';
+import FormControlLabel from '@material-ui/core/FormControlLabel';
+import FormControl from '@material-ui/core/FormControl';
+import Typography from '@material-ui/core/Typography';
+import {
+ buildResultsPerPage,
+ ResultsPerPageState,
+ ResultsPerPage as ResultPerPageType,
+} from '@coveo/headless';
+import {headlessEngine} from '../Engine';
+
+export default class ResultsPerPage extends React.Component {
+ private headlessResultsPerPage: ResultPerPageType;
+ state: ResultsPerPageState;
+
+ constructor(props: any) {
+ super(props);
+
+ this.headlessResultsPerPage = buildResultsPerPage(headlessEngine, {
+ initialState: {numberOfResults: 10},
+ });
+
+ this.state = this.headlessResultsPerPage.state;
+ }
+
+ componentDidMount() {
+ this.headlessResultsPerPage.subscribe(() => this.updateState());
+ }
+
+ updateState() {
+ this.setState(this.headlessResultsPerPage.state);
+ }
+
+ render() {
+ return (
+
+ Results per page
+ {
+ this.headlessResultsPerPage.set(parseInt(event.target.value, 10));
+ }}
+ >
+ } label="5" />
+ } label="10" />
+ } label="15" />
+
+
+ );
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/Components/SearchBox.tsx b/packages/cra-template-coveo/template/src/Components/SearchBox.tsx
new file mode 100644
index 0000000000..c416480390
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/SearchBox.tsx
@@ -0,0 +1,56 @@
+import React from 'react';
+import TextField from '@material-ui/core/TextField';
+import Autocomplete from '@material-ui/lab/Autocomplete';
+import {
+ buildSearchBox,
+ SearchBoxState,
+ SearchBox as SearchBoxType,
+} from '@coveo/headless';
+import {headlessEngine} from '../Engine';
+
+export default class SearchBox extends React.Component {
+ private headlessSearchBox: SearchBoxType;
+ state: SearchBoxState;
+
+ constructor(props: any) {
+ super(props);
+
+ this.headlessSearchBox = buildSearchBox(headlessEngine);
+ this.state = this.headlessSearchBox.state;
+ }
+
+ componentDidMount() {
+ this.headlessSearchBox.subscribe(() => this.updateState());
+ }
+
+ updateState() {
+ this.setState(this.headlessSearchBox.state);
+ }
+
+ render() {
+ return (
+ {
+ this.headlessSearchBox.updateText(newInputValue);
+ }}
+ onChange={() => {
+ this.headlessSearchBox.submit();
+ }}
+ options={this.state.suggestions.map(
+ (suggestion: any) => suggestion.rawValue
+ )}
+ freeSolo
+ style={{width: 'auto'}}
+ renderInput={(params) => (
+
+ )}
+ />
+ );
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/Components/SearchPage.tsx b/packages/cra-template-coveo/template/src/Components/SearchPage.tsx
new file mode 100644
index 0000000000..2865e26ae3
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/SearchPage.tsx
@@ -0,0 +1,66 @@
+import React from 'react';
+import Container from '@material-ui/core/Container';
+import Box from '@material-ui/core/Box';
+import Grid from '@material-ui/core/Grid';
+import SearchBox from './SearchBox';
+import QuerySummary from './QuerySummary';
+import ResultList from './ResultList';
+import Pager from './Pager';
+import Sort from './Sort';
+import FacetList from './FacetList';
+import ResultsPerPage from './ResultsPerPage';
+import {AnalyticsActions, SearchActions} from '@coveo/headless';
+import {headlessEngine} from '../Engine';
+
+export default class SearchPage extends React.Component {
+ componentDidMount() {
+ const {dispatch} = headlessEngine;
+ const action = SearchActions.executeSearch(
+ AnalyticsActions.logInterfaceLoad()
+ ) as any;
+ dispatch(action);
+ }
+
+ render() {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/Components/Sort.tsx b/packages/cra-template-coveo/template/src/Components/Sort.tsx
new file mode 100644
index 0000000000..b87eb6684d
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Components/Sort.tsx
@@ -0,0 +1,81 @@
+import React from 'react';
+import {
+ Sort as SortType,
+ SortState,
+ buildSort,
+ buildRelevanceSortCriterion,
+ buildDateSortCriterion,
+ SortOrder,
+ SortByRelevancy,
+ SortByDate,
+} from '@coveo/headless';
+import {headlessEngine} from '../Engine';
+import Box from '@material-ui/core/Box';
+import FormControl from '@material-ui/core/FormControl';
+import {InputLabel, MenuItem, Select} from '@material-ui/core';
+
+export default class Sort extends React.Component {
+ private headlessSort: SortType;
+ state: SortState;
+ relevanceSortCriterion: SortByRelevancy = buildRelevanceSortCriterion();
+ dateDescendingSortCriterion: SortByDate = buildDateSortCriterion(
+ SortOrder.Descending
+ );
+ dateAscendingSortCriterion: SortByDate = buildDateSortCriterion(
+ SortOrder.Ascending
+ );
+
+ constructor(props: any) {
+ super(props);
+
+ this.headlessSort = buildSort(headlessEngine, {
+ initialState: {
+ criterion: this.relevanceSortCriterion,
+ },
+ });
+
+ this.state = this.headlessSort.state;
+ }
+
+ componentDidMount() {
+ this.headlessSort.subscribe(() => this.updateState());
+ }
+
+ updateState() {
+ this.setState(this.headlessSort.state);
+ }
+
+ handleChange(event: any) {
+ switch (event.target.value) {
+ case 'relevance':
+ this.headlessSort.sortBy(this.relevanceSortCriterion);
+ break;
+ case 'datedescending':
+ this.headlessSort.sortBy(this.dateDescendingSortCriterion);
+ break;
+ default:
+ this.headlessSort.sortBy(this.dateAscendingSortCriterion);
+ break;
+ }
+ }
+
+ render() {
+ return (
+
+
+ Sort by
+ this.handleChange(event)}
+ defaultValue="relevance"
+ >
+ Relevance
+ Date Descending
+ Date Ascending
+
+
+
+ );
+ }
+}
diff --git a/packages/cra-template-coveo/template/src/Engine.tsx b/packages/cra-template-coveo/template/src/Engine.tsx
new file mode 100644
index 0000000000..27aca3bc52
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/Engine.tsx
@@ -0,0 +1,6 @@
+import {HeadlessEngine, searchAppReducers} from '@coveo/headless';
+
+export const headlessEngine = new HeadlessEngine({
+ configuration: HeadlessEngine.getSampleConfiguration(),
+ reducers: searchAppReducers,
+});
diff --git a/packages/cra-template-coveo/template/src/index.css b/packages/cra-template-coveo/template/src/index.css
new file mode 100644
index 0000000000..ec2585e8c0
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/index.css
@@ -0,0 +1,13 @@
+body {
+ margin: 0;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
+ sans-serif;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+code {
+ font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
+ monospace;
+}
diff --git a/packages/cra-template-coveo/template/src/index.tsx b/packages/cra-template-coveo/template/src/index.tsx
new file mode 100644
index 0000000000..06f09a095f
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/index.tsx
@@ -0,0 +1,16 @@
+import React from 'react';
+import {render} from 'react-dom';
+import CssBaseline from '@material-ui/core/CssBaseline';
+import {ThemeProvider} from '@material-ui/core/styles';
+import App from './App';
+import theme from './theme';
+
+const rootElement = document.getElementById('root');
+render(
+
+ {/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
+
+
+ ,
+ rootElement
+);
diff --git a/packages/cra-template-coveo/template/src/logo.svg b/packages/cra-template-coveo/template/src/logo.svg
new file mode 100644
index 0000000000..9dfc1c058c
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/logo.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/packages/cra-template-coveo/template/src/reportWebVitals.ts b/packages/cra-template-coveo/template/src/reportWebVitals.ts
new file mode 100644
index 0000000000..b7876a4776
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/reportWebVitals.ts
@@ -0,0 +1,15 @@
+import {ReportHandler} from 'web-vitals';
+
+const reportWebVitals = (onPerfEntry?: ReportHandler) => {
+ if (onPerfEntry && onPerfEntry instanceof Function) {
+ import('web-vitals').then(({getCLS, getFID, getFCP, getLCP, getTTFB}) => {
+ getCLS(onPerfEntry);
+ getFID(onPerfEntry);
+ getFCP(onPerfEntry);
+ getLCP(onPerfEntry);
+ getTTFB(onPerfEntry);
+ });
+ }
+};
+
+export default reportWebVitals;
diff --git a/packages/cra-template-coveo/template/src/setupTests.ts b/packages/cra-template-coveo/template/src/setupTests.ts
new file mode 100644
index 0000000000..8f2609b7b3
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/setupTests.ts
@@ -0,0 +1,5 @@
+// jest-dom adds custom jest matchers for asserting on DOM nodes.
+// allows you to do things like:
+// expect(element).toHaveTextContent(/react/i)
+// learn more: https://github.com/testing-library/jest-dom
+import '@testing-library/jest-dom';
diff --git a/packages/cra-template-coveo/template/src/theme.tsx b/packages/cra-template-coveo/template/src/theme.tsx
new file mode 100644
index 0000000000..62a61e5710
--- /dev/null
+++ b/packages/cra-template-coveo/template/src/theme.tsx
@@ -0,0 +1,34 @@
+import red from '@material-ui/core/colors/red';
+import {createMuiTheme} from '@material-ui/core/styles';
+
+// A custom theme for this app
+const theme = createMuiTheme({
+ palette: {
+ type: 'light',
+ text: {
+ // You can easily change the overall text color
+ // primary: '#282829',
+ // secondary: '#E5E8E8',
+ },
+ primary: {
+ main: '#2e45ba', // Ebony Clay
+ },
+ secondary: {
+ main: '#004990',
+ },
+ error: {
+ main: red.A400,
+ },
+ background: {
+ default: '#fff',
+ },
+ },
+ typography: {
+ fontFamily: 'Avenir, Helvetica, Arial, sans-serif',
+ // Material-UI uses rem units for the font size. This will change the base size for the entire search page
+ // More info at https://material-ui.com/customization/typography/#font-size
+ fontSize: 17,
+ },
+});
+
+export default theme;