Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve with-algolia-react-instantsearch example and convert to TypeScript #42617

Merged
merged 2 commits into from Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 56 additions & 0 deletions examples/with-algolia-react-instantsearch/components/Search.tsx
@@ -0,0 +1,56 @@
import {
RefinementList,
SearchBox,
Hits,
Configure,
Highlight,
Pagination,
InstantSearch,
} from 'react-instantsearch-dom'
import type { InstantSearchProps } from 'react-instantsearch-dom'

const HitComponent = ({ hit }: any) => (
<div className="hit">
<div>
<div className="hit-picture">
<img src={`${hit.image}`} />
</div>
</div>
<div className="hit-content">
<div>
<Highlight attribute="name" hit={hit} />
<span> - ${hit.price}</span>
<span> - {hit.rating} stars</span>
</div>
<div className="hit-type">
<Highlight attribute="type" hit={hit} />
</div>
<div className="hit-description">
<Highlight attribute="description" hit={hit} />
</div>
</div>
</div>
)

export function Search(props: InstantSearchProps) {
return (
<InstantSearch {...props}>
<Configure hitsPerPage={12} />
<header>
<h1>React InstantSearch + Next.js</h1>
<SearchBox />
</header>
<main>
<div className="menu">
<RefinementList attribute="categories" />
</div>
<div className="results">
<Hits hitComponent={HitComponent} />
</div>
</main>
<footer>
<Pagination />
</footer>
</InstantSearch>
)
}
81 changes: 0 additions & 81 deletions examples/with-algolia-react-instantsearch/components/app.js

This file was deleted.

48 changes: 0 additions & 48 deletions examples/with-algolia-react-instantsearch/components/head.js

This file was deleted.

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions examples/with-algolia-react-instantsearch/next.config.js

This file was deleted.

22 changes: 14 additions & 8 deletions examples/with-algolia-react-instantsearch/package.json
Expand Up @@ -2,19 +2,25 @@
"private": true,
"scripts": {
"dev": "next",
"build": "cross-env NODE_ENV=development next build",
"build": "next build",
"start": "next start"
},
"dependencies": {
"algoliasearch": "4.3.0",
"cross-env": "^7.0.2",
"css-loader": "1.0.0",
"algoliasearch": "^4.14.2",
"instantsearch.css": "^7.4.5",
"next": "latest",
"prop-types": "^15.5.10",
"qs": "^6.4.0",
"qs": "^6.11.0",
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-instantsearch-dom": "6.6.0",
"style-loader": "^0.17.0"
"react-instantsearch-dom": "^6.38.0"
},
"devDependencies": {
"@types/node": "^18.11.9",
"@types/qs": "^6.9.7",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"@types/react-instantsearch-core": "^6.26.2",
"@types/react-instantsearch-dom": "^6.12.3",
"typescript": "^4.8.4"
}
}
7 changes: 7 additions & 0 deletions examples/with-algolia-react-instantsearch/pages/_app.tsx
@@ -0,0 +1,7 @@
import type { AppProps } from 'next/app'
import 'instantsearch.css/themes/algolia.css'
import '../styles/global.css'

export default function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
60 changes: 0 additions & 60 deletions examples/with-algolia-react-instantsearch/pages/index.js

This file was deleted.