Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve
with-algolia-react-instantsearch
example and convert to Typ…
…eScript (#42617) Converted to TypeScript to match Contribution docs, and updated/simplified the example. - Replaced stylesheets in Head component with imported styles - Removed `style-loader`, `css-loader`, `cross-env`, `prop-types` packages - Removed custom webpack config ## Documentation / Examples - [X] Make sure the linting passes by running `pnpm build && pnpm lint` - [X] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
- Loading branch information
Showing
14 changed files
with
202 additions
and
236 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
examples/with-algolia-react-instantsearch/components/Search.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
81
examples/with-algolia-react-instantsearch/components/app.js
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
examples/with-algolia-react-instantsearch/components/head.js
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
examples/with-algolia-react-instantsearch/components/index.js
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
examples/with-algolia-react-instantsearch/components/instantsearch.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} /> | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.