Skip to content

Commit

Permalink
docs: More refinement of the public documentation page
Browse files Browse the repository at this point in the history
  • Loading branch information
joerideg committed Dec 3, 2024
1 parent 5e29f17 commit 1469ac6
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions readme/limitless-ui-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ const SearchPage = () => {
searchOptions={searchOptions}
searchType="product"
/>

<Results resultComponent={(result) => <div>{result.title}</div>} />
</div>
);
};
Expand All @@ -139,8 +141,8 @@ register them within React state:
```jsx
import { useSearch } from '@bloomreach/limitless-ui-react';

const SearchComponent = ({ configuration, searchOptions }) => {
const { response, loading, error } = useSearch('product', configuration, searchOptions);
const SearchComponent = ({ query, configuration, searchOptions }) => {
const { response, loading, error } = useSearch('product', query, configuration, searchOptions);

if (loading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
Expand All @@ -161,18 +163,6 @@ the context and outputs state and handlers to build your own custom component:
```jsx
import { useSearchBox, SearchContext } from '@bloomreach/limitless-ui-react';

const Results = () => {
const context = useContext(SearchContext);
return context?.searchResponse?.response?.docs?.map((result) => {
return (
<div key={result.pid}>
<h2>{result.title}</h2>
<p>{result.description}</p>
</div>
);
});
};

const CustomSearchBox = (props) => {
const { response, loading, error, changeHandler, submitHandler, resetHandler, inputValue } =
useSearchBox(props);
Expand All @@ -184,7 +174,12 @@ const CustomSearchBox = (props) => {
<button type="reset">Clear</button>
</form>

<Results />
<Results resultComponent={() => (
<div key={result.pid}>
<h2>{result.title}</h2>
<p>{result.description}</p>
</div>
)} />
);
};
```
Expand All @@ -210,7 +205,6 @@ const SearchPage = () => {
}}
>
<SearchBox.Suggestions
configuration={/* your configuration */}
suggestOptions={/* your suggestion options */}
onQuerySelect={(query, event) => {
// Handle query selection
Expand All @@ -228,10 +222,8 @@ const SearchPage = () => {
### Using Components + Style bundle

The headless components can be combined with the optional style bundle and to get a full
'out-of-the-box' experience. One can simply import `style.css` from the package.
<!-- ## Type documentation -->
<!-- For a type reference see the TSDoc published [here](.) -->
'out-of-the-box' experience. Simply import `style.css` from the package in your projects preferred
way.

## Troubleshooting

Expand Down

0 comments on commit 1469ac6

Please sign in to comment.